@lvce-editor/file-search-worker 3.4.0 → 3.5.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.
@@ -54,6 +54,41 @@ class VError extends Error {
54
54
  }
55
55
  }
56
56
 
57
+ class AssertionError extends Error {
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = 'AssertionError';
61
+ }
62
+ }
63
+ const getType = value => {
64
+ switch (typeof value) {
65
+ case 'number':
66
+ return 'number';
67
+ case 'function':
68
+ return 'function';
69
+ case 'string':
70
+ return 'string';
71
+ case 'object':
72
+ if (value === null) {
73
+ return 'null';
74
+ }
75
+ if (Array.isArray(value)) {
76
+ return 'array';
77
+ }
78
+ return 'object';
79
+ case 'boolean':
80
+ return 'boolean';
81
+ default:
82
+ return 'unknown';
83
+ }
84
+ };
85
+ const array = value => {
86
+ const type = getType(value);
87
+ if (type !== 'array') {
88
+ throw new AssertionError('expected value to be of type array');
89
+ }
90
+ };
91
+
57
92
  const isMessagePort = value => {
58
93
  return value && value instanceof MessagePort;
59
94
  };
@@ -389,32 +424,32 @@ const create$4 = (method, params) => {
389
424
  };
390
425
  };
391
426
  const callbacks = Object.create(null);
392
- const set = (id, fn) => {
427
+ const set$1 = (id, fn) => {
393
428
  callbacks[id] = fn;
394
429
  };
395
- const get = id => {
430
+ const get$1 = id => {
396
431
  return callbacks[id];
397
432
  };
398
433
  const remove$2 = id => {
399
434
  delete callbacks[id];
400
435
  };
401
436
  let id = 0;
402
- const create$3 = () => {
437
+ const create$3$1 = () => {
403
438
  return ++id;
404
439
  };
405
440
  const registerPromise = () => {
406
- const id = create$3();
441
+ const id = create$3$1();
407
442
  const {
408
443
  resolve,
409
444
  promise
410
445
  } = Promise.withResolvers();
411
- set(id, resolve);
446
+ set$1(id, resolve);
412
447
  return {
413
448
  id,
414
449
  promise
415
450
  };
416
451
  };
417
- const create$2 = (method, params) => {
452
+ const create$2$1 = (method, params) => {
418
453
  const {
419
454
  id,
420
455
  promise
@@ -565,7 +600,7 @@ const warn$1 = (...args) => {
565
600
  console.warn(...args);
566
601
  };
567
602
  const resolve = (id, response) => {
568
- const fn = get(id);
603
+ const fn = get$1(id);
569
604
  if (!fn) {
570
605
  console.log(response);
571
606
  warn$1(`callback ${id} may already be disposed`);
@@ -604,7 +639,7 @@ const getErrorProperty = (error, prettyError) => {
604
639
  }
605
640
  };
606
641
  };
607
- const create$1 = (message, error) => {
642
+ const create$1$1 = (message, error) => {
608
643
  return {
609
644
  jsonrpc: Two,
610
645
  id: message.id,
@@ -615,7 +650,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
615
650
  const prettyError = preparePrettyError(error);
616
651
  logError(error, prettyError);
617
652
  const errorProperty = getErrorProperty(error, prettyError);
618
- return create$1(message, errorProperty);
653
+ return create$1$1(message, errorProperty);
619
654
  };
620
655
  const create$5 = (message, result) => {
621
656
  return {
@@ -706,7 +741,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
706
741
  const {
707
742
  message,
708
743
  promise
709
- } = create$2(method, params);
744
+ } = create$2$1(method, params);
710
745
  if (useSendAndTransfer && ipc.sendAndTransfer) {
711
746
  ipc.sendAndTransfer(message);
712
747
  } else {
@@ -790,7 +825,7 @@ const listen$1 = async (module, options) => {
790
825
  const ipc = module.wrap(rawIpc);
791
826
  return ipc;
792
827
  };
793
- const create = async ({
828
+ const create$3 = async ({
794
829
  commandMap
795
830
  }) => {
796
831
  // TODO create a commandMap per rpc instance
@@ -802,247 +837,404 @@ const create = async ({
802
837
  };
803
838
  const WebWorkerRpcClient = {
804
839
  __proto__: null,
805
- create
840
+ create: create$3
806
841
  };
807
842
 
808
- const assetDir = '';
809
-
810
- const Directory$1 = 3;
811
- const File$2 = 7;
843
+ const User = 1;
844
+ const Script = 2;
812
845
 
813
- const fileMapUrl = `${assetDir}/config/fileMap.json`;
846
+ const minimumSliderSize = 20;
814
847
 
815
- const getBlob$2 = async url => {
816
- try {
817
- const response = await fetch(url);
818
- if (!response.ok) {
819
- throw new Error(response.statusText);
820
- }
821
- const text = await response.blob();
822
- return text;
823
- } catch (error) {
824
- throw new VError(error, `Failed to request blob for ${url}`);
825
- }
848
+ const handleError = async (error, notify = true, prefix = '') => {
849
+ console.error(error);
826
850
  };
827
-
828
- const getJson = async url => {
829
- try {
830
- const response = await fetch(url);
831
- if (!response.ok) {
832
- throw new Error(response.statusText);
833
- }
834
- const text = await response.json();
835
- return text;
836
- } catch (error) {
837
- throw new VError(error, `Failed to request json for ${url}`);
838
- }
851
+ const showErrorDialog = async () => {};
852
+ const warn = (...args) => {
853
+ console.warn(...args);
839
854
  };
840
855
 
841
- const getText = async url => {
842
- try {
843
- const response = await fetch(url);
844
- if (!response.ok) {
845
- throw new Error(response.statusText);
846
- }
847
- const text = await response.text();
848
- return text;
849
- } catch (error) {
850
- throw new VError(error, `Failed to request text for ${url}`);
851
- }
856
+ const state$5 = {
857
+ menuEntries: []
858
+ };
859
+ const getAll = () => {
860
+ return state$5.menuEntries;
852
861
  };
853
862
 
854
- const Slash$1 = '/';
855
-
856
- const Slash = Slash$1;
863
+ const Hide = 'hide';
864
+ const KeepOpen = '';
857
865
 
858
- // TODO move all of this to an extension
866
+ const emptyObject = {};
867
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
868
+ const i18nString = (key, placeholders = emptyObject) => {
869
+ if (placeholders === emptyObject) {
870
+ return key;
871
+ }
872
+ const replacer = (match, rest) => {
873
+ return placeholders[rest];
874
+ };
875
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
876
+ };
859
877
 
860
- const readFile$1 = async uri => {
861
- const fetchUri = `${assetDir}${uri}`;
862
- const text = await getText(fetchUri);
863
- return text;
878
+ /**
879
+ * @enum {string}
880
+ */
881
+ const UiStrings = {
882
+ Files: 'Files',
883
+ GoToFile: 'Go to file',
884
+ NoMatchingColorThemesFound: 'No matching color themes found',
885
+ NoMatchingResults: 'No matching results',
886
+ NoRecentlyOpenedFoldersFound: 'No recently opened folders found',
887
+ NoResults: 'No Results',
888
+ NoSymbolFound: 'No symbol found',
889
+ NoWorkspaceSymbolsFound: 'no workspace symbols found',
890
+ OpenRecent: 'Open Recent',
891
+ SelectColorTheme: 'Select Color Theme',
892
+ SelectToOpen: 'Select to open',
893
+ ShowAndRunCommands: 'Show And Run Commands',
894
+ TypeNameOfCommandToRun: 'Type the name of a command to run.',
895
+ TypeTheNameOfAViewToOpen: 'Type the name of a view, output channel or terminal to open.'
864
896
  };
865
- const writeFile$1 = () => {
866
- throw new Error('not implemented');
897
+ const noMatchingColorThemesFound = () => {
898
+ return i18nString(UiStrings.NoMatchingColorThemesFound);
867
899
  };
868
- const mkdir$1 = () => {
869
- throw new Error('not implemented');
900
+ const selectColorTheme = () => {
901
+ return i18nString(UiStrings.SelectColorTheme);
870
902
  };
871
- const remove$1 = () => {
872
- throw new Error('not implemented');
903
+ const typeNameofCommandToRun = () => {
904
+ return i18nString(UiStrings.TypeNameOfCommandToRun);
873
905
  };
874
- const readDirWithFileTypes$1 = async uri => {
875
- const fileList = await getJson(fileMapUrl);
876
- const dirents = [];
877
- for (const fileUri of fileList) {
878
- if (fileUri.startsWith(uri)) {
879
- const rest = fileUri.slice(uri.length + 1);
880
- if (rest.includes(Slash)) {
881
- const name = rest.slice(0, rest.indexOf(Slash));
882
- if (dirents.some(dirent => dirent.name === name)) {
883
- continue;
884
- }
885
- dirents.push({
886
- type: Directory$1,
887
- name
888
- });
889
- } else {
890
- dirents.push({
891
- type: File$2,
892
- name: rest
893
- });
894
- }
895
- }
896
- }
897
- return dirents;
906
+ const showAndRunCommands = () => {
907
+ return i18nString(UiStrings.ShowAndRunCommands);
898
908
  };
899
- const chmod$1 = () => {
900
- throw new Error('[memfs] chmod not implemented');
909
+ const noMatchingResults = () => {
910
+ return i18nString(UiStrings.NoMatchingResults);
901
911
  };
902
- const getBlob$1 = async (uri, type) => {
903
- const fetchUri = `${assetDir}${uri}`;
904
- const blob = getBlob$2(fetchUri);
905
- return blob;
912
+ const files = () => {
913
+ return i18nString(UiStrings.Files);
906
914
  };
907
-
908
- class FileNotFoundError extends Error {
909
- constructor(uri) {
910
- super(`File not found: ${uri}`);
911
- this.code = 'ENOENT';
912
- }
913
- }
914
-
915
- const ApplicationJson = 'application/json';
916
- const AudioMpeg = 'audio/mpeg';
917
- const FontTtf = 'font/ttf';
918
- const ImagePng = 'image/png';
919
- const ImageSvgXml = 'image/svg+xml';
920
- const TextCss = 'text/css';
921
- const TextHtml = 'text/html';
922
- const TextJavaScript = 'text/javascript';
923
- const TextPlain = 'text/plain';
924
- const VideoWebm = 'video/webm';
925
-
926
- const getMimeType = fileExtension => {
927
- switch (fileExtension) {
928
- case '.html':
929
- return TextHtml;
930
- case '.css':
931
- return TextCss;
932
- case '.ttf':
933
- return FontTtf;
934
- case '.js':
935
- case '.mjs':
936
- case '.ts':
937
- return TextJavaScript;
938
- case '.svg':
939
- return ImageSvgXml;
940
- case '.png':
941
- return ImagePng;
942
- case '.json':
943
- case '.map':
944
- return ApplicationJson;
945
- case '.mp3':
946
- return AudioMpeg;
947
- case '.webm':
948
- return VideoWebm;
949
- case '.txt':
950
- return TextPlain;
951
- default:
952
- return '';
953
- }
915
+ const goToFile = () => {
916
+ return i18nString(UiStrings.GoToFile);
954
917
  };
955
-
956
- const dirname = (pathSeparator, path) => {
957
- const index = path.lastIndexOf(pathSeparator);
958
- if (index === -1) {
959
- return path;
960
- }
961
- return path.slice(0, index);
918
+ const noResults = () => {
919
+ return i18nString(UiStrings.NoResults);
962
920
  };
963
- const extname = path => {
964
- const index = path.lastIndexOf('.');
965
- if (index === -1) {
966
- return '';
967
- }
968
- return path.slice(index);
921
+ const selectToOpen = () => {
922
+ return i18nString(UiStrings.SelectToOpen);
923
+ };
924
+ const openRecent = () => {
925
+ return i18nString(UiStrings.OpenRecent);
926
+ };
927
+ const noRecentlyOpenedFoldersFound = () => {
928
+ return i18nString(UiStrings.NoRecentlyOpenedFoldersFound);
929
+ };
930
+ const noSymbolFound = () => {
931
+ return i18nString(UiStrings.NoSymbolFound);
932
+ };
933
+ const noWorkspaceSymbolsFound = () => {
934
+ return i18nString(UiStrings.NoWorkspaceSymbolsFound);
969
935
  };
970
936
 
971
- const getContentType = uri => {
972
- const extension = extname(uri);
973
- const mime = getMimeType(extension);
974
- return mime;
937
+ const state$4 = {
938
+ rpc: undefined
975
939
  };
976
940
 
977
- // TODO move this to an extension?
941
+ // TODO use rpc registry
942
+ const invoke$1 = (method, ...params) => {
943
+ const rpc = state$4.rpc;
944
+ // @ts-ignore
945
+ return rpc.invoke(method, ...params);
946
+ };
947
+ const setRpc = rpc => {
948
+ state$4.rpc = rpc;
949
+ };
978
950
 
979
- const state$5 = {
980
- files: Object.create(null)
951
+ const name$8 = 'command';
952
+ const getPlaceholder$b = () => {
953
+ return typeNameofCommandToRun();
981
954
  };
982
- const getDirent = uri => {
983
- return state$5.files[uri];
955
+ const helpEntries = () => {
956
+ return [{
957
+ description: showAndRunCommands(),
958
+ category: 'global commands'
959
+ }];
984
960
  };
985
- const readFile = uri => {
986
- const dirent = getDirent(uri);
987
- if (!dirent) {
988
- throw new FileNotFoundError(uri);
989
- }
990
- if (dirent.type !== File$2) {
991
- throw new Error('file is a directory');
992
- }
993
- return dirent.content;
961
+ const getLabel$5 = () => {
962
+ return '';
994
963
  };
995
- const ensureParentDir = uri => {
996
- const startIndex = 0;
997
- let endIndex = uri.indexOf(Slash);
998
- while (endIndex >= 0) {
964
+ const getNoResults$a = () => {
965
+ return {
966
+ label: noMatchingResults()
967
+ };
968
+ };
969
+
970
+ // TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
971
+ const getBuiltinPicks = async () => {
972
+ const builtinPicks = getAll();
973
+ return builtinPicks;
974
+ };
975
+ const prefixIdWithExt = item => {
976
+ if (!item.label) {
977
+ warn('[QuickPick] item has missing label', item);
978
+ }
979
+ if (!item.id) {
980
+ warn('[QuickPick] item has missing id', item);
981
+ }
982
+ return {
983
+ ...item,
984
+ id: `ext.${item.id}`,
985
+ label: item.label || item.id
986
+ };
987
+ };
988
+ const getExtensionPicks = async () => {
989
+ try {
990
+ // TODO don't call this every time
991
+ const extensionPicks = await invoke$1('ExtensionHostCommands.getCommands');
992
+ if (!extensionPicks) {
993
+ return [];
994
+ }
995
+ const mappedPicks = extensionPicks.map(prefixIdWithExt);
996
+ return mappedPicks;
997
+ } catch (error) {
998
+ console.error(`Failed to get extension picks: ${error}`);
999
+ return [];
1000
+ }
1001
+ };
1002
+
1003
+ // TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
1004
+
1005
+ const getPicks$b = async () => {
1006
+ const builtinPicks = await getBuiltinPicks();
1007
+ const extensionPicks = await getExtensionPicks();
1008
+ return [...builtinPicks, ...extensionPicks];
1009
+ };
1010
+ const shouldHide = item => {
1011
+ if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
1012
+ return false;
1013
+ }
1014
+ return true;
1015
+ };
1016
+ const selectPickBuiltin = async item => {
1017
+ const args = item.args || [];
1018
+ // TODO ids should be all numbers for efficiency -> also directly can call command
1019
+ await invoke$1(item.id, ...args);
1020
+ if (shouldHide(item)) {
1021
+ return {
1022
+ command: Hide
1023
+ };
1024
+ }
1025
+ return {
1026
+ command: KeepOpen
1027
+ };
1028
+ };
1029
+ const selectPickExtension = async item => {
1030
+ const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
1031
+ try {
1032
+ await invoke$1('ExtensionHostCommands.executeCommand', id);
1033
+ } catch (error) {
1034
+ await handleError(error, false);
1035
+ // @ts-ignore
1036
+ await showErrorDialog();
1037
+ }
1038
+ return {
1039
+ command: Hide
1040
+ };
1041
+ };
1042
+ const selectPick$b = async item => {
1043
+ if (item.id.startsWith('ext.')) {
1044
+ return selectPickExtension(item);
1045
+ }
1046
+ return selectPickBuiltin(item);
1047
+ };
1048
+ const getFilterValue$a = value => {
1049
+ return value;
1050
+ };
1051
+ const getPickFilterValue$6 = pick => {
1052
+ return pick.label;
1053
+ };
1054
+ const getPickLabel$5 = pick => {
1055
+ return pick.label;
1056
+ };
1057
+ const getPickIcon$5 = () => {
1058
+ return '';
1059
+ };
1060
+
1061
+ const QuickPickEntriesCommand = {
1062
+ __proto__: null,
1063
+ getFilterValue: getFilterValue$a,
1064
+ getLabel: getLabel$5,
1065
+ getNoResults: getNoResults$a,
1066
+ getPickFilterValue: getPickFilterValue$6,
1067
+ getPickIcon: getPickIcon$5,
1068
+ getPickLabel: getPickLabel$5,
1069
+ getPicks: getPicks$b,
1070
+ getPlaceholder: getPlaceholder$b,
1071
+ helpEntries,
1072
+ name: name$8,
1073
+ selectPick: selectPick$b
1074
+ };
1075
+
1076
+ const execute = async (method, ...params) => {
1077
+ // TODO
1078
+ };
1079
+
1080
+ const RE_PROTOCOL = /^([a-z-]+):\/\//;
1081
+ const getProtocol = uri => {
1082
+ const protocolMatch = uri.match(RE_PROTOCOL);
1083
+ if (protocolMatch) {
1084
+ return protocolMatch[1];
1085
+ }
1086
+ return '';
1087
+ };
1088
+
1089
+ const Memfs = 'memfs';
1090
+ const Html = 'html';
1091
+ const Fetch = 'fetch';
1092
+
1093
+ const Directory$1 = 3;
1094
+ const File$2 = 7;
1095
+
1096
+ class FileNotFoundError extends Error {
1097
+ constructor(uri) {
1098
+ super(`File not found: ${uri}`);
1099
+ this.code = 'ENOENT';
1100
+ }
1101
+ }
1102
+
1103
+ const ApplicationJson = 'application/json';
1104
+ const AudioMpeg = 'audio/mpeg';
1105
+ const FontTtf = 'font/ttf';
1106
+ const ImagePng = 'image/png';
1107
+ const ImageSvgXml = 'image/svg+xml';
1108
+ const TextCss = 'text/css';
1109
+ const TextHtml = 'text/html';
1110
+ const TextJavaScript = 'text/javascript';
1111
+ const TextPlain = 'text/plain';
1112
+ const VideoWebm = 'video/webm';
1113
+
1114
+ const getMimeType = fileExtension => {
1115
+ switch (fileExtension) {
1116
+ case '.html':
1117
+ return TextHtml;
1118
+ case '.css':
1119
+ return TextCss;
1120
+ case '.ttf':
1121
+ return FontTtf;
1122
+ case '.js':
1123
+ case '.mjs':
1124
+ case '.ts':
1125
+ return TextJavaScript;
1126
+ case '.svg':
1127
+ return ImageSvgXml;
1128
+ case '.png':
1129
+ return ImagePng;
1130
+ case '.json':
1131
+ case '.map':
1132
+ return ApplicationJson;
1133
+ case '.mp3':
1134
+ return AudioMpeg;
1135
+ case '.webm':
1136
+ return VideoWebm;
1137
+ case '.txt':
1138
+ return TextPlain;
1139
+ default:
1140
+ return '';
1141
+ }
1142
+ };
1143
+
1144
+ const dirname = (pathSeparator, path) => {
1145
+ const index = path.lastIndexOf(pathSeparator);
1146
+ if (index === -1) {
1147
+ return path;
1148
+ }
1149
+ return path.slice(0, index);
1150
+ };
1151
+ const extname = path => {
1152
+ const index = path.lastIndexOf('.');
1153
+ if (index === -1) {
1154
+ return '';
1155
+ }
1156
+ return path.slice(index);
1157
+ };
1158
+
1159
+ const getContentType = uri => {
1160
+ const extension = extname(uri);
1161
+ const mime = getMimeType(extension);
1162
+ return mime;
1163
+ };
1164
+
1165
+ const Slash$1 = '/';
1166
+
1167
+ const Slash = Slash$1;
1168
+
1169
+ // TODO move this to an extension?
1170
+
1171
+ const state$3 = {
1172
+ files: Object.create(null)
1173
+ };
1174
+ const getDirent = uri => {
1175
+ return state$3.files[uri];
1176
+ };
1177
+ const readFile$1 = uri => {
1178
+ const dirent = getDirent(uri);
1179
+ if (!dirent) {
1180
+ throw new FileNotFoundError(uri);
1181
+ }
1182
+ if (dirent.type !== File$2) {
1183
+ throw new Error('file is a directory');
1184
+ }
1185
+ return dirent.content;
1186
+ };
1187
+ const ensureParentDir = uri => {
1188
+ const startIndex = 0;
1189
+ let endIndex = uri.indexOf(Slash);
1190
+ while (endIndex >= 0) {
999
1191
  const part = uri.slice(startIndex, endIndex + 1);
1000
- state$5.files[part] = {
1192
+ state$3.files[part] = {
1001
1193
  type: Directory$1,
1002
1194
  content: ''
1003
1195
  };
1004
1196
  endIndex = uri.indexOf(Slash, endIndex + 1);
1005
1197
  }
1006
1198
  };
1007
- const writeFile = (uri, content) => {
1199
+ const writeFile$1 = (uri, content) => {
1008
1200
  const dirent = getDirent(uri);
1009
1201
  if (dirent) {
1010
1202
  dirent.content = content;
1011
1203
  } else {
1012
1204
  ensureParentDir(uri);
1013
- state$5.files[uri] = {
1205
+ state$3.files[uri] = {
1014
1206
  type: File$2,
1015
1207
  content
1016
1208
  };
1017
1209
  }
1018
1210
  };
1019
- const mkdir = uri => {
1211
+ const mkdir$1 = uri => {
1020
1212
  if (!uri.endsWith(Slash)) {
1021
1213
  uri += Slash;
1022
1214
  }
1023
1215
  ensureParentDir(uri);
1024
- state$5.files[uri] = {
1216
+ state$3.files[uri] = {
1025
1217
  type: Directory$1,
1026
1218
  content: ''
1027
1219
  };
1028
1220
  };
1029
- const remove = uri => {
1221
+ const remove$1 = uri => {
1030
1222
  const toDelete = [];
1031
- for (const key of Object.keys(state$5.files)) {
1223
+ for (const key of Object.keys(state$3.files)) {
1032
1224
  if (key.startsWith(uri)) {
1033
1225
  toDelete.push(key);
1034
1226
  }
1035
1227
  }
1036
1228
  for (const key of toDelete) {
1037
- delete state$5.files[key];
1229
+ delete state$3.files[key];
1038
1230
  }
1039
1231
  };
1040
- const readDirWithFileTypes = uri => {
1232
+ const readDirWithFileTypes$1 = uri => {
1041
1233
  if (!uri.endsWith(Slash)) {
1042
1234
  uri += Slash;
1043
1235
  }
1044
1236
  const dirents = [];
1045
- for (const [key, value] of Object.entries(state$5.files)) {
1237
+ for (const [key, value] of Object.entries(state$3.files)) {
1046
1238
  if (key.startsWith(uri)) {
1047
1239
  // @ts-ignore
1048
1240
  switch (value.type) {
@@ -1069,8 +1261,8 @@ const readDirWithFileTypes = uri => {
1069
1261
  }
1070
1262
  return dirents;
1071
1263
  };
1072
- const getBlob = (uri, type) => {
1073
- const content = readFile(uri);
1264
+ const getBlob$2 = (uri, type) => {
1265
+ const content = readFile$1(uri);
1074
1266
  const contentType = type || getContentType(uri);
1075
1267
  const blob = new Blob([content], {
1076
1268
  type: contentType
@@ -1078,762 +1270,43 @@ const getBlob = (uri, type) => {
1078
1270
  return blob;
1079
1271
  };
1080
1272
  const getBlobUrl = (uri, type) => {
1081
- const blob = getBlob(uri, type);
1273
+ const blob = getBlob$2(uri, type);
1082
1274
  const url = URL.createObjectURL(blob);
1083
1275
  return url;
1084
1276
  };
1085
- const chmod = () => {
1277
+ const chmod$1 = () => {
1086
1278
  throw new Error('[memfs] chmod not implemented');
1087
1279
  };
1088
1280
  const getFiles = () => {
1089
- return state$5.files;
1281
+ return state$3.files;
1090
1282
  };
1091
1283
 
1092
- const emptyMatches = [];
1284
+ const searchFile$4 = async () => {
1285
+ const files = await getFiles();
1286
+ const keys = Object.keys(files);
1287
+ return keys;
1288
+ };
1093
1289
 
1094
- const convertToPick = item => {
1095
- return {
1096
- pick: item,
1097
- matches: emptyMatches
1098
- };
1290
+ const SearchFileMemfs = {
1291
+ __proto__: null,
1292
+ searchFile: searchFile$4
1099
1293
  };
1100
1294
 
1101
- const Diagonal = 1;
1102
- const Left = 2;
1295
+ const assetDir = '';
1103
1296
 
1104
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1297
+ const fileMapUrl = `${assetDir}/config/fileMap.json`;
1105
1298
 
1106
- const createTable = size => {
1107
- const table = [];
1108
- for (let i = 0; i < size; i++) {
1109
- const row = new Uint8Array(size);
1110
- table.push(row);
1111
- }
1112
- return table;
1113
- };
1114
- const EmptyMatches = [];
1115
- const Dash = '-';
1116
- const Dot = '.';
1117
- const EmptyString = '';
1118
- const Space = ' ';
1119
- const Underline = '_';
1120
- const T = 't';
1121
- const isLowerCase = char => {
1122
- return char === char.toLowerCase();
1123
- };
1124
- const isUpperCase = char => {
1125
- return char === char.toUpperCase();
1126
- };
1127
-
1128
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1129
- const isGap = (columnCharBefore, columnChar) => {
1130
- switch (columnCharBefore) {
1131
- case Dash:
1132
- case Underline:
1133
- case EmptyString:
1134
- case T:
1135
- case Space:
1136
- case Dot:
1137
- return true;
1138
- }
1139
- if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
1140
- return true;
1141
- }
1142
- return false;
1143
- };
1144
-
1145
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1146
- const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
1147
- if (rowCharLow !== columnCharLow) {
1148
- return -1;
1149
- }
1150
- const isMatch = rowChar === columnChar;
1151
- if (isMatch) {
1152
- if (isDiagonalMatch) {
1153
- return 8;
1154
- }
1155
- if (isGap(columnCharBefore, columnChar)) {
1156
- return 8;
1157
- }
1158
- return 5;
1159
- }
1160
- if (isGap(columnCharBefore, columnChar)) {
1161
- return 8;
1162
- }
1163
- return 5;
1164
- };
1165
-
1166
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1167
-
1168
- const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
1169
- while (patternPos < patternLen && wordPos < wordLen) {
1170
- if (patternLow[patternPos] === wordLow[wordPos]) {
1171
- patternPos += 1;
1172
- }
1173
- wordPos += 1;
1174
- }
1175
- return patternPos === patternLen; // pattern must be exhausted
1176
- };
1177
-
1178
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1179
- const traceHighlights = (table, arrows, patternLength, wordLength) => {
1180
- let row = patternLength;
1181
- let column = wordLength;
1182
- const matches = [];
1183
- while (row >= 1 && column >= 1) {
1184
- const arrow = arrows[row][column];
1185
- if (arrow === Left) {
1186
- column--;
1187
- } else if (arrow === Diagonal) {
1188
- row--;
1189
- column--;
1190
- const start = column + 1;
1191
- while (row >= 1 && column >= 1) {
1192
- const arrow = arrows[row][column];
1193
- if (arrow === Left) {
1194
- break;
1195
- }
1196
- if (arrow === Diagonal) {
1197
- row--;
1198
- column--;
1199
- }
1200
- }
1201
- const end = column;
1202
- matches.unshift(end, start);
1203
- }
1204
- }
1205
- matches.unshift(table[patternLength][wordLength - 1]);
1206
- return matches;
1207
- };
1208
-
1209
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1210
- const gridSize = 128;
1211
- const table = createTable(gridSize);
1212
- const arrows = createTable(gridSize);
1213
- const fuzzySearch = (pattern, word) => {
1214
- const patternLength = Math.min(pattern.length, gridSize - 1);
1215
- const wordLength = Math.min(word.length, gridSize - 1);
1216
- const patternLower = pattern.toLowerCase();
1217
- const wordLower = word.toLowerCase();
1218
- if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
1219
- return EmptyMatches;
1220
- }
1221
- let strongMatch = false;
1222
- for (let row = 1; row < patternLength + 1; row++) {
1223
- const rowChar = pattern[row - 1];
1224
- const rowCharLow = patternLower[row - 1];
1225
- for (let column = 1; column < wordLength + 1; column++) {
1226
- const columnChar = word[column - 1];
1227
- const columnCharLow = wordLower[column - 1];
1228
- const columnCharBefore = word[column - 2] || '';
1229
- const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
1230
- const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
1231
- if (row === 1 && score > 5) {
1232
- strongMatch = true;
1233
- }
1234
- let diagonalScore = score + table[row - 1][column - 1];
1235
- if (isDiagonalMatch && score !== -1) {
1236
- diagonalScore += 2;
1237
- }
1238
- const leftScore = table[row][column - 1];
1239
- if (leftScore > diagonalScore) {
1240
- table[row][column] = leftScore;
1241
- arrows[row][column] = Left;
1242
- } else {
1243
- table[row][column] = diagonalScore;
1244
- arrows[row][column] = Diagonal;
1245
- }
1246
- }
1247
- }
1248
- if (!strongMatch) {
1249
- return EmptyMatches;
1250
- }
1251
- const highlights = traceHighlights(table, arrows, patternLength, wordLength);
1252
- return highlights;
1253
- };
1254
-
1255
- const filterQuickPickItem = (pattern, word) => {
1256
- const matches = fuzzySearch(pattern, word);
1257
- return matches;
1258
- };
1259
-
1260
- const getBaseName = path => {
1261
- return path.slice(path.lastIndexOf('/') + 1);
1262
- };
1263
-
1264
- const filterQuickPickItems = (items, value) => {
1265
- if (!value) {
1266
- return items.map(convertToPick);
1267
- }
1268
- const results = [];
1269
- for (const item of items) {
1270
- const baseName = getBaseName(item);
1271
- const matches = filterQuickPickItem(value, baseName);
1272
- if (matches.length > 0) {
1273
- results.push({
1274
- pick: item,
1275
- matches
1276
- });
1277
- }
1278
- }
1279
- return results;
1280
- };
1281
-
1282
- const Enter = 3;
1283
- const Escape = 8;
1284
- const PageUp = 10;
1285
- const PageDown = 11;
1286
- const UpArrow = 14;
1287
- const DownArrow = 16;
1288
-
1289
- const FocusQuickPickInput = 20;
1290
-
1291
- const getKeyBindings = () => {
1292
- return [{
1293
- key: Escape,
1294
- command: 'Viewlet.closeWidget',
1295
- args: ['QuickPick'],
1296
- when: FocusQuickPickInput
1297
- }, {
1298
- key: UpArrow,
1299
- command: 'QuickPick.focusPrevious',
1300
- when: FocusQuickPickInput
1301
- }, {
1302
- key: DownArrow,
1303
- command: 'QuickPick.focusNext',
1304
- when: FocusQuickPickInput
1305
- }, {
1306
- key: PageUp,
1307
- command: 'QuickPick.focusFirst',
1308
- when: FocusQuickPickInput
1309
- }, {
1310
- key: PageDown,
1311
- command: 'QuickPick.focusLast',
1312
- when: FocusQuickPickInput
1313
- }, {
1314
- key: Enter,
1315
- command: 'QuickPick.selectCurrentIndex',
1316
- when: FocusQuickPickInput
1317
- }];
1318
- };
1319
-
1320
- // TODO support file icons
1321
- const getFolderIcon = () => {
1322
- return '';
1323
- };
1324
-
1325
- const Hide = 'hide';
1326
- const KeepOpen = '';
1327
-
1328
- const emptyObject = {};
1329
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1330
- const i18nString = (key, placeholders = emptyObject) => {
1331
- if (placeholders === emptyObject) {
1332
- return key;
1333
- }
1334
- const replacer = (match, rest) => {
1335
- return placeholders[rest];
1336
- };
1337
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1338
- };
1339
-
1340
- /**
1341
- * @enum {string}
1342
- */
1343
- const UiStrings = {
1344
- Files: 'Files',
1345
- GoToFile: 'Go to file',
1346
- NoMatchingColorThemesFound: 'No matching color themes found',
1347
- NoMatchingResults: 'No matching results',
1348
- NoRecentlyOpenedFoldersFound: 'No recently opened folders found',
1349
- NoResults: 'No Results',
1350
- NoSymbolFound: 'No symbol found',
1351
- NoWorkspaceSymbolsFound: 'no workspace symbols found',
1352
- OpenRecent: 'Open Recent',
1353
- SelectColorTheme: 'Select Color Theme',
1354
- SelectToOpen: 'Select to open',
1355
- ShowAndRunCommands: 'Show And Run Commands',
1356
- TypeNameOfCommandToRun: 'Type the name of a command to run.',
1357
- TypeTheNameOfAViewToOpen: 'Type the name of a view, output channel or terminal to open.'
1358
- };
1359
- const noMatchingColorThemesFound = () => {
1360
- return i18nString(UiStrings.NoMatchingColorThemesFound);
1361
- };
1362
- const selectColorTheme = () => {
1363
- return i18nString(UiStrings.SelectColorTheme);
1364
- };
1365
- const typeNameofCommandToRun = () => {
1366
- return i18nString(UiStrings.TypeNameOfCommandToRun);
1367
- };
1368
- const showAndRunCommands = () => {
1369
- return i18nString(UiStrings.ShowAndRunCommands);
1370
- };
1371
- const noMatchingResults = () => {
1372
- return i18nString(UiStrings.NoMatchingResults);
1373
- };
1374
- const files = () => {
1375
- return i18nString(UiStrings.Files);
1376
- };
1377
- const goToFile = () => {
1378
- return i18nString(UiStrings.GoToFile);
1379
- };
1380
- const noResults = () => {
1381
- return i18nString(UiStrings.NoResults);
1382
- };
1383
- const selectToOpen = () => {
1384
- return i18nString(UiStrings.SelectToOpen);
1385
- };
1386
- const openRecent = () => {
1387
- return i18nString(UiStrings.OpenRecent);
1388
- };
1389
- const noRecentlyOpenedFoldersFound = () => {
1390
- return i18nString(UiStrings.NoRecentlyOpenedFoldersFound);
1391
- };
1392
- const noSymbolFound = () => {
1393
- return i18nString(UiStrings.NoSymbolFound);
1394
- };
1395
- const noWorkspaceSymbolsFound = () => {
1396
- return i18nString(UiStrings.NoWorkspaceSymbolsFound);
1397
- };
1398
-
1399
- const state$4 = {
1400
- rpc: undefined
1401
- };
1402
- const invoke$1 = (method, ...params) => {
1403
- const rpc = state$4.rpc;
1404
- // @ts-ignore
1405
- return rpc.invoke(method, ...params);
1406
- };
1407
- const setRpc = rpc => {
1408
- state$4.rpc = rpc;
1409
- };
1410
-
1411
- // TODO this should be in FileSystem module
1412
- const pathBaseName = path => {
1413
- return path.slice(path.lastIndexOf('/') + 1);
1414
- };
1415
-
1416
- // TODO this should be in FileSystem module
1417
- const pathDirName = path => {
1418
- const pathSeparator = '/';
1419
- const index = path.lastIndexOf(pathSeparator);
1420
- if (index === -1) {
1421
- return '';
1422
- }
1423
- return path.slice(0, index);
1424
- };
1425
-
1426
- const getRecentlyOpened = () => {
1427
- return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1428
- };
1429
- const openWorkspaceFolder = uri => {
1430
- return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
1431
- };
1432
- const getPlaceholder$b = () => {
1433
- return selectToOpen();
1434
- };
1435
- const getLabel$5 = () => {
1436
- return openRecent();
1437
- };
1438
- const getHelpEntries$9 = () => {
1439
- return [];
1440
- };
1441
- const getNoResults$a = () => {
1442
- return {
1443
- label: noRecentlyOpenedFoldersFound()
1444
- };
1445
- };
1446
-
1447
- // TODO could also change api so that getPicks returns an array of anything
1448
- // and the transformPick gets the label for each pick
1449
- // This would make the code more module since the code for getting the picks
1450
- // would be more independent of the specific data format of the quickpick provider
1451
-
1452
- const getPicks$b = async () => {
1453
- const recentlyOpened = await getRecentlyOpened();
1454
- return recentlyOpened;
1455
- };
1456
-
1457
- // TODO selectPick should be independent of show/hide
1458
- const selectPick$b = async pick => {
1459
- const path = pick;
1460
- await openWorkspaceFolder(path);
1461
- return {
1462
- command: Hide
1463
- };
1464
- };
1465
- const getFilterValue$a = value => {
1466
- return pathBaseName(value);
1467
- };
1468
- const getPickFilterValue$6 = pick => {
1469
- return pathBaseName(pick);
1470
- };
1471
- const getPickLabel$5 = pick => {
1472
- return pathBaseName(pick);
1473
- };
1474
- const getPickDescription$3 = pick => {
1475
- return pathDirName(pick);
1476
- };
1477
- const getPickIcon$5 = () => {
1478
- return '';
1479
- };
1480
- const getPickFileIcon$2 = () => {
1481
- return getFolderIcon();
1482
- };
1483
-
1484
- const QuickPickEntriesOpenRecent = {
1485
- __proto__: null,
1486
- getFilterValue: getFilterValue$a,
1487
- getHelpEntries: getHelpEntries$9,
1488
- getLabel: getLabel$5,
1489
- getNoResults: getNoResults$a,
1490
- getPickDescription: getPickDescription$3,
1491
- getPickFileIcon: getPickFileIcon$2,
1492
- getPickFilterValue: getPickFilterValue$6,
1493
- getPickIcon: getPickIcon$5,
1494
- getPickLabel: getPickLabel$5,
1495
- getPicks: getPicks$b,
1496
- getPlaceholder: getPlaceholder$b,
1497
- selectPick: selectPick$b
1498
- };
1499
-
1500
- const CommandPalette = 'quickPick://commandPalette';
1501
- const File$1 = 'quickPick://file';
1502
- const EveryThing = 'quickPick://everything';
1503
- const Number$1 = 'quickPick://number';
1504
- const Recent = 'quickPick://recent';
1505
- const ColorTheme = 'quickPick://color-theme';
1506
- const Symbol$2 = 'quickPick://symbol';
1507
- const View$1 = 'quickPick://view';
1508
- const WorkspaceSymbol$1 = 'quickPick://workspace-symbol';
1509
- const Custom = 'quickPick://custom';
1510
-
1511
- const loadQuickPickEntries = moduleId => {
1512
- switch (moduleId) {
1513
- case Recent:
1514
- return QuickPickEntriesOpenRecent;
1515
- default:
1516
- throw new Error(`unknown module "${moduleId}"`);
1517
- }
1518
- };
1519
-
1520
- const getColorThemeNames = async () => {
1521
- return invoke$1(/* Ajax.getJson */'ColorTheme.getColorThemeNames');
1522
- };
1523
-
1524
- const setColorTheme = id => {
1525
- return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1526
- };
1527
- const getPlaceholder$a = () => {
1528
- return selectColorTheme();
1529
- };
1530
- const getLabel$4 = () => {
1531
- return selectColorTheme();
1532
- };
1533
- const getPicks$a = async searchValue => {
1534
- const colorThemeNames = await getColorThemeNames();
1535
- return colorThemeNames;
1536
- };
1537
- const selectPick$a = async pick => {
1538
- await setColorTheme(/* colorThemeId */pick);
1539
- return {
1540
- command: Hide
1541
- };
1542
- };
1543
- const focusPick = async pick => {
1544
- await setColorTheme(/* colorThemeId */pick);
1545
- };
1546
- const getFilterValue$9 = value => {
1547
- return value;
1548
- };
1549
- const getNoResults$9 = () => {
1550
- return {
1551
- label: noMatchingColorThemesFound()
1552
- };
1553
- };
1554
- const getPickFilterValue$5 = pick => {
1555
- return pick;
1556
- };
1557
- const getPickLabel$4 = pick => {
1558
- return pick;
1559
- };
1560
- const getPickIcon$4 = pick => {
1561
- return '';
1562
- };
1563
-
1564
- const QuickPickEntriesColorTheme = {
1565
- __proto__: null,
1566
- focusPick,
1567
- getFilterValue: getFilterValue$9,
1568
- getLabel: getLabel$4,
1569
- getNoResults: getNoResults$9,
1570
- getPickFilterValue: getPickFilterValue$5,
1571
- getPickIcon: getPickIcon$4,
1572
- getPickLabel: getPickLabel$4,
1573
- getPicks: getPicks$a,
1574
- getPlaceholder: getPlaceholder$a,
1575
- selectPick: selectPick$a,
1576
- setColorTheme
1577
- };
1578
-
1579
- const Tag$1 = 'Tag';
1580
- const Cloud$1 = 'Cloud';
1581
- const SourceControl$1 = 'SourceControl';
1582
- const None$1 = '';
1583
-
1584
- const SourceControl = 1;
1585
- const Cloud = 2;
1586
- const Tag = 3;
1587
-
1588
- const name$8 = 'custom';
1589
- const state$3 = {
1590
- args: []
1591
- };
1592
- const setArgs = args => {
1593
- state$3.args = args;
1594
- };
1595
- const getPlaceholder$9 = () => {
1596
- return '';
1597
- };
1598
- const getLabel$3 = () => {
1599
- return 'Custom';
1600
- };
1601
-
1602
- // TODO help entries should not be here
1603
- const getHelpEntries$8 = () => {
1604
- return [];
1605
- };
1606
- const getNoResults$8 = () => {
1607
- return {
1608
- label: noMatchingResults()
1609
- };
1610
- };
1611
- const getPicks$9 = async searchValue => {
1612
- const items = state$3.args[1] || [];
1613
- return items;
1614
- };
1615
- const selectPick$9 = async pick => {
1616
- const {
1617
- args
1618
- } = state$3;
1619
- const resolve = args[2];
1620
- resolve(pick);
1621
- return {
1622
- command: Hide
1623
- };
1624
- };
1625
- const getFilterValue$8 = value => {
1626
- return value;
1627
- };
1628
- const getPickFilterValue$4 = pick => {
1629
- return pick;
1630
- };
1631
- const getPickLabel$3 = pick => {
1632
- return pick.label;
1633
- };
1634
- const getPickDescription$2 = pick => {
1635
- return pick.description || '';
1636
- };
1637
- const convertIcon = icon => {
1638
- switch (icon) {
1639
- case SourceControl:
1640
- return SourceControl$1;
1641
- case Cloud:
1642
- return Cloud$1;
1643
- case Tag:
1644
- return Tag$1;
1645
- default:
1646
- return None$1;
1647
- }
1648
- };
1649
- const getPickIcon$3 = pick => {
1650
- return convertIcon(pick.icon);
1651
- };
1652
-
1653
- const QuickPickEntriesCustom = {
1654
- __proto__: null,
1655
- getFilterValue: getFilterValue$8,
1656
- getHelpEntries: getHelpEntries$8,
1657
- getLabel: getLabel$3,
1658
- getNoResults: getNoResults$8,
1659
- getPickDescription: getPickDescription$2,
1660
- getPickFilterValue: getPickFilterValue$4,
1661
- getPickIcon: getPickIcon$3,
1662
- getPickLabel: getPickLabel$3,
1663
- getPicks: getPicks$9,
1664
- getPlaceholder: getPlaceholder$9,
1665
- name: name$8,
1666
- selectPick: selectPick$9,
1667
- setArgs,
1668
- state: state$3
1669
- };
1670
-
1671
- const handleError = async (error, notify = true, prefix = '') => {
1672
- console.error(error);
1673
- };
1674
- const showErrorDialog = async () => {};
1675
- const warn = (...args) => {
1676
- console.warn(...args);
1677
- };
1678
-
1679
- const state$2 = {
1680
- menuEntries: []
1681
- };
1682
- const getAll = () => {
1683
- return state$2.menuEntries;
1684
- };
1685
-
1686
- const name$7 = 'command';
1687
- const getPlaceholder$8 = () => {
1688
- return typeNameofCommandToRun();
1689
- };
1690
- const helpEntries = () => {
1691
- return [{
1692
- description: showAndRunCommands(),
1693
- category: 'global commands'
1694
- }];
1695
- };
1696
- const getLabel$2 = () => {
1697
- return '';
1698
- };
1699
- const getNoResults$7 = () => {
1700
- return {
1701
- label: noMatchingResults()
1702
- };
1703
- };
1704
-
1705
- // TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
1706
- const getBuiltinPicks = async () => {
1707
- const builtinPicks = getAll();
1708
- return builtinPicks;
1709
- };
1710
- const prefixIdWithExt = item => {
1711
- if (!item.label) {
1712
- warn('[QuickPick] item has missing label', item);
1713
- }
1714
- if (!item.id) {
1715
- warn('[QuickPick] item has missing id', item);
1716
- }
1717
- return {
1718
- ...item,
1719
- id: `ext.${item.id}`,
1720
- label: item.label || item.id
1721
- };
1722
- };
1723
- const getExtensionPicks = async () => {
1724
- try {
1725
- // TODO don't call this every time
1726
- const extensionPicks = await invoke$1('ExtensionHostCommands.getCommands');
1727
- if (!extensionPicks) {
1728
- return [];
1729
- }
1730
- const mappedPicks = extensionPicks.map(prefixIdWithExt);
1731
- return mappedPicks;
1732
- } catch (error) {
1733
- console.error(`Failed to get extension picks: ${error}`);
1734
- return [];
1735
- }
1736
- };
1737
-
1738
- // TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
1739
-
1740
- const getPicks$8 = async () => {
1741
- const builtinPicks = await getBuiltinPicks();
1742
- const extensionPicks = await getExtensionPicks();
1743
- return [...builtinPicks, ...extensionPicks];
1744
- };
1745
- const shouldHide = item => {
1746
- if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
1747
- return false;
1748
- }
1749
- return true;
1750
- };
1751
- const selectPickBuiltin = async item => {
1752
- const args = item.args || [];
1753
- // TODO ids should be all numbers for efficiency -> also directly can call command
1754
- await invoke$1(item.id, ...args);
1755
- if (shouldHide(item)) {
1756
- return {
1757
- command: Hide
1758
- };
1759
- }
1760
- return {
1761
- command: KeepOpen
1762
- };
1763
- };
1764
- const selectPickExtension = async item => {
1765
- const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
1766
- try {
1767
- await invoke$1('ExtensionHostCommands.executeCommand', id);
1768
- } catch (error) {
1769
- await handleError(error, false);
1770
- // @ts-ignore
1771
- await showErrorDialog();
1772
- }
1773
- return {
1774
- command: Hide
1775
- };
1776
- };
1777
- const selectPick$8 = async item => {
1778
- if (item.id.startsWith('ext.')) {
1779
- return selectPickExtension(item);
1780
- }
1781
- return selectPickBuiltin(item);
1782
- };
1783
- const getFilterValue$7 = value => {
1784
- return value;
1785
- };
1786
- const getPickFilterValue$3 = pick => {
1787
- return pick.label;
1788
- };
1789
- const getPickLabel$2 = pick => {
1790
- return pick.label;
1791
- };
1792
- const getPickIcon$2 = () => {
1793
- return '';
1794
- };
1795
-
1796
- const QuickPickEntriesCommand = {
1797
- __proto__: null,
1798
- getFilterValue: getFilterValue$7,
1799
- getLabel: getLabel$2,
1800
- getNoResults: getNoResults$7,
1801
- getPickFilterValue: getPickFilterValue$3,
1802
- getPickIcon: getPickIcon$2,
1803
- getPickLabel: getPickLabel$2,
1804
- getPicks: getPicks$8,
1805
- getPlaceholder: getPlaceholder$8,
1806
- helpEntries,
1807
- name: name$7,
1808
- selectPick: selectPick$8
1809
- };
1810
-
1811
- const execute = async (method, ...params) => {
1812
- // TODO
1813
- };
1814
-
1815
- const RE_PROTOCOL = /^([a-z-]+):\/\//;
1816
- const getProtocol = uri => {
1817
- const protocolMatch = uri.match(RE_PROTOCOL);
1818
- if (protocolMatch) {
1819
- return protocolMatch[1];
1299
+ const getJson = async url => {
1300
+ try {
1301
+ const response = await fetch(url);
1302
+ if (!response.ok) {
1303
+ throw new Error(response.statusText);
1304
+ }
1305
+ const text = await response.json();
1306
+ return text;
1307
+ } catch (error) {
1308
+ throw new VError(error, `Failed to request json for ${url}`);
1820
1309
  }
1821
- return '';
1822
- };
1823
-
1824
- const Memfs = 'memfs';
1825
- const Html = 'html';
1826
- const Fetch = 'fetch';
1827
-
1828
- const searchFile$4 = async () => {
1829
- const files = await getFiles();
1830
- const keys = Object.keys(files);
1831
- return keys;
1832
- };
1833
-
1834
- const SearchFileMemfs = {
1835
- __proto__: null,
1836
- searchFile: searchFile$4
1837
1310
  };
1838
1311
 
1839
1312
  const removeLeadingSlash = path => {
@@ -1863,7 +1336,7 @@ const SearchFileFetch = {
1863
1336
  };
1864
1337
 
1865
1338
  const Directory = 'directory';
1866
- const File = 'file';
1339
+ const File$1 = 'file';
1867
1340
 
1868
1341
  // based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
1869
1342
 
@@ -1882,7 +1355,6 @@ const fromAsync = async asyncIterable => {
1882
1355
  *
1883
1356
  */
1884
1357
 
1885
- // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1886
1358
  const getChildHandles = async handle => {
1887
1359
  // @ts-ignore
1888
1360
  const handles = await fromAsync(handle.values());
@@ -2143,7 +1615,7 @@ replaceTraps(oldTraps => ({
2143
1615
  }
2144
1616
  }));
2145
1617
 
2146
- const state$1 = {
1618
+ const state$2 = {
2147
1619
  databases: Object.create(null),
2148
1620
  eventId: 0,
2149
1621
  dbVersion: 1,
@@ -2154,78 +1626,268 @@ const state$1 = {
2154
1626
 
2155
1627
  const getHandleDb = async () => {
2156
1628
  // @ts-ignore
2157
- const db = await openDB('handle', state$1.dbVersion, {
1629
+ const db = await openDB('handle', state$2.dbVersion, {
2158
1630
  async upgrade(db) {
2159
1631
  if (!db.objectStoreNames.contains('file-handles-store')) {
2160
1632
  await db.createObjectStore('file-handles-store', {});
2161
1633
  }
2162
1634
  }
2163
- });
2164
- return db;
1635
+ });
1636
+ return db;
1637
+ };
1638
+ const getHandle$1 = async uri => {
1639
+ const handleDb = await getHandleDb();
1640
+ const handle = await handleDb.get('file-handles-store', uri);
1641
+ return handle;
1642
+ };
1643
+
1644
+ const getHandle = async uri => {
1645
+ try {
1646
+ // TODO retrieve handle from state or from indexeddb
1647
+ // TODO if not found, throw error
1648
+ const handle = await getHandle$1(uri);
1649
+ return handle;
1650
+ } catch (error) {
1651
+ throw new VError(error, 'Failed to get handle');
1652
+ }
1653
+ };
1654
+
1655
+ const getDirectoryHandle = async uri => {
1656
+ const handle = await getHandle(uri);
1657
+ if (handle) {
1658
+ return handle;
1659
+ }
1660
+ const dirname$1 = dirname('/', uri);
1661
+ if (uri === dirname$1) {
1662
+ return undefined;
1663
+ }
1664
+ return getDirectoryHandle(dirname$1);
1665
+ };
1666
+ const toIgnore = ['.git', 'node_modules', 'dist', 'dist2'];
1667
+ const searchFilesRecursively = async (all, parent, handle) => {
1668
+ const childHandles = await getChildHandles(handle);
1669
+ const promises = [];
1670
+ for (const childHandle of childHandles) {
1671
+ if (toIgnore.includes(childHandle.name)) {
1672
+ continue;
1673
+ }
1674
+ const absolutePath = parent + '/' + childHandle.name;
1675
+ switch (childHandle.kind) {
1676
+ case Directory:
1677
+ promises.push(searchFilesRecursively(all, absolutePath, childHandle));
1678
+ break;
1679
+ case File$1:
1680
+ all.push(absolutePath);
1681
+ break;
1682
+ }
1683
+ }
1684
+ await Promise.all(promises);
1685
+ };
1686
+ const searchFile$2 = async uri => {
1687
+ const path = uri.slice('html://'.length);
1688
+ const handle = await getDirectoryHandle(path);
1689
+ if (!handle) {
1690
+ // @ts-ignore
1691
+ throw new VError(`Folder not found ${uri}`);
1692
+ }
1693
+ const all = [];
1694
+ await searchFilesRecursively(all, '', handle);
1695
+ return all;
1696
+ };
1697
+
1698
+ const SearchFileHtml = {
1699
+ __proto__: null,
1700
+ searchFile: searchFile$2
1701
+ };
1702
+
1703
+ const emptyMatches = [];
1704
+
1705
+ const convertToPick = item => {
1706
+ return {
1707
+ pick: item,
1708
+ matches: emptyMatches
1709
+ };
1710
+ };
1711
+
1712
+ const Diagonal = 1;
1713
+ const Left = 2;
1714
+
1715
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1716
+
1717
+ const createTable = size => {
1718
+ const table = [];
1719
+ for (let i = 0; i < size; i++) {
1720
+ const row = new Uint8Array(size);
1721
+ table.push(row);
1722
+ }
1723
+ return table;
1724
+ };
1725
+ const EmptyMatches = [];
1726
+ const Dash = '-';
1727
+ const Dot = '.';
1728
+ const EmptyString = '';
1729
+ const Space = ' ';
1730
+ const Underline = '_';
1731
+ const T = 't';
1732
+ const isLowerCase = char => {
1733
+ return char === char.toLowerCase();
1734
+ };
1735
+ const isUpperCase = char => {
1736
+ return char === char.toUpperCase();
1737
+ };
1738
+
1739
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1740
+ const isGap = (columnCharBefore, columnChar) => {
1741
+ switch (columnCharBefore) {
1742
+ case Dash:
1743
+ case Underline:
1744
+ case EmptyString:
1745
+ case T:
1746
+ case Space:
1747
+ case Dot:
1748
+ return true;
1749
+ }
1750
+ if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
1751
+ return true;
1752
+ }
1753
+ return false;
1754
+ };
1755
+
1756
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1757
+ const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
1758
+ if (rowCharLow !== columnCharLow) {
1759
+ return -1;
1760
+ }
1761
+ const isMatch = rowChar === columnChar;
1762
+ if (isMatch) {
1763
+ if (isDiagonalMatch) {
1764
+ return 8;
1765
+ }
1766
+ if (isGap(columnCharBefore, columnChar)) {
1767
+ return 8;
1768
+ }
1769
+ return 5;
1770
+ }
1771
+ if (isGap(columnCharBefore, columnChar)) {
1772
+ return 8;
1773
+ }
1774
+ return 5;
1775
+ };
1776
+
1777
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1778
+
1779
+ const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
1780
+ while (patternPos < patternLen && wordPos < wordLen) {
1781
+ if (patternLow[patternPos] === wordLow[wordPos]) {
1782
+ patternPos += 1;
1783
+ }
1784
+ wordPos += 1;
1785
+ }
1786
+ return patternPos === patternLen; // pattern must be exhausted
1787
+ };
1788
+
1789
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1790
+ const traceHighlights = (table, arrows, patternLength, wordLength) => {
1791
+ let row = patternLength;
1792
+ let column = wordLength;
1793
+ const matches = [];
1794
+ while (row >= 1 && column >= 1) {
1795
+ const arrow = arrows[row][column];
1796
+ if (arrow === Left) {
1797
+ column--;
1798
+ } else if (arrow === Diagonal) {
1799
+ row--;
1800
+ column--;
1801
+ const start = column + 1;
1802
+ while (row >= 1 && column >= 1) {
1803
+ const arrow = arrows[row][column];
1804
+ if (arrow === Left) {
1805
+ break;
1806
+ }
1807
+ if (arrow === Diagonal) {
1808
+ row--;
1809
+ column--;
1810
+ }
1811
+ }
1812
+ const end = column;
1813
+ matches.unshift(end, start);
1814
+ }
1815
+ }
1816
+ matches.unshift(table[patternLength][wordLength - 1]);
1817
+ return matches;
1818
+ };
1819
+
1820
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1821
+ const gridSize = 128;
1822
+ const table = createTable(gridSize);
1823
+ const arrows = createTable(gridSize);
1824
+ const fuzzySearch = (pattern, word) => {
1825
+ const patternLength = Math.min(pattern.length, gridSize - 1);
1826
+ const wordLength = Math.min(word.length, gridSize - 1);
1827
+ const patternLower = pattern.toLowerCase();
1828
+ const wordLower = word.toLowerCase();
1829
+ if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
1830
+ return EmptyMatches;
1831
+ }
1832
+ let strongMatch = false;
1833
+ for (let row = 1; row < patternLength + 1; row++) {
1834
+ const rowChar = pattern[row - 1];
1835
+ const rowCharLow = patternLower[row - 1];
1836
+ for (let column = 1; column < wordLength + 1; column++) {
1837
+ const columnChar = word[column - 1];
1838
+ const columnCharLow = wordLower[column - 1];
1839
+ const columnCharBefore = word[column - 2] || '';
1840
+ const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
1841
+ const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
1842
+ if (row === 1 && score > 5) {
1843
+ strongMatch = true;
1844
+ }
1845
+ let diagonalScore = score + table[row - 1][column - 1];
1846
+ if (isDiagonalMatch && score !== -1) {
1847
+ diagonalScore += 2;
1848
+ }
1849
+ const leftScore = table[row][column - 1];
1850
+ if (leftScore > diagonalScore) {
1851
+ table[row][column] = leftScore;
1852
+ arrows[row][column] = Left;
1853
+ } else {
1854
+ table[row][column] = diagonalScore;
1855
+ arrows[row][column] = Diagonal;
1856
+ }
1857
+ }
1858
+ }
1859
+ if (!strongMatch) {
1860
+ return EmptyMatches;
1861
+ }
1862
+ const highlights = traceHighlights(table, arrows, patternLength, wordLength);
1863
+ return highlights;
2165
1864
  };
2166
- const getHandle$1 = async uri => {
2167
- const handleDb = await getHandleDb();
2168
- const handle = await handleDb.get('file-handles-store', uri);
2169
- return handle;
1865
+
1866
+ const filterQuickPickItem = (pattern, word) => {
1867
+ const matches = fuzzySearch(pattern, word);
1868
+ return matches;
2170
1869
  };
2171
1870
 
2172
- const getHandle = async uri => {
2173
- try {
2174
- // TODO retrieve handle from state or from indexeddb
2175
- // TODO if not found, throw error
2176
- const handle = await getHandle$1(uri);
2177
- return handle;
2178
- } catch (error) {
2179
- throw new VError(error, 'Failed to get handle');
2180
- }
1871
+ const getBaseName = path => {
1872
+ return path.slice(path.lastIndexOf('/') + 1);
2181
1873
  };
2182
1874
 
2183
- const getDirectoryHandle = async uri => {
2184
- const handle = await getHandle(uri);
2185
- if (handle) {
2186
- return handle;
2187
- }
2188
- const dirname$1 = dirname('/', uri);
2189
- if (uri === dirname$1) {
2190
- return undefined;
1875
+ const filterQuickPickItems = (items, value) => {
1876
+ if (!value) {
1877
+ return items.map(convertToPick);
2191
1878
  }
2192
- return getDirectoryHandle(dirname$1);
2193
- };
2194
- const toIgnore = ['.git', 'node_modules', 'dist', 'dist2'];
2195
- const searchFilesRecursively = async (all, parent, handle) => {
2196
- const childHandles = await getChildHandles(handle);
2197
- const promises = [];
2198
- for (const childHandle of childHandles) {
2199
- if (toIgnore.includes(childHandle.name)) {
2200
- continue;
2201
- }
2202
- const absolutePath = parent + '/' + childHandle.name;
2203
- switch (childHandle.kind) {
2204
- case Directory:
2205
- promises.push(searchFilesRecursively(all, absolutePath, childHandle));
2206
- break;
2207
- case File:
2208
- all.push(absolutePath);
2209
- break;
1879
+ const results = [];
1880
+ for (const item of items) {
1881
+ const baseName = getBaseName(item);
1882
+ const matches = filterQuickPickItem(value, baseName);
1883
+ if (matches.length > 0) {
1884
+ results.push({
1885
+ pick: item,
1886
+ matches
1887
+ });
2210
1888
  }
2211
1889
  }
2212
- await Promise.all(promises);
2213
- };
2214
- const searchFile$2 = async uri => {
2215
- const path = uri.slice('html://'.length);
2216
- const handle = await getDirectoryHandle(path);
2217
- if (!handle) {
2218
- // @ts-ignore
2219
- throw new VError(`Folder not found ${uri}`);
2220
- }
2221
- const all = [];
2222
- await searchFilesRecursively(all, '', handle);
2223
- return all;
2224
- };
2225
-
2226
- const SearchFileHtml = {
2227
- __proto__: null,
2228
- searchFile: searchFile$2
1890
+ return results;
2229
1891
  };
2230
1892
 
2231
1893
  const getFileSearchRipGrepArgs = () => {
@@ -2287,32 +1949,47 @@ const searchFile = async (path, value, prepare, assetDir) => {
2287
1949
  return result;
2288
1950
  };
2289
1951
 
2290
- const name$6 = 'file';
2291
- const getPlaceholder$7 = () => {
1952
+ // TODO this should be in FileSystem module
1953
+ const pathBaseName = path => {
1954
+ return path.slice(path.lastIndexOf('/') + 1);
1955
+ };
1956
+
1957
+ // TODO this should be in FileSystem module
1958
+ const pathDirName = path => {
1959
+ const pathSeparator = '/';
1960
+ const index = path.lastIndexOf(pathSeparator);
1961
+ if (index === -1) {
1962
+ return '';
1963
+ }
1964
+ return path.slice(0, index);
1965
+ };
1966
+
1967
+ const name$7 = 'file';
1968
+ const getPlaceholder$a = () => {
2292
1969
  return '';
2293
1970
  };
2294
- const getLabel$1 = () => {
1971
+ const getLabel$4 = () => {
2295
1972
  return files();
2296
1973
  };
2297
1974
 
2298
1975
  // TODO help entries should not be here
2299
- const getHelpEntries$7 = () => {
1976
+ const getHelpEntries$9 = () => {
2300
1977
  return [{
2301
1978
  description: goToFile(),
2302
1979
  category: 'global commands'
2303
1980
  }];
2304
1981
  };
2305
- const getNoResults$6 = () => {
1982
+ const getNoResults$9 = () => {
2306
1983
  return {
2307
1984
  label: noMatchingResults()
2308
1985
  };
2309
1986
  };
2310
- const getPicks$7 = async searchValue => {
1987
+ const getPicks$a = async searchValue => {
2311
1988
  {
2312
1989
  return [];
2313
1990
  }
2314
1991
  };
2315
- const selectPick$7 = async pick => {
1992
+ const selectPick$a = async pick => {
2316
1993
  if (typeof pick === 'object') {
2317
1994
  pick = pick.pick;
2318
1995
  }
@@ -2323,125 +2000,234 @@ const selectPick$7 = async pick => {
2323
2000
  command: Hide
2324
2001
  };
2325
2002
  };
2003
+ const getFilterValue$9 = value => {
2004
+ return value;
2005
+ };
2006
+ const getPickFilterValue$5 = pick => {
2007
+ if (typeof pick === 'object') {
2008
+ pick = pick.pick;
2009
+ }
2010
+ return pick;
2011
+ };
2012
+ const getPickLabel$4 = pick => {
2013
+ if (typeof pick === 'object') {
2014
+ pick = pick.pick;
2015
+ }
2016
+ const baseName = pathBaseName(pick);
2017
+ return baseName;
2018
+ };
2019
+ const getPickDescription$3 = pick => {
2020
+ if (typeof pick === 'object') {
2021
+ pick = pick.pick;
2022
+ }
2023
+ const dirName = pathDirName(pick);
2024
+ return dirName;
2025
+ };
2026
+ const getPickIcon$4 = () => {
2027
+ return '';
2028
+ };
2029
+ const getPickFileIcon$2 = pick => {
2030
+ return '';
2031
+ };
2032
+ const isPrepared$1 = () => {
2033
+ const workspace = '';
2034
+ // TODO protocol should always be defined. For files it should use file protocol
2035
+ const protocol = getProtocol(workspace);
2036
+ return !protocol;
2037
+ };
2038
+
2039
+ const QuickPickEntriesFile = {
2040
+ __proto__: null,
2041
+ getFilterValue: getFilterValue$9,
2042
+ getHelpEntries: getHelpEntries$9,
2043
+ getLabel: getLabel$4,
2044
+ getNoResults: getNoResults$9,
2045
+ getPickDescription: getPickDescription$3,
2046
+ getPickFileIcon: getPickFileIcon$2,
2047
+ getPickFilterValue: getPickFilterValue$5,
2048
+ getPickIcon: getPickIcon$4,
2049
+ getPickLabel: getPickLabel$4,
2050
+ getPicks: getPicks$a,
2051
+ getPlaceholder: getPlaceholder$a,
2052
+ isPrepared: isPrepared$1,
2053
+ name: name$7,
2054
+ selectPick: selectPick$a
2055
+ };
2056
+
2057
+ const name$6 = 'goToLine';
2058
+ const getPlaceholder$9 = () => {
2059
+ return '';
2060
+ };
2061
+ const getHelpEntries$8 = () => {
2062
+ return [];
2063
+ };
2064
+ const getNoResults$8 = () => {
2065
+ return undefined;
2066
+ };
2067
+ const getPicks$9 = async () => {
2068
+ const picks = [{
2069
+ label: '1'
2070
+ }, {
2071
+ label: '2'
2072
+ }, {
2073
+ label: '3'
2074
+ }, {
2075
+ label: '4'
2076
+ }, {
2077
+ label: '5'
2078
+ }, {
2079
+ label: '6'
2080
+ }];
2081
+ return picks;
2082
+ };
2083
+ const selectPick$9 = async item => {
2084
+ const rowIndex = Number.parseInt(item.label);
2085
+ const position = {
2086
+ rowIndex,
2087
+ columnIndex: 5
2088
+ };
2089
+ await execute(/* EditorSetCursor.editorSetCursor */'TODO', /* position */position);
2090
+ // TODO put cursor onto that line
2091
+ return {
2092
+ command: Hide
2093
+ };
2094
+ };
2095
+ const getFilterValue$8 = value => {
2096
+ return value;
2097
+ };
2098
+
2099
+ const QuickPickEntriesGoToLine = {
2100
+ __proto__: null,
2101
+ getFilterValue: getFilterValue$8,
2102
+ getHelpEntries: getHelpEntries$8,
2103
+ getNoResults: getNoResults$8,
2104
+ getPicks: getPicks$9,
2105
+ getPlaceholder: getPlaceholder$9,
2106
+ name: name$6,
2107
+ selectPick: selectPick$9
2108
+ };
2109
+
2110
+ const name$5 = 'noop';
2111
+ const getPlaceholder$8 = () => {
2112
+ return '';
2113
+ };
2114
+ const getHelpEntries$7 = () => {
2115
+ return [];
2116
+ };
2117
+ const getNoResults$7 = () => {
2118
+ return noResults();
2119
+ };
2120
+ const getPicks$8 = async value => {
2121
+ return [];
2122
+ };
2123
+ const selectPick$8 = async item => {
2124
+ return {
2125
+ command: Hide
2126
+ };
2127
+ };
2128
+ const getFilterValue$7 = value => {
2129
+ return value;
2130
+ };
2131
+ const getPickFilterValue$4 = pick => {
2132
+ return pick;
2133
+ };
2134
+
2135
+ const QuickPickNoop = {
2136
+ __proto__: null,
2137
+ getFilterValue: getFilterValue$7,
2138
+ getHelpEntries: getHelpEntries$7,
2139
+ getNoResults: getNoResults$7,
2140
+ getPickFilterValue: getPickFilterValue$4,
2141
+ getPicks: getPicks$8,
2142
+ getPlaceholder: getPlaceholder$8,
2143
+ name: name$5,
2144
+ selectPick: selectPick$8
2145
+ };
2146
+
2147
+ const name$4 = 'symbol';
2148
+ const getPlaceholder$7 = () => {
2149
+ return '';
2150
+ };
2151
+ const getHelpEntries$6 = () => {
2152
+ return [];
2153
+ };
2154
+ const getNoResults$6 = () => {
2155
+ return {
2156
+ label: noSymbolFound()
2157
+ };
2158
+ };
2159
+ const getPicks$7 = async () => {
2160
+ const picks = [];
2161
+ return picks;
2162
+ };
2163
+ const selectPick$7 = async item => {
2164
+ return {
2165
+ command: Hide
2166
+ };
2167
+ };
2326
2168
  const getFilterValue$6 = value => {
2327
2169
  return value;
2328
2170
  };
2329
- const getPickFilterValue$2 = pick => {
2330
- if (typeof pick === 'object') {
2331
- pick = pick.pick;
2332
- }
2333
- return pick;
2334
- };
2335
- const getPickLabel$1 = pick => {
2336
- if (typeof pick === 'object') {
2337
- pick = pick.pick;
2338
- }
2339
- const baseName = pathBaseName(pick);
2340
- return baseName;
2341
- };
2342
- const getPickDescription$1 = pick => {
2343
- if (typeof pick === 'object') {
2344
- pick = pick.pick;
2345
- }
2346
- const dirName = pathDirName(pick);
2347
- return dirName;
2348
- };
2349
- const getPickIcon$1 = () => {
2350
- return '';
2351
- };
2352
- const getPickFileIcon$1 = pick => {
2353
- return '';
2354
- };
2355
- const isPrepared$1 = () => {
2356
- const workspace = '';
2357
- // TODO protocol should always be defined. For files it should use file protocol
2358
- const protocol = getProtocol(workspace);
2359
- return !protocol;
2360
- };
2361
2171
 
2362
- const QuickPickEntriesFile = {
2172
+ const QuickPickEntriesSymbol = {
2363
2173
  __proto__: null,
2364
2174
  getFilterValue: getFilterValue$6,
2365
- getHelpEntries: getHelpEntries$7,
2366
- getLabel: getLabel$1,
2175
+ getHelpEntries: getHelpEntries$6,
2367
2176
  getNoResults: getNoResults$6,
2368
- getPickDescription: getPickDescription$1,
2369
- getPickFileIcon: getPickFileIcon$1,
2370
- getPickFilterValue: getPickFilterValue$2,
2371
- getPickIcon: getPickIcon$1,
2372
- getPickLabel: getPickLabel$1,
2373
2177
  getPicks: getPicks$7,
2374
2178
  getPlaceholder: getPlaceholder$7,
2375
- isPrepared: isPrepared$1,
2376
- name: name$6,
2179
+ name: name$4,
2377
2180
  selectPick: selectPick$7
2378
2181
  };
2379
2182
 
2380
- const name$5 = 'goToLine';
2183
+ // TODO probably not needed
2184
+
2381
2185
  const getPlaceholder$6 = () => {
2382
- return '';
2383
- };
2384
- const getHelpEntries$6 = () => {
2385
- return [];
2186
+ return typeNameofCommandToRun();
2386
2187
  };
2387
- const getNoResults$5 = () => {
2188
+ const getHelpEntries$5 = () => {
2388
2189
  return undefined;
2389
2190
  };
2390
2191
  const getPicks$6 = async () => {
2391
- const picks = [{
2392
- label: '1'
2393
- }, {
2394
- label: '2'
2395
- }, {
2396
- label: '3'
2397
- }, {
2398
- label: '4'
2399
- }, {
2400
- label: '5'
2401
- }, {
2402
- label: '6'
2403
- }];
2404
- return picks;
2192
+ // const views = ViewService.getViews()
2193
+ // const picks = views.map(toPick)
2194
+ // return picks
2195
+ return [];
2405
2196
  };
2406
2197
  const selectPick$6 = async item => {
2407
- const rowIndex = Number.parseInt(item.label);
2408
- const position = {
2409
- rowIndex,
2410
- columnIndex: 5
2411
- };
2412
- await execute(/* EditorSetCursor.editorSetCursor */'TODO', /* position */position);
2413
- // TODO put cursor onto that line
2414
- return {
2415
- command: Hide
2416
- };
2198
+ // Command.execute(/* openView */ 549, /* viewName */ item.label)
2199
+ // return {
2200
+ // command: QuickPickReturnValue.Hide,
2201
+ // }
2417
2202
  };
2418
2203
  const getFilterValue$5 = value => {
2419
2204
  return value;
2420
2205
  };
2421
2206
 
2422
- const QuickPickEntriesGoToLine = {
2207
+ const QuickPickEntriesView = {
2423
2208
  __proto__: null,
2424
2209
  getFilterValue: getFilterValue$5,
2425
- getHelpEntries: getHelpEntries$6,
2426
- getNoResults: getNoResults$5,
2210
+ getHelpEntries: getHelpEntries$5,
2427
2211
  getPicks: getPicks$6,
2428
2212
  getPlaceholder: getPlaceholder$6,
2429
- name: name$5,
2430
2213
  selectPick: selectPick$6
2431
2214
  };
2432
2215
 
2433
- const name$4 = 'noop';
2216
+ const name$3 = 'workspace-symbol';
2434
2217
  const getPlaceholder$5 = () => {
2435
2218
  return '';
2436
2219
  };
2437
- const getHelpEntries$5 = () => {
2220
+ const getHelpEntries$4 = () => {
2438
2221
  return [];
2439
2222
  };
2440
- const getNoResults$4 = () => {
2441
- return noResults();
2223
+ const getNoResults$5 = () => {
2224
+ return {
2225
+ label: noWorkspaceSymbolsFound()
2226
+ };
2442
2227
  };
2443
- const getPicks$5 = async value => {
2444
- return [];
2228
+ const getPicks$5 = async () => {
2229
+ const picks = [];
2230
+ return picks;
2445
2231
  };
2446
2232
  const selectPick$5 = async item => {
2447
2233
  return {
@@ -2451,311 +2237,556 @@ const selectPick$5 = async item => {
2451
2237
  const getFilterValue$4 = value => {
2452
2238
  return value;
2453
2239
  };
2454
- const getPickFilterValue$1 = pick => {
2455
- return pick;
2456
- };
2457
2240
 
2458
- const QuickPickNoop = {
2241
+ const QuickPickEntriesWorkspaceSymbol = {
2459
2242
  __proto__: null,
2460
2243
  getFilterValue: getFilterValue$4,
2461
- getHelpEntries: getHelpEntries$5,
2462
- getNoResults: getNoResults$4,
2463
- getPickFilterValue: getPickFilterValue$1,
2244
+ getHelpEntries: getHelpEntries$4,
2245
+ getNoResults: getNoResults$5,
2464
2246
  getPicks: getPicks$5,
2465
2247
  getPlaceholder: getPlaceholder$5,
2466
- name: name$4,
2248
+ name: name$3,
2467
2249
  selectPick: selectPick$5
2468
2250
  };
2469
2251
 
2470
- const name$3 = 'symbol';
2252
+ const Command = '>';
2253
+ const Symbol$2 = '@';
2254
+ const WorkspaceSymbol$1 = '#';
2255
+ const GoToLine = ':';
2256
+ const View$1 = 'view ';
2257
+ const None$1 = '';
2258
+
2259
+ // TODO avoid global variable
2260
+
2261
+ const state$1 = {
2262
+ // providerId: PROVIDER_NOOP,
2263
+ provider: QuickPickNoop,
2264
+ prefix: 'string-that-should-never-match-another-string'
2265
+ };
2266
+
2267
+ /**
2268
+ * @type {string}
2269
+ */
2270
+ const name$2 = 'everything';
2471
2271
  const getPlaceholder$4 = () => {
2272
+ return state$1.provider.getPlaceholder();
2273
+ };
2274
+ const getLabel$3 = () => {
2472
2275
  return '';
2473
2276
  };
2474
- const getHelpEntries$4 = () => {
2475
- return [];
2277
+ const getHelpEntries$3 = () => {
2278
+ return state$1.provider.getHelpEntries();
2279
+ };
2280
+ const getNoResults$4 = () => {
2281
+ return state$1.provider.getNoResults();
2282
+ };
2283
+ const getPrefix = value => {
2284
+ if (value.startsWith(Command)) {
2285
+ return Command;
2286
+ }
2287
+ if (value.startsWith(Symbol$2)) {
2288
+ return Symbol$2;
2289
+ }
2290
+ if (value.startsWith(WorkspaceSymbol$1)) {
2291
+ return WorkspaceSymbol$1;
2292
+ }
2293
+ if (value.startsWith(GoToLine)) {
2294
+ return GoToLine;
2295
+ }
2296
+ if (value.startsWith(View$1)) {
2297
+ return View$1;
2298
+ }
2299
+ return None$1;
2300
+ };
2301
+ const getQuickPickProvider = prefix => {
2302
+ // TODO could use enum for prefix
2303
+ // TODO could use regex to extract prefix
2304
+ // TODO or could check first letter char code (less comparisons)
2305
+ switch (prefix) {
2306
+ case Command:
2307
+ return QuickPickEntriesCommand;
2308
+ case Symbol$2:
2309
+ return QuickPickEntriesSymbol;
2310
+ case WorkspaceSymbol$1:
2311
+ return QuickPickEntriesWorkspaceSymbol;
2312
+ case GoToLine:
2313
+ return QuickPickEntriesGoToLine;
2314
+ case View$1:
2315
+ return QuickPickEntriesView;
2316
+ default:
2317
+ return QuickPickEntriesFile;
2318
+ }
2319
+ };
2320
+ const getPicks$4 = async value => {
2321
+ const prefix = getPrefix(value);
2322
+ // TODO race condition
2323
+ if (state$1.prefix !== prefix) {
2324
+ state$1.prefix = prefix;
2325
+ // @ts-ignore
2326
+ state$1.provider = await getQuickPickProvider(prefix);
2327
+ }
2328
+ // TODO this line is a bit duplicated with getFilterValue
2329
+ const slicedValue = value.slice(prefix.length);
2330
+ const picks = await state$1.provider.getPicks(slicedValue);
2331
+ return picks;
2332
+ };
2333
+ const selectPick$4 = item => {
2334
+ const {
2335
+ provider
2336
+ } = state$1;
2337
+ return provider.selectPick(item);
2338
+ };
2339
+ const openCommandPalette = () => {
2340
+ // show('>')
2341
+ };
2342
+ const openView = () => {
2343
+ // show('view ')
2344
+ };
2345
+ const getFilterValue$3 = value => {
2346
+ return value.slice(state$1.prefix.length);
2347
+ };
2348
+ const getPickFilterValue$3 = pick => {
2349
+ const {
2350
+ provider
2351
+ } = state$1;
2352
+ return provider.getPickFilterValue(pick);
2353
+ };
2354
+ const getPickDescription$2 = pick => {
2355
+ const {
2356
+ provider
2357
+ } = state$1;
2358
+ // @ts-ignore
2359
+ if (provider.getPickDescription) {
2360
+ // @ts-ignore
2361
+ return provider.getPickDescription(pick);
2362
+ }
2363
+ return '';
2364
+ };
2365
+ const getPickLabel$3 = pick => {
2366
+ const {
2367
+ provider
2368
+ } = state$1;
2369
+ // @ts-ignore
2370
+ return provider.getPickLabel(pick);
2371
+ };
2372
+ const getPickIcon$3 = pick => {
2373
+ const {
2374
+ provider
2375
+ } = state$1;
2376
+ // @ts-ignore
2377
+ return provider.getPickIcon(pick);
2378
+ };
2379
+ const getPickFileIcon$1 = pick => {
2380
+ const {
2381
+ provider
2382
+ } = state$1;
2383
+ // @ts-ignore
2384
+ if (provider.getPickFileIcon) {
2385
+ // @ts-ignore
2386
+ return provider.getPickFileIcon(pick);
2387
+ }
2388
+ return '';
2389
+ };
2390
+ const isPrepared = () => {
2391
+ const {
2392
+ provider
2393
+ } = state$1;
2394
+ // @ts-ignore
2395
+ if (provider.isPrepared) {
2396
+ // @ts-ignore
2397
+ return provider.isPrepared();
2398
+ }
2399
+ return false;
2400
+ };
2401
+
2402
+ const QuickPickEntriesEverything = {
2403
+ __proto__: null,
2404
+ getFilterValue: getFilterValue$3,
2405
+ getHelpEntries: getHelpEntries$3,
2406
+ getLabel: getLabel$3,
2407
+ getNoResults: getNoResults$4,
2408
+ getPickDescription: getPickDescription$2,
2409
+ getPickFileIcon: getPickFileIcon$1,
2410
+ getPickFilterValue: getPickFilterValue$3,
2411
+ getPickIcon: getPickIcon$3,
2412
+ getPickLabel: getPickLabel$3,
2413
+ getPicks: getPicks$4,
2414
+ getPlaceholder: getPlaceholder$4,
2415
+ isPrepared,
2416
+ name: name$2,
2417
+ openCommandPalette,
2418
+ openView,
2419
+ selectPick: selectPick$4,
2420
+ state: state$1
2476
2421
  };
2477
- const getNoResults$3 = () => {
2422
+
2423
+ const Default = 0;
2424
+ const Finished = 2;
2425
+
2426
+ const create$2 = () => {
2427
+ const states = Object.create(null);
2478
2428
  return {
2479
- label: noSymbolFound()
2429
+ get(uid) {
2430
+ return states[uid];
2431
+ },
2432
+ set(uid, oldState, newState) {
2433
+ states[uid] = {
2434
+ oldState,
2435
+ newState
2436
+ };
2437
+ }
2480
2438
  };
2481
2439
  };
2482
- const getPicks$4 = async () => {
2483
- const picks = [];
2484
- return picks;
2485
- };
2486
- const selectPick$4 = async item => {
2440
+
2441
+ const {
2442
+ get,
2443
+ set
2444
+ } = create$2();
2445
+
2446
+ const create$1 = ({
2447
+ itemHeight,
2448
+ headerHeight = 0,
2449
+ minimumSliderSize = 20
2450
+ }) => {
2487
2451
  return {
2488
- command: Hide
2452
+ deltaY: 0,
2453
+ minLineY: 0,
2454
+ maxLineY: 0,
2455
+ finalDeltaY: 0,
2456
+ itemHeight,
2457
+ headerHeight,
2458
+ items: [],
2459
+ minimumSliderSize,
2460
+ focusedIndex: -1,
2461
+ touchOffsetY: 0,
2462
+ touchTimeStamp: 0,
2463
+ touchDifference: 0,
2464
+ scrollBarHeight: 0,
2465
+ scrollBarActive: false
2489
2466
  };
2490
2467
  };
2491
- const getFilterValue$3 = value => {
2492
- return value;
2468
+
2469
+ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) => {
2470
+ const state = {
2471
+ uid,
2472
+ state: Default,
2473
+ picks: [],
2474
+ recentPicks: [],
2475
+ recentPickIds: new Map(),
2476
+ // TODO use object.create(null) instead
2477
+ versionId: 0,
2478
+ provider: QuickPickEntriesEverything,
2479
+ // TODO make this dynamic again
2480
+ warned: [],
2481
+ visiblePicks: [],
2482
+ maxVisibleItems: 10,
2483
+ uri,
2484
+ cursorOffset: 0,
2485
+ height: 300,
2486
+ top: 50,
2487
+ width: 600,
2488
+ ...create$1({
2489
+ itemHeight: listItemHeight,
2490
+ headerHeight: 30,
2491
+ minimumSliderSize: minimumSliderSize
2492
+ }),
2493
+ inputSource: User,
2494
+ args,
2495
+ focused: false,
2496
+ platform,
2497
+ value: ''
2498
+ };
2499
+ set(uid, state, state);
2500
+ return state;
2493
2501
  };
2494
2502
 
2495
- const QuickPickEntriesSymbol = {
2496
- __proto__: null,
2497
- getFilterValue: getFilterValue$3,
2498
- getHelpEntries: getHelpEntries$4,
2499
- getNoResults: getNoResults$3,
2500
- getPicks: getPicks$4,
2501
- getPlaceholder: getPlaceholder$4,
2502
- name: name$3,
2503
- selectPick: selectPick$4
2503
+ const getBlob$1 = async url => {
2504
+ try {
2505
+ const response = await fetch(url);
2506
+ if (!response.ok) {
2507
+ throw new Error(response.statusText);
2508
+ }
2509
+ const text = await response.blob();
2510
+ return text;
2511
+ } catch (error) {
2512
+ throw new VError(error, `Failed to request blob for ${url}`);
2513
+ }
2504
2514
  };
2505
2515
 
2506
- // TODO probably not needed
2516
+ const getText = async url => {
2517
+ try {
2518
+ const response = await fetch(url);
2519
+ if (!response.ok) {
2520
+ throw new Error(response.statusText);
2521
+ }
2522
+ const text = await response.text();
2523
+ return text;
2524
+ } catch (error) {
2525
+ throw new VError(error, `Failed to request text for ${url}`);
2526
+ }
2527
+ };
2507
2528
 
2508
- const getPlaceholder$3 = () => {
2509
- return typeNameofCommandToRun();
2529
+ // TODO move all of this to an extension
2530
+
2531
+ const readFile = async uri => {
2532
+ const fetchUri = `${assetDir}${uri}`;
2533
+ const text = await getText(fetchUri);
2534
+ return text;
2510
2535
  };
2511
- const getHelpEntries$3 = () => {
2512
- return undefined;
2536
+ const writeFile = () => {
2537
+ throw new Error('not implemented');
2513
2538
  };
2514
- const getPicks$3 = async () => {
2515
- // const views = ViewService.getViews()
2516
- // const picks = views.map(toPick)
2517
- // return picks
2518
- return [];
2539
+ const mkdir = () => {
2540
+ throw new Error('not implemented');
2519
2541
  };
2520
- const selectPick$3 = async item => {
2521
- // Command.execute(/* openView */ 549, /* viewName */ item.label)
2522
- // return {
2523
- // command: QuickPickReturnValue.Hide,
2524
- // }
2542
+ const remove = () => {
2543
+ throw new Error('not implemented');
2525
2544
  };
2526
- const getFilterValue$2 = value => {
2527
- return value;
2545
+ const readDirWithFileTypes = async uri => {
2546
+ const fileList = await getJson(fileMapUrl);
2547
+ const dirents = [];
2548
+ for (const fileUri of fileList) {
2549
+ if (fileUri.startsWith(uri)) {
2550
+ const rest = fileUri.slice(uri.length + 1);
2551
+ if (rest.includes(Slash)) {
2552
+ const name = rest.slice(0, rest.indexOf(Slash));
2553
+ if (dirents.some(dirent => dirent.name === name)) {
2554
+ continue;
2555
+ }
2556
+ dirents.push({
2557
+ type: Directory$1,
2558
+ name
2559
+ });
2560
+ } else {
2561
+ dirents.push({
2562
+ type: File$2,
2563
+ name: rest
2564
+ });
2565
+ }
2566
+ }
2567
+ }
2568
+ return dirents;
2569
+ };
2570
+ const chmod = () => {
2571
+ throw new Error('[memfs] chmod not implemented');
2572
+ };
2573
+ const getBlob = async (uri, type) => {
2574
+ const fetchUri = `${assetDir}${uri}`;
2575
+ const blob = getBlob$1(fetchUri);
2576
+ return blob;
2528
2577
  };
2529
2578
 
2530
- const QuickPickEntriesView = {
2531
- __proto__: null,
2532
- getFilterValue: getFilterValue$2,
2533
- getHelpEntries: getHelpEntries$3,
2534
- getPicks: getPicks$3,
2535
- getPlaceholder: getPlaceholder$3,
2536
- selectPick: selectPick$3
2579
+ const Enter = 3;
2580
+ const Escape = 8;
2581
+ const PageUp = 10;
2582
+ const PageDown = 11;
2583
+ const UpArrow = 14;
2584
+ const DownArrow = 16;
2585
+
2586
+ const FocusQuickPickInput = 20;
2587
+
2588
+ const getKeyBindings = () => {
2589
+ return [{
2590
+ key: Escape,
2591
+ command: 'Viewlet.closeWidget',
2592
+ args: ['QuickPick'],
2593
+ when: FocusQuickPickInput
2594
+ }, {
2595
+ key: UpArrow,
2596
+ command: 'QuickPick.focusPrevious',
2597
+ when: FocusQuickPickInput
2598
+ }, {
2599
+ key: DownArrow,
2600
+ command: 'QuickPick.focusNext',
2601
+ when: FocusQuickPickInput
2602
+ }, {
2603
+ key: PageUp,
2604
+ command: 'QuickPick.focusFirst',
2605
+ when: FocusQuickPickInput
2606
+ }, {
2607
+ key: PageDown,
2608
+ command: 'QuickPick.focusLast',
2609
+ when: FocusQuickPickInput
2610
+ }, {
2611
+ key: Enter,
2612
+ command: 'QuickPick.selectCurrentIndex',
2613
+ when: FocusQuickPickInput
2614
+ }];
2537
2615
  };
2538
2616
 
2539
- const name$2 = 'workspace-symbol';
2540
- const getPlaceholder$2 = () => {
2541
- return '';
2617
+ const getDefaultValue = uri => {
2618
+ switch (uri) {
2619
+ case 'quickPick://everything':
2620
+ return '>';
2621
+ default:
2622
+ return '';
2623
+ }
2542
2624
  };
2543
- const getHelpEntries$2 = () => {
2544
- return [];
2625
+
2626
+ const getColorThemeNames = async () => {
2627
+ return invoke$1(/* Ajax.getJson */'ColorTheme.getColorThemeNames');
2545
2628
  };
2546
- const getNoResults$2 = () => {
2547
- return {
2548
- label: noWorkspaceSymbolsFound()
2549
- };
2629
+
2630
+ const setColorTheme = id => {
2631
+ return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
2550
2632
  };
2551
- const getPicks$2 = async () => {
2552
- const picks = [];
2553
- return picks;
2633
+ const getPlaceholder$3 = () => {
2634
+ return selectColorTheme();
2635
+ };
2636
+ const getLabel$2 = () => {
2637
+ return selectColorTheme();
2638
+ };
2639
+ const getPicks$3 = async searchValue => {
2640
+ const colorThemeNames = await getColorThemeNames();
2641
+ return colorThemeNames;
2554
2642
  };
2555
- const selectPick$2 = async item => {
2643
+ const selectPick$3 = async pick => {
2644
+ await setColorTheme(/* colorThemeId */pick);
2556
2645
  return {
2557
2646
  command: Hide
2558
2647
  };
2559
2648
  };
2560
- const getFilterValue$1 = value => {
2649
+ const focusPick = async pick => {
2650
+ await setColorTheme(/* colorThemeId */pick);
2651
+ };
2652
+ const getFilterValue$2 = value => {
2561
2653
  return value;
2562
2654
  };
2563
-
2564
- const QuickPickEntriesWorkspaceSymbol = {
2565
- __proto__: null,
2566
- getFilterValue: getFilterValue$1,
2567
- getHelpEntries: getHelpEntries$2,
2568
- getNoResults: getNoResults$2,
2569
- getPicks: getPicks$2,
2570
- getPlaceholder: getPlaceholder$2,
2571
- name: name$2,
2572
- selectPick: selectPick$2
2655
+ const getNoResults$3 = () => {
2656
+ return {
2657
+ label: noMatchingColorThemesFound()
2658
+ };
2573
2659
  };
2574
-
2575
- const Command = '>';
2576
- const Symbol$1 = '@';
2577
- const WorkspaceSymbol = '#';
2578
- const GoToLine = ':';
2579
- const View = 'view ';
2580
- const None = '';
2581
-
2582
- // TODO avoid global variable
2583
-
2584
- const state = {
2585
- // providerId: PROVIDER_NOOP,
2586
- provider: QuickPickNoop,
2587
- prefix: 'string-that-should-never-match-another-string'
2660
+ const getPickFilterValue$2 = pick => {
2661
+ return pick;
2588
2662
  };
2589
-
2590
- /**
2591
- * @type {string}
2592
- */
2593
- const name$1 = 'everything';
2594
- const getPlaceholder$1 = () => {
2595
- return state.provider.getPlaceholder();
2663
+ const getPickLabel$2 = pick => {
2664
+ return pick;
2596
2665
  };
2597
- const getLabel = () => {
2666
+ const getPickIcon$2 = pick => {
2598
2667
  return '';
2599
2668
  };
2600
- const getHelpEntries$1 = () => {
2601
- return state.provider.getHelpEntries();
2602
- };
2603
- const getNoResults$1 = () => {
2604
- return state.provider.getNoResults();
2605
- };
2606
- const getPrefix = value => {
2607
- if (value.startsWith(Command)) {
2608
- return Command;
2609
- }
2610
- if (value.startsWith(Symbol$1)) {
2611
- return Symbol$1;
2612
- }
2613
- if (value.startsWith(WorkspaceSymbol)) {
2614
- return WorkspaceSymbol;
2615
- }
2616
- if (value.startsWith(GoToLine)) {
2617
- return GoToLine;
2618
- }
2619
- if (value.startsWith(View)) {
2620
- return View;
2621
- }
2622
- return None;
2623
- };
2624
- const getQuickPickProvider = prefix => {
2625
- // TODO could use enum for prefix
2626
- // TODO could use regex to extract prefix
2627
- // TODO or could check first letter char code (less comparisons)
2628
- switch (prefix) {
2629
- case Command:
2630
- return QuickPickEntriesCommand;
2631
- case Symbol$1:
2632
- return QuickPickEntriesSymbol;
2633
- case WorkspaceSymbol:
2634
- return QuickPickEntriesWorkspaceSymbol;
2635
- case GoToLine:
2636
- return QuickPickEntriesGoToLine;
2637
- case View:
2638
- return QuickPickEntriesView;
2639
- default:
2640
- return QuickPickEntriesFile;
2641
- }
2669
+
2670
+ const QuickPickEntriesColorTheme = {
2671
+ __proto__: null,
2672
+ focusPick,
2673
+ getFilterValue: getFilterValue$2,
2674
+ getLabel: getLabel$2,
2675
+ getNoResults: getNoResults$3,
2676
+ getPickFilterValue: getPickFilterValue$2,
2677
+ getPickIcon: getPickIcon$2,
2678
+ getPickLabel: getPickLabel$2,
2679
+ getPicks: getPicks$3,
2680
+ getPlaceholder: getPlaceholder$3,
2681
+ selectPick: selectPick$3,
2682
+ setColorTheme
2642
2683
  };
2643
- const getPicks$1 = async value => {
2644
- const prefix = getPrefix(value);
2645
- // TODO race condition
2646
- if (state.prefix !== prefix) {
2647
- state.prefix = prefix;
2648
- // @ts-ignore
2649
- state.provider = await getQuickPickProvider(prefix);
2650
- }
2651
- // TODO this line is a bit duplicated with getFilterValue
2652
- const slicedValue = value.slice(prefix.length);
2653
- const picks = await state.provider.getPicks(slicedValue);
2654
- return picks;
2684
+
2685
+ const Tag$1 = 'Tag';
2686
+ const Cloud$1 = 'Cloud';
2687
+ const SourceControl$1 = 'SourceControl';
2688
+ const None = '';
2689
+
2690
+ const SourceControl = 1;
2691
+ const Cloud = 2;
2692
+ const Tag = 3;
2693
+
2694
+ const name$1 = 'custom';
2695
+ const state = {
2696
+ args: []
2655
2697
  };
2656
- const selectPick$1 = item => {
2657
- const {
2658
- provider
2659
- } = state;
2660
- return provider.selectPick(item);
2698
+ const setArgs = args => {
2699
+ state.args = args;
2661
2700
  };
2662
- const openCommandPalette = () => {
2663
- // show('>')
2701
+ const getPlaceholder$2 = () => {
2702
+ return '';
2664
2703
  };
2665
- const openView = () => {
2666
- // show('view ')
2704
+ const getLabel$1 = () => {
2705
+ return 'Custom';
2667
2706
  };
2668
- const getFilterValue = value => {
2669
- return value.slice(state.prefix.length);
2707
+
2708
+ // TODO help entries should not be here
2709
+ const getHelpEntries$2 = () => {
2710
+ return [];
2670
2711
  };
2671
- const getPickFilterValue = pick => {
2672
- const {
2673
- provider
2674
- } = state;
2675
- return provider.getPickFilterValue(pick);
2712
+ const getNoResults$2 = () => {
2713
+ return {
2714
+ label: noMatchingResults()
2715
+ };
2676
2716
  };
2677
- const getPickDescription = pick => {
2678
- const {
2679
- provider
2680
- } = state;
2681
- // @ts-ignore
2682
- if (provider.getPickDescription) {
2683
- // @ts-ignore
2684
- return provider.getPickDescription(pick);
2685
- }
2686
- return '';
2717
+ const getPicks$2 = async searchValue => {
2718
+ const items = state.args[1] || [];
2719
+ return items;
2687
2720
  };
2688
- const getPickLabel = pick => {
2721
+ const selectPick$2 = async pick => {
2689
2722
  const {
2690
- provider
2723
+ args
2691
2724
  } = state;
2692
- // @ts-ignore
2693
- return provider.getPickLabel(pick);
2725
+ const resolve = args[2];
2726
+ resolve(pick);
2727
+ return {
2728
+ command: Hide
2729
+ };
2694
2730
  };
2695
- const getPickIcon = pick => {
2696
- const {
2697
- provider
2698
- } = state;
2699
- // @ts-ignore
2700
- return provider.getPickIcon(pick);
2731
+ const getFilterValue$1 = value => {
2732
+ return value;
2701
2733
  };
2702
- const getPickFileIcon = pick => {
2703
- const {
2704
- provider
2705
- } = state;
2706
- // @ts-ignore
2707
- if (provider.getPickFileIcon) {
2708
- // @ts-ignore
2709
- return provider.getPickFileIcon(pick);
2710
- }
2711
- return '';
2734
+ const getPickFilterValue$1 = pick => {
2735
+ return pick;
2712
2736
  };
2713
- const isPrepared = () => {
2714
- const {
2715
- provider
2716
- } = state;
2717
- // @ts-ignore
2718
- if (provider.isPrepared) {
2719
- // @ts-ignore
2720
- return provider.isPrepared();
2737
+ const getPickLabel$1 = pick => {
2738
+ return pick.label;
2739
+ };
2740
+ const getPickDescription$1 = pick => {
2741
+ return pick.description || '';
2742
+ };
2743
+ const convertIcon = icon => {
2744
+ switch (icon) {
2745
+ case SourceControl:
2746
+ return SourceControl$1;
2747
+ case Cloud:
2748
+ return Cloud$1;
2749
+ case Tag:
2750
+ return Tag$1;
2751
+ default:
2752
+ return None;
2721
2753
  }
2722
- return false;
2754
+ };
2755
+ const getPickIcon$1 = pick => {
2756
+ return convertIcon(pick.icon);
2723
2757
  };
2724
2758
 
2725
- const QuickPickEntriesEverything = {
2759
+ const QuickPickEntriesCustom = {
2726
2760
  __proto__: null,
2727
- getFilterValue,
2728
- getHelpEntries: getHelpEntries$1,
2729
- getLabel,
2730
- getNoResults: getNoResults$1,
2731
- getPickDescription,
2732
- getPickFileIcon,
2733
- getPickFilterValue,
2734
- getPickIcon,
2735
- getPickLabel,
2736
- getPicks: getPicks$1,
2737
- getPlaceholder: getPlaceholder$1,
2738
- isPrepared,
2761
+ getFilterValue: getFilterValue$1,
2762
+ getHelpEntries: getHelpEntries$2,
2763
+ getLabel: getLabel$1,
2764
+ getNoResults: getNoResults$2,
2765
+ getPickDescription: getPickDescription$1,
2766
+ getPickFilterValue: getPickFilterValue$1,
2767
+ getPickIcon: getPickIcon$1,
2768
+ getPickLabel: getPickLabel$1,
2769
+ getPicks: getPicks$2,
2770
+ getPlaceholder: getPlaceholder$2,
2739
2771
  name: name$1,
2740
- openCommandPalette,
2741
- openView,
2742
- selectPick: selectPick$1,
2772
+ selectPick: selectPick$2,
2773
+ setArgs,
2743
2774
  state
2744
2775
  };
2745
2776
 
2746
2777
  const name = 'number';
2747
- const getPlaceholder = () => {
2778
+ const getPlaceholder$1 = () => {
2748
2779
  return '';
2749
2780
  };
2750
- const getHelpEntries = () => {
2781
+ const getHelpEntries$1 = () => {
2751
2782
  return [];
2752
2783
  };
2753
- const getNoResults = () => {
2784
+ const getNoResults$1 = () => {
2754
2785
  return {
2755
2786
  label: noMatchingResults()
2756
2787
  };
2757
2788
  };
2758
- const getPicks = async () => {
2789
+ const getPicks$1 = async () => {
2759
2790
  const picks = [{
2760
2791
  label: '1'
2761
2792
  }, {
@@ -2779,7 +2810,7 @@ const getPicks = async () => {
2779
2810
  }];
2780
2811
  return picks;
2781
2812
  };
2782
- const selectPick = async item => {
2813
+ const selectPick$1 = async item => {
2783
2814
  return {
2784
2815
  command: Hide
2785
2816
  };
@@ -2787,20 +2818,110 @@ const selectPick = async item => {
2787
2818
 
2788
2819
  const QuickPickEntriesNumber = {
2789
2820
  __proto__: null,
2821
+ getHelpEntries: getHelpEntries$1,
2822
+ getNoResults: getNoResults$1,
2823
+ getPicks: getPicks$1,
2824
+ getPlaceholder: getPlaceholder$1,
2825
+ name,
2826
+ selectPick: selectPick$1
2827
+ };
2828
+
2829
+ // TODO support file icons
2830
+ const getFolderIcon = () => {
2831
+ return '';
2832
+ };
2833
+
2834
+ const getRecentlyOpened = () => {
2835
+ return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2836
+ };
2837
+ const openWorkspaceFolder = uri => {
2838
+ return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
2839
+ };
2840
+ const getPlaceholder = () => {
2841
+ return selectToOpen();
2842
+ };
2843
+ const getLabel = () => {
2844
+ return openRecent();
2845
+ };
2846
+ const getHelpEntries = () => {
2847
+ return [];
2848
+ };
2849
+ const getNoResults = () => {
2850
+ return {
2851
+ label: noRecentlyOpenedFoldersFound()
2852
+ };
2853
+ };
2854
+
2855
+ // TODO could also change api so that getPicks returns an array of anything
2856
+ // and the transformPick gets the label for each pick
2857
+ // This would make the code more module since the code for getting the picks
2858
+ // would be more independent of the specific data format of the quickpick provider
2859
+
2860
+ const getPicks = async () => {
2861
+ const recentlyOpened = await getRecentlyOpened();
2862
+ return recentlyOpened;
2863
+ };
2864
+
2865
+ // TODO selectPick should be independent of show/hide
2866
+ const selectPick = async pick => {
2867
+ const path = pick;
2868
+ await openWorkspaceFolder(path);
2869
+ return {
2870
+ command: Hide
2871
+ };
2872
+ };
2873
+ const getFilterValue = value => {
2874
+ return pathBaseName(value);
2875
+ };
2876
+ const getPickFilterValue = pick => {
2877
+ return pathBaseName(pick);
2878
+ };
2879
+ const getPickLabel = pick => {
2880
+ return pathBaseName(pick);
2881
+ };
2882
+ const getPickDescription = pick => {
2883
+ return pathDirName(pick);
2884
+ };
2885
+ const getPickIcon = () => {
2886
+ return '';
2887
+ };
2888
+ const getPickFileIcon = () => {
2889
+ return getFolderIcon();
2890
+ };
2891
+
2892
+ const QuickPickEntriesOpenRecent = {
2893
+ __proto__: null,
2894
+ getFilterValue,
2790
2895
  getHelpEntries,
2896
+ getLabel,
2791
2897
  getNoResults,
2898
+ getPickDescription,
2899
+ getPickFileIcon,
2900
+ getPickFilterValue,
2901
+ getPickIcon,
2902
+ getPickLabel,
2792
2903
  getPicks,
2793
2904
  getPlaceholder,
2794
- name,
2795
2905
  selectPick
2796
2906
  };
2797
2907
 
2908
+ const CommandPalette = 'quickPick://commandPalette';
2909
+ const File = 'quickPick://file';
2910
+ const EveryThing = 'quickPick://everything';
2911
+ const Number$1 = 'quickPick://number';
2912
+ const Recent = 'quickPick://recent';
2913
+ const ColorTheme = 'quickPick://color-theme';
2914
+ const Symbol$1 = 'quickPick://symbol';
2915
+ const View = 'quickPick://view';
2916
+ const WorkspaceSymbol = 'quickPick://workspace-symbol';
2917
+ const Custom = 'quickPick://custom';
2918
+
2798
2919
  const load = moduleId => {
2799
2920
  switch (moduleId) {
2800
2921
  case CommandPalette:
2801
- case File$1:
2922
+ case File:
2802
2923
  case EveryThing:
2803
- case WorkspaceSymbol$1:
2924
+ case WorkspaceSymbol:
2804
2925
  return QuickPickEntriesEverything;
2805
2926
  case Number$1:
2806
2927
  return QuickPickEntriesNumber;
@@ -2808,9 +2929,9 @@ const load = moduleId => {
2808
2929
  return QuickPickEntriesOpenRecent;
2809
2930
  case ColorTheme:
2810
2931
  return QuickPickEntriesColorTheme;
2811
- case Symbol$2:
2932
+ case Symbol$1:
2812
2933
  return QuickPickEntriesSymbol;
2813
- case View$1:
2934
+ case View:
2814
2935
  return QuickPickEntriesView;
2815
2936
  case Custom:
2816
2937
  return QuickPickEntriesCustom;
@@ -2819,24 +2940,72 @@ const load = moduleId => {
2819
2940
  }
2820
2941
  };
2821
2942
 
2943
+ const loadContent = async state => {
2944
+ const {
2945
+ uri,
2946
+ args
2947
+ } = state;
2948
+ const value = getDefaultValue(uri);
2949
+ const provider = await load(uri);
2950
+ // @ts-ignore
2951
+ if (provider.setArgs) {
2952
+ // @ts-ignore
2953
+ provider.setArgs(args);
2954
+ }
2955
+ const newPicks = await provider.getPicks(value);
2956
+ array(newPicks);
2957
+ // @ts-ignore
2958
+ const filterValue = provider.getFilterValue(value);
2959
+ const items = filterQuickPickItems(state.items, filterValue);
2960
+ // @ts-ignore
2961
+ provider.getLabel();
2962
+ const minLineY = 0;
2963
+ const maxLineY = Math.min(minLineY + state.maxVisibleItems, newPicks.length);
2964
+ return {
2965
+ ...state,
2966
+ picks: newPicks,
2967
+ items,
2968
+ focusedIndex: 0,
2969
+ state: Finished,
2970
+ minLineY,
2971
+ maxLineY,
2972
+ value,
2973
+ cursorOffset: value.length,
2974
+ provider,
2975
+ inputSource: Script,
2976
+ focused: true
2977
+ };
2978
+ };
2979
+
2980
+ const loadQuickPickEntries = moduleId => {
2981
+ switch (moduleId) {
2982
+ case Recent:
2983
+ return QuickPickEntriesOpenRecent;
2984
+ default:
2985
+ throw new Error(`unknown module "${moduleId}"`);
2986
+ }
2987
+ };
2988
+
2822
2989
  const commandMap = {
2823
- 'FileSystemFetch.chmod': chmod$1,
2824
- 'FileSystemFetch.getBlob': getBlob$1,
2825
- 'FileSystemFetch.mkdir': mkdir$1,
2826
- 'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes$1,
2827
- 'FileSystemFetch.readFile': readFile$1,
2828
- 'FileSystemFetch.remove': remove$1,
2829
- 'FileSystemFetch.writeFile': writeFile$1,
2830
- 'FileSystemMemory.chmod': chmod,
2831
- 'FileSystemMemory.getBlob': getBlob,
2990
+ 'FileSystemFetch.chmod': chmod,
2991
+ 'FileSystemFetch.getBlob': getBlob,
2992
+ 'FileSystemFetch.mkdir': mkdir,
2993
+ 'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes,
2994
+ 'FileSystemFetch.readFile': readFile,
2995
+ 'FileSystemFetch.remove': remove,
2996
+ 'FileSystemFetch.writeFile': writeFile,
2997
+ 'FileSystemMemory.chmod': chmod$1,
2998
+ 'FileSystemMemory.getBlob': getBlob$2,
2832
2999
  'FileSystemMemory.getBlobUrl': getBlobUrl,
2833
3000
  'FileSystemMemory.getFiles': getFiles,
2834
- 'FileSystemMemory.mkdir': mkdir,
2835
- 'FileSystemMemory.readDirWithFileTypes': readDirWithFileTypes,
2836
- 'FileSystemMemory.readFile': readFile,
2837
- 'FileSystemMemory.remove': remove,
2838
- 'FileSystemMemory.writeFile': writeFile,
3001
+ 'FileSystemMemory.mkdir': mkdir$1,
3002
+ 'FileSystemMemory.readDirWithFileTypes': readDirWithFileTypes$1,
3003
+ 'FileSystemMemory.readFile': readFile$1,
3004
+ 'FileSystemMemory.remove': remove$1,
3005
+ 'FileSystemMemory.writeFile': writeFile$1,
3006
+ 'QuickPick.create': create,
2839
3007
  'QuickPick.getKeyBindings': getKeyBindings,
3008
+ 'QuickPick.loadContent': loadContent,
2840
3009
  'QuickPick.loadEntries': loadQuickPickEntries,
2841
3010
  'QuickPick.loadEntries2': load,
2842
3011
  'SearchFile.filter': filterQuickPickItems,