@lvce-editor/text-search-worker 5.33.0 → 5.34.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.
@@ -243,8 +243,8 @@ const getModuleNotFoundError = stderr => {
243
243
  const messageIndex = lines.findIndex(isModuleNotFoundMessage);
244
244
  const message = lines[messageIndex];
245
245
  return {
246
- message,
247
- code: ERR_MODULE_NOT_FOUND
246
+ code: ERR_MODULE_NOT_FOUND,
247
+ message
248
248
  };
249
249
  };
250
250
  const isModuleNotFoundError = stderr => {
@@ -267,14 +267,14 @@ const isUnhelpfulNativeModuleError = stderr => {
267
267
  const getNativeModuleErrorMessage = stderr => {
268
268
  const message = getMessageCodeBlock(stderr);
269
269
  return {
270
- message: `Incompatible native node module: ${message}`,
271
- code: E_INCOMPATIBLE_NATIVE_MODULE
270
+ code: E_INCOMPATIBLE_NATIVE_MODULE,
271
+ message: `Incompatible native node module: ${message}`
272
272
  };
273
273
  };
274
274
  const getModuleSyntaxError = () => {
275
275
  return {
276
- message: `ES Modules are not supported in electron`,
277
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
276
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
277
+ message: `ES Modules are not supported in electron`
278
278
  };
279
279
  };
280
280
  const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -293,8 +293,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
293
293
  rest
294
294
  } = getDetails(lines);
295
295
  return {
296
- message: actualMessage,
297
296
  code: '',
297
+ message: actualMessage,
298
298
  stack: rest
299
299
  };
300
300
  };
@@ -304,8 +304,8 @@ class IpcError extends VError {
304
304
  if (stdout || stderr) {
305
305
  // @ts-ignore
306
306
  const {
307
- message,
308
307
  code,
308
+ message,
309
309
  stack
310
310
  } = getHelpfulChildProcessError(stdout, stderr);
311
311
  const cause = new Error(message);
@@ -366,8 +366,8 @@ const wrap$f = global => {
366
366
  };
367
367
  const waitForFirstMessage = async port => {
368
368
  const {
369
- resolve,
370
- promise
369
+ promise,
370
+ resolve
371
371
  } = Promise.withResolvers();
372
372
  port.addEventListener('message', resolve, {
373
373
  once: true
@@ -387,8 +387,8 @@ const listen$6 = async () => {
387
387
  const type = firstMessage.params[0];
388
388
  if (type === 'message-port') {
389
389
  parentIpc.send({
390
- jsonrpc: '2.0',
391
390
  id: firstMessage.id,
391
+ jsonrpc: '2.0',
392
392
  result: null
393
393
  });
394
394
  parentIpc.dispose();
@@ -448,8 +448,8 @@ const removeListener = (emitter, type, callback) => {
448
448
  };
449
449
  const getFirstEvent = (eventEmitter, eventMap) => {
450
450
  const {
451
- resolve,
452
- promise
451
+ promise,
452
+ resolve
453
453
  } = Promise.withResolvers();
454
454
  const listenerMap = Object.create(null);
455
455
  const cleanup = value => {
@@ -461,8 +461,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
461
461
  for (const [event, type] of Object.entries(eventMap)) {
462
462
  const listener = event => {
463
463
  cleanup({
464
- type,
465
- event
464
+ event,
465
+ type
466
466
  });
467
467
  };
468
468
  addListener(eventEmitter, event, listener);
@@ -472,8 +472,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
472
472
  };
473
473
  const Message$1 = 3;
474
474
  const create$5$1 = async ({
475
- messagePort,
476
- isMessagePortOpen
475
+ isMessagePortOpen,
476
+ messagePort
477
477
  }) => {
478
478
  if (!isMessagePort(messagePort)) {
479
479
  throw new IpcError('port must be of type MessagePort');
@@ -486,8 +486,8 @@ const create$5$1 = async ({
486
486
  });
487
487
  messagePort.start();
488
488
  const {
489
- type,
490
- event
489
+ event,
490
+ type
491
491
  } = await eventPromise;
492
492
  if (type !== Message$1) {
493
493
  throw new IpcError('Failed to wait for ipc message');
@@ -541,12 +541,12 @@ const parse = content => {
541
541
  };
542
542
  const waitForWebSocketToBeOpen = webSocket => {
543
543
  return getFirstEvent(webSocket, {
544
- open: Open,
545
544
  close: Close,
546
- error: Error$3
545
+ error: Error$3,
546
+ open: Open
547
547
  });
548
548
  };
549
- const create$7 = async ({
549
+ const create$6 = async ({
550
550
  webSocket
551
551
  }) => {
552
552
  const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
@@ -583,60 +583,18 @@ const wrap = webSocket => {
583
583
  };
584
584
  const IpcParentWithWebSocket$1 = {
585
585
  __proto__: null,
586
- create: create$7,
586
+ create: create$6,
587
587
  wrap
588
588
  };
589
589
 
590
- const Two = '2.0';
591
- const create$4$1 = (method, params) => {
592
- return {
593
- jsonrpc: Two,
594
- method,
595
- params
596
- };
597
- };
590
+ const Two$1 = '2.0';
598
591
  const callbacks = Object.create(null);
599
- const set$4 = (id, fn) => {
600
- callbacks[id] = fn;
601
- };
602
592
  const get$3 = id => {
603
593
  return callbacks[id];
604
594
  };
605
595
  const remove$2 = id => {
606
596
  delete callbacks[id];
607
597
  };
608
- let id = 0;
609
- const create$3$2 = () => {
610
- return ++id;
611
- };
612
- const registerPromise = () => {
613
- const id = create$3$2();
614
- const {
615
- resolve,
616
- promise
617
- } = Promise.withResolvers();
618
- set$4(id, resolve);
619
- return {
620
- id,
621
- promise
622
- };
623
- };
624
- const create$2$2 = (method, params) => {
625
- const {
626
- id,
627
- promise
628
- } = registerPromise();
629
- const message = {
630
- jsonrpc: Two,
631
- method,
632
- params,
633
- id
634
- };
635
- return {
636
- message,
637
- promise
638
- };
639
- };
640
598
  class JsonRpcError extends Error {
641
599
  constructor(message) {
642
600
  super(message);
@@ -832,7 +790,7 @@ const getErrorProperty = (error, prettyError) => {
832
790
  };
833
791
  const create$1$2 = (id, error) => {
834
792
  return {
835
- jsonrpc: Two,
793
+ jsonrpc: Two$1,
836
794
  id,
837
795
  error
838
796
  };
@@ -843,20 +801,20 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
843
801
  const errorProperty = getErrorProperty(error, prettyError);
844
802
  return create$1$2(id, errorProperty);
845
803
  };
846
- const create$6 = (message, result) => {
804
+ const create$5 = (message, result) => {
847
805
  return {
848
- jsonrpc: Two,
806
+ jsonrpc: Two$1,
849
807
  id: message.id,
850
808
  result: result ?? null
851
809
  };
852
810
  };
853
811
  const getSuccessResponse = (message, result) => {
854
812
  const resultProperty = result ?? null;
855
- return create$6(message, resultProperty);
813
+ return create$5(message, resultProperty);
856
814
  };
857
815
  const getErrorResponseSimple = (id, error) => {
858
816
  return {
859
- jsonrpc: Two,
817
+ jsonrpc: Two$1,
860
818
  id,
861
819
  error: {
862
820
  code: Custom,
@@ -943,29 +901,6 @@ const handleJsonRpcMessage = async (...args) => {
943
901
  }
944
902
  throw new JsonRpcError('unexpected message');
945
903
  };
946
- const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
947
- const {
948
- message,
949
- promise
950
- } = create$2$2(method, params);
951
- if (useSendAndTransfer && ipc.sendAndTransfer) {
952
- ipc.sendAndTransfer(message);
953
- } else {
954
- ipc.send(message);
955
- }
956
- const responseMessage = await promise;
957
- return unwrapJsonRpcResult(responseMessage);
958
- };
959
- const send$1 = (transport, method, ...params) => {
960
- const message = create$4$1(method, params);
961
- transport.send(message);
962
- };
963
- const invoke$3 = (ipc, method, ...params) => {
964
- return invokeHelper(ipc, method, params, false);
965
- };
966
- const invokeAndTransfer$1 = (ipc, method, ...params) => {
967
- return invokeHelper(ipc, method, params, true);
968
- };
969
904
 
970
905
  class CommandNotFoundError extends Error {
971
906
  constructor(command) {
@@ -988,24 +923,87 @@ const execute = (command, ...args) => {
988
923
  return fn(...args);
989
924
  };
990
925
 
926
+ const Two = '2.0';
927
+ const create$s = (method, params) => {
928
+ return {
929
+ jsonrpc: Two,
930
+ method,
931
+ params
932
+ };
933
+ };
934
+ const create$r = (id, method, params) => {
935
+ const message = {
936
+ id,
937
+ jsonrpc: Two,
938
+ method,
939
+ params
940
+ };
941
+ return message;
942
+ };
943
+ let id = 0;
944
+ const create$q = () => {
945
+ return ++id;
946
+ };
947
+
948
+ /* eslint-disable n/no-unsupported-features/es-syntax */
949
+
950
+ const registerPromise = map => {
951
+ const id = create$q();
952
+ const {
953
+ promise,
954
+ resolve
955
+ } = Promise.withResolvers();
956
+ map[id] = resolve;
957
+ return {
958
+ id,
959
+ promise
960
+ };
961
+ };
962
+
963
+ // @ts-ignore
964
+ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
965
+ const {
966
+ id,
967
+ promise
968
+ } = registerPromise(callbacks);
969
+ const message = create$r(id, method, params);
970
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
971
+ ipc.sendAndTransfer(message);
972
+ } else {
973
+ ipc.send(message);
974
+ }
975
+ const responseMessage = await promise;
976
+ return unwrapJsonRpcResult(responseMessage);
977
+ };
991
978
  const createRpc = ipc => {
979
+ const callbacks = Object.create(null);
980
+ ipc._resolve = (id, response) => {
981
+ const fn = callbacks[id];
982
+ if (!fn) {
983
+ console.warn(`callback ${id} may already be disposed`);
984
+ return;
985
+ }
986
+ fn(response);
987
+ delete callbacks[id];
988
+ };
992
989
  const rpc = {
990
+ async dispose() {
991
+ await ipc?.dispose();
992
+ },
993
+ invoke(method, ...params) {
994
+ return invokeHelper(callbacks, ipc, method, params, false);
995
+ },
996
+ invokeAndTransfer(method, ...params) {
997
+ return invokeHelper(callbacks, ipc, method, params, true);
998
+ },
993
999
  // @ts-ignore
994
1000
  ipc,
995
1001
  /**
996
1002
  * @deprecated
997
1003
  */
998
1004
  send(method, ...params) {
999
- send$1(ipc, method, ...params);
1000
- },
1001
- invoke(method, ...params) {
1002
- return invoke$3(ipc, method, ...params);
1003
- },
1004
- invokeAndTransfer(method, ...params) {
1005
- return invokeAndTransfer$1(ipc, method, ...params);
1006
- },
1007
- async dispose() {
1008
- await ipc?.dispose();
1005
+ const message = create$s(method, params);
1006
+ ipc.send(message);
1009
1007
  }
1010
1008
  };
1011
1009
  return rpc;
@@ -1022,7 +1020,7 @@ const logError = () => {
1022
1020
  const handleMessage = event => {
1023
1021
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
1024
1022
  const actualExecute = event?.target?.execute || execute;
1025
- return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
1023
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
1026
1024
  };
1027
1025
  const handleIpc = ipc => {
1028
1026
  if ('addEventListener' in ipc) {
@@ -1040,53 +1038,52 @@ const listen$1 = async (module, options) => {
1040
1038
  const ipc = module.wrap(rawIpc);
1041
1039
  return ipc;
1042
1040
  };
1043
- const create$5 = async ({
1044
- commandMap,
1045
- messagePort
1046
- }) => {
1047
- // TODO create a commandMap per rpc instance
1048
- register(commandMap);
1049
- const rawIpc = await IpcParentWithMessagePort$1.create({
1050
- messagePort,
1051
- isMessagePortOpen: true
1052
- });
1053
- const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1054
- handleIpc(ipc);
1055
- const rpc = createRpc(ipc);
1056
- messagePort.start();
1057
- return rpc;
1041
+
1042
+ /* eslint-disable @typescript-eslint/no-misused-promises */
1043
+
1044
+ const createSharedLazyRpc = factory => {
1045
+ let rpcPromise;
1046
+ const getOrCreate = () => {
1047
+ if (!rpcPromise) {
1048
+ rpcPromise = factory();
1049
+ }
1050
+ return rpcPromise;
1051
+ };
1052
+ return {
1053
+ async dispose() {
1054
+ const rpc = await getOrCreate();
1055
+ await rpc.dispose();
1056
+ },
1057
+ async invoke(method, ...params) {
1058
+ const rpc = await getOrCreate();
1059
+ return rpc.invoke(method, ...params);
1060
+ },
1061
+ async invokeAndTransfer(method, ...params) {
1062
+ const rpc = await getOrCreate();
1063
+ return rpc.invokeAndTransfer(method, ...params);
1064
+ },
1065
+ async send(method, ...params) {
1066
+ const rpc = await getOrCreate();
1067
+ rpc.send(method, ...params);
1068
+ }
1069
+ };
1058
1070
  };
1059
- const create$3$1 = async ({
1071
+ const create$i = async ({
1060
1072
  commandMap,
1073
+ isMessagePortOpen,
1061
1074
  send
1062
1075
  }) => {
1063
- const {
1064
- port1,
1065
- port2
1066
- } = new MessageChannel();
1067
- await send(port1);
1068
- return create$5({
1069
- commandMap,
1070
- messagePort: port2
1076
+ return createSharedLazyRpc(() => {
1077
+ return create$2$1({
1078
+ commandMap,
1079
+ isMessagePortOpen,
1080
+ send
1081
+ });
1071
1082
  });
1072
1083
  };
1073
- const TransferMessagePortRpcParent = {
1084
+ const LazyTransferMessagePortRpcParent = {
1074
1085
  __proto__: null,
1075
- create: create$3$1
1076
- };
1077
- const create$2$1 = async ({
1078
- commandMap,
1079
- webSocket
1080
- }) => {
1081
- // TODO create a commandMap per rpc instance
1082
- register(commandMap);
1083
- const rawIpc = await IpcParentWithWebSocket$1.create({
1084
- webSocket
1085
- });
1086
- const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
1087
- handleIpc(ipc);
1088
- const rpc = createRpc(ipc);
1089
- return rpc;
1086
+ create: create$i
1090
1087
  };
1091
1088
  const Https = 'https:';
1092
1089
  const Ws = 'ws:';
@@ -1104,7 +1101,21 @@ const getHost = () => {
1104
1101
  const getProtocol$1 = () => {
1105
1102
  return location.protocol;
1106
1103
  };
1107
- const create$1$1 = async ({
1104
+ const create$h = async ({
1105
+ commandMap,
1106
+ webSocket
1107
+ }) => {
1108
+ // TODO create a commandMap per rpc instance
1109
+ register(commandMap);
1110
+ const rawIpc = await IpcParentWithWebSocket$1.create({
1111
+ webSocket
1112
+ });
1113
+ const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
1114
+ handleIpc(ipc);
1115
+ const rpc = createRpc(ipc);
1116
+ return rpc;
1117
+ };
1118
+ const create$g = async ({
1108
1119
  commandMap,
1109
1120
  type
1110
1121
  }) => {
@@ -1112,17 +1123,65 @@ const create$1$1 = async ({
1112
1123
  const protocol = getProtocol$1();
1113
1124
  const wsUrl = getWebSocketUrl(type, host, protocol);
1114
1125
  const webSocket = new WebSocket(wsUrl);
1115
- const rpc = await create$2$1({
1116
- webSocket,
1117
- commandMap
1126
+ const rpc = await create$h({
1127
+ commandMap,
1128
+ webSocket
1118
1129
  });
1119
1130
  return rpc;
1120
1131
  };
1121
- const WebSocketRpcParent2 = {
1132
+ const create$f = async ({
1133
+ commandMap,
1134
+ type
1135
+ }) => {
1136
+ return createSharedLazyRpc(() => {
1137
+ return create$g({
1138
+ commandMap,
1139
+ type
1140
+ });
1141
+ });
1142
+ };
1143
+ const LazyWebSocketRpcParent2 = {
1122
1144
  __proto__: null,
1123
- create: create$1$1
1145
+ create: create$f
1124
1146
  };
1125
1147
  const create$4 = async ({
1148
+ commandMap,
1149
+ isMessagePortOpen = true,
1150
+ messagePort
1151
+ }) => {
1152
+ // TODO create a commandMap per rpc instance
1153
+ register(commandMap);
1154
+ const rawIpc = await IpcParentWithMessagePort$1.create({
1155
+ isMessagePortOpen,
1156
+ messagePort
1157
+ });
1158
+ const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1159
+ handleIpc(ipc);
1160
+ const rpc = createRpc(ipc);
1161
+ messagePort.start();
1162
+ return rpc;
1163
+ };
1164
+ const create$2$1 = async ({
1165
+ commandMap,
1166
+ isMessagePortOpen,
1167
+ send
1168
+ }) => {
1169
+ const {
1170
+ port1,
1171
+ port2
1172
+ } = new MessageChannel();
1173
+ await send(port1);
1174
+ return create$4({
1175
+ commandMap,
1176
+ isMessagePortOpen,
1177
+ messagePort: port2
1178
+ });
1179
+ };
1180
+ const TransferMessagePortRpcParent = {
1181
+ __proto__: null,
1182
+ create: create$2$1
1183
+ };
1184
+ const create$1$1 = async ({
1126
1185
  commandMap
1127
1186
  }) => {
1128
1187
  // TODO create a commandMap per rpc instance
@@ -1134,7 +1193,7 @@ const create$4 = async ({
1134
1193
  };
1135
1194
  const WebWorkerRpcClient = {
1136
1195
  __proto__: null,
1137
- create: create$4
1196
+ create: create$1$1
1138
1197
  };
1139
1198
 
1140
1199
  const Alert = 'alert';
@@ -1147,78 +1206,9 @@ const ToolBar = 'toolbar';
1147
1206
  const Tree$1 = 'tree';
1148
1207
  const TreeItem$1 = 'treeitem';
1149
1208
 
1150
- const Actions = 'Actions';
1151
- const Badge = 'Badge';
1152
- const Chevron = 'Chevron';
1153
- const CloseMaskIcon = 'MaskIcon MaskIconClose';
1154
- const Empty$1 = '';
1155
- const FileIcon = 'FileIcon';
1156
- const FocusOutline = 'FocusOutline';
1157
- const Grow = 'Grow';
1158
- const Highlight = 'Highlight';
1159
- const HighlightDeleted = 'HighlightDeleted';
1160
- const HighlightInserted = 'HighlightInserted';
1161
- const IconButton = 'IconButton';
1162
- const IconButtonDisabled = 'IconButtonDisabled';
1163
- const Label = 'Label';
1164
- const List$1 = 'List';
1165
- const MaskIcon = 'MaskIcon';
1166
- const MaskIconBook = 'MaskIconBook';
1167
- const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1168
- const MaskIconChevronDown = 'MaskIconChevronDown';
1169
- const MaskIconChevronRight = 'MaskIconChevronRight';
1170
- const MaskIconEllipsis = 'MaskIconEllipsis';
1171
- const MaskIconExclude = 'MaskIconExclude';
1172
- const MaskIconPreserveCase = 'MaskIconPreserveCase';
1173
- const MaskIconRegex = 'MaskIconRegex';
1174
- const MaskIconReplaceAll = 'MaskIconReplaceAll';
1175
- const MaskIconWholeWord = 'MaskIconWholeWord';
1176
- const MultilineInputBox = 'MultilineInputBox';
1177
- const ScrollBar = 'ScrollBar';
1178
- const ScrollBarThumb = 'ScrollBarThumb';
1179
- const ScrollBarVertical = 'ScrollBarVertical';
1180
- const Search$2 = 'Search';
1181
- const SearchField = 'SearchField';
1182
- const SearchFieldButton = 'SearchFieldButton';
1183
- const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
1184
- const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
1185
- const SearchFieldButtons = 'SearchFieldButtons';
1186
- const SearchFieldContainer = 'SearchFieldContainer';
1187
- const SearchFieldError = 'SearchFieldError';
1188
- const SearchHeader = 'SearchHeader';
1189
- const SearchHeaderDetails = 'SearchHeaderDetails';
1190
- const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1191
- const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1192
- const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1193
- const SearchHeaderTop = 'SearchHeaderTop';
1194
- const SearchHeaderTopRight = 'SearchHeaderTopRight';
1195
- const SearchInputError = 'SearchInputError';
1196
- const SearchRemove = 'SearchRemove';
1197
- const SearchToggleButton = 'SearchToggleButton';
1198
- const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1199
- const SourceControlBadge = 'SourceControlBadge';
1200
- const ToggleDetails = 'ToggleDetails';
1201
- const Tree = 'Tree';
1202
- const TreeItem = 'TreeItem';
1203
- const TreeItemActive = 'TreeItemActive';
1204
- const TreeItems$1 = 'TreeItems';
1205
- const Viewlet = 'Viewlet';
1206
- const ViewletSearchMessage = 'ViewletSearchMessage';
1207
- const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1208
-
1209
1209
  const File$2 = 7;
1210
1210
 
1211
- const Button$2 = 1;
1212
- const Div = 4;
1213
- const Span = 8;
1214
- const Text = 12;
1215
- const Img = 17;
1216
- const Ins = 20;
1217
- const Del = 21;
1218
- const H4 = 24;
1219
- const TextArea = 62;
1220
-
1221
- const Button$1 = 'event.button';
1211
+ const Button$2 = 'event.button';
1222
1212
  const ClientX = 'event.clientX';
1223
1213
  const ClientY = 'event.clientY';
1224
1214
  const DeltaMode = 'event.deltaMode';
@@ -1230,7 +1220,7 @@ const TargetValue = 'event.target.value';
1230
1220
 
1231
1221
  const Script$1 = 2;
1232
1222
 
1233
- const Search$1 = 18;
1223
+ const Search$2 = 18;
1234
1224
  const InputContextMenu = 91;
1235
1225
 
1236
1226
  const Separator = 1;
@@ -1241,9 +1231,9 @@ const LeftClick = 0;
1241
1231
  const Electron = 2;
1242
1232
  const Remote = 3;
1243
1233
 
1234
+ const IconThemeWorker = 7009;
1244
1235
  const RendererWorker = 1;
1245
1236
  const SearchProcess = 77;
1246
- const IconThemeWorker = 7009;
1247
1237
 
1248
1238
  const File$1 = 1;
1249
1239
  const Match$1 = 2;
@@ -1253,25 +1243,10 @@ const SetDom2 = 'Viewlet.setDom2';
1253
1243
  const SetFocusContext = 'Viewlet.setFocusContext';
1254
1244
  const SetValueByName = 'Viewlet.setValueByName';
1255
1245
 
1256
- const Empty = 0;
1257
- const FocusIgnoreFiles = 1012;
1258
- const FocusSearch = 1013;
1259
- const FocusSearchExcludeInput = 1008;
1260
- const FocusSearchIncludeInput = 1007;
1261
- const FocusSearchInput = 21;
1262
- const FocusSearchMatchCase = 32;
1263
- const FocusSearchOpenEditors = 1011;
1264
- const FocusSearchPreserveCase = 36;
1265
- const FocusSearchRegex = 33;
1266
- const FocusSearchReplaceAll = 35;
1267
- const FocusSearchReplaceInput = 31;
1268
- const FocusSearchResults = 22;
1269
- const FocusSearchWholeWord = 34;
1270
- const FocusToggleDetails = 1010;
1271
- const FocusToggleReplace = 1020;
1246
+ const FocusSearch$1 = 1013;
1272
1247
 
1273
1248
  const rpcs = Object.create(null);
1274
- const set$3 = (id, rpc) => {
1249
+ const set$4 = (id, rpc) => {
1275
1250
  rpcs[id] = rpc;
1276
1251
  };
1277
1252
  const get$2 = id => {
@@ -1280,6 +1255,10 @@ const get$2 = id => {
1280
1255
 
1281
1256
  const create$3 = rpcId => {
1282
1257
  return {
1258
+ async dispose() {
1259
+ const rpc = get$2(rpcId);
1260
+ await rpc.dispose();
1261
+ },
1283
1262
  // @ts-ignore
1284
1263
  invoke(method, ...params) {
1285
1264
  const rpc = get$2(rpcId);
@@ -1293,18 +1272,15 @@ const create$3 = rpcId => {
1293
1272
  return rpc.invokeAndTransfer(method, ...params);
1294
1273
  },
1295
1274
  set(rpc) {
1296
- set$3(rpcId, rpc);
1297
- },
1298
- async dispose() {
1299
- const rpc = get$2(rpcId);
1300
- await rpc.dispose();
1275
+ set$4(rpcId, rpc);
1301
1276
  }
1302
1277
  };
1303
1278
  };
1304
1279
 
1305
1280
  const {
1306
1281
  invoke: invoke$2,
1307
- set: set$2} = create$3(IconThemeWorker);
1282
+ set: set$3
1283
+ } = create$3(IconThemeWorker);
1308
1284
  const getIcons = async iconRequests => {
1309
1285
  // @ts-ignore
1310
1286
  return invoke$2('IconTheme.getIcons', iconRequests);
@@ -1313,7 +1289,8 @@ const getIcons = async iconRequests => {
1313
1289
  const {
1314
1290
  invoke: invoke$1,
1315
1291
  invokeAndTransfer,
1316
- set: set$1} = create$3(RendererWorker);
1292
+ set: set$2
1293
+ } = create$3(RendererWorker);
1317
1294
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1318
1295
  number(uid);
1319
1296
  number(menuId);
@@ -1340,30 +1317,10 @@ const openUri$1 = async (uri, focus, options) => {
1340
1317
  await invoke$1('Main.openUri', uri, focus, options);
1341
1318
  };
1342
1319
 
1343
- const createLazyRpc = rpcId => {
1344
- let rpcPromise;
1345
- let factory;
1346
- const createRpc = async () => {
1347
- const rpc = await factory();
1348
- set$3(rpcId, rpc);
1349
- };
1350
- const ensureRpc = async () => {
1351
- if (!rpcPromise) {
1352
- rpcPromise = createRpc();
1353
- }
1354
- await rpcPromise;
1355
- };
1356
- return {
1357
- setFactory(value) {
1358
- factory = value;
1359
- },
1360
- async invoke(method, ...params) {
1361
- await ensureRpc();
1362
- const rpc = get$2(rpcId);
1363
- return rpc.invoke(method, ...params);
1364
- }
1365
- };
1366
- };
1320
+ const {
1321
+ invoke,
1322
+ set: set$1
1323
+ } = create$3(SearchProcess);
1367
1324
 
1368
1325
  const toCommandId = key => {
1369
1326
  const dotIndex = key.indexOf('.');
@@ -1450,6 +1407,92 @@ const terminate = () => {
1450
1407
  globalThis.close();
1451
1408
  };
1452
1409
 
1410
+ const Actions = 'Actions';
1411
+ const Badge = 'Badge';
1412
+ const Chevron = 'Chevron';
1413
+ const CloseMaskIcon = 'MaskIcon MaskIconClose';
1414
+ const Empty$1 = '';
1415
+ const FileIcon = 'FileIcon';
1416
+ const FocusOutline = 'FocusOutline';
1417
+ const Grow = 'Grow';
1418
+ const Highlight = 'Highlight';
1419
+ const HighlightDeleted = 'HighlightDeleted';
1420
+ const HighlightInserted = 'HighlightInserted';
1421
+ const IconButton = 'IconButton';
1422
+ const IconButtonDisabled = 'IconButtonDisabled';
1423
+ const Label = 'Label';
1424
+ const List$1 = 'List';
1425
+ const MaskIcon = 'MaskIcon';
1426
+ const MaskIconBook = 'MaskIconBook';
1427
+ const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1428
+ const MaskIconChevronDown = 'MaskIconChevronDown';
1429
+ const MaskIconChevronRight = 'MaskIconChevronRight';
1430
+ const MaskIconEllipsis = 'MaskIconEllipsis';
1431
+ const MaskIconExclude = 'MaskIconExclude';
1432
+ const MaskIconPreserveCase = 'MaskIconPreserveCase';
1433
+ const MaskIconRegex = 'MaskIconRegex';
1434
+ const MaskIconReplaceAll = 'MaskIconReplaceAll';
1435
+ const MaskIconWholeWord = 'MaskIconWholeWord';
1436
+ const MultilineInputBox = 'MultilineInputBox';
1437
+ const ScrollBar = 'ScrollBar';
1438
+ const ScrollBarThumb = 'ScrollBarThumb';
1439
+ const ScrollBarVertical = 'ScrollBarVertical';
1440
+ const Search$1 = 'Search';
1441
+ const SearchField = 'SearchField';
1442
+ const SearchFieldButton = 'SearchFieldButton';
1443
+ const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
1444
+ const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
1445
+ const SearchFieldButtons = 'SearchFieldButtons';
1446
+ const SearchFieldContainer = 'SearchFieldContainer';
1447
+ const SearchFieldError = 'SearchFieldError';
1448
+ const SearchHeader = 'SearchHeader';
1449
+ const SearchHeaderDetails = 'SearchHeaderDetails';
1450
+ const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1451
+ const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1452
+ const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1453
+ const SearchHeaderTop = 'SearchHeaderTop';
1454
+ const SearchHeaderTopRight = 'SearchHeaderTopRight';
1455
+ const SearchInputError = 'SearchInputError';
1456
+ const SearchRemove = 'SearchRemove';
1457
+ const SearchToggleButton = 'SearchToggleButton';
1458
+ const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1459
+ const SourceControlBadge = 'SourceControlBadge';
1460
+ const ToggleDetails = 'ToggleDetails';
1461
+ const Tree = 'Tree';
1462
+ const TreeItem = 'TreeItem';
1463
+ const TreeItemActive = 'TreeItemActive';
1464
+ const TreeItems$1 = 'TreeItems';
1465
+ const Viewlet = 'Viewlet';
1466
+ const ViewletSearchMessage = 'ViewletSearchMessage';
1467
+ const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1468
+
1469
+ const Button$1 = 1;
1470
+ const Div = 4;
1471
+ const Span = 8;
1472
+ const Text = 12;
1473
+ const Img = 17;
1474
+ const Ins = 20;
1475
+ const Del = 21;
1476
+ const H4 = 24;
1477
+ const TextArea = 62;
1478
+
1479
+ const Empty = 0;
1480
+ const FocusIgnoreFiles = 1012;
1481
+ const FocusSearch = 1013;
1482
+ const FocusSearchExcludeInput = 1008;
1483
+ const FocusSearchIncludeInput = 1007;
1484
+ const FocusSearchInput = 21;
1485
+ const FocusSearchMatchCase = 32;
1486
+ const FocusSearchOpenEditors = 1011;
1487
+ const FocusSearchPreserveCase = 36;
1488
+ const FocusSearchRegex = 33;
1489
+ const FocusSearchReplaceAll = 35;
1490
+ const FocusSearchReplaceInput = 31;
1491
+ const FocusSearchResults = 22;
1492
+ const FocusSearchWholeWord = 34;
1493
+ const FocusToggleDetails = 1010;
1494
+ const FocusToggleReplace = 1020;
1495
+
1453
1496
  const mergeClassNames = (...classNames) => {
1454
1497
  return classNames.filter(Boolean).join(' ');
1455
1498
  };
@@ -1667,39 +1710,154 @@ const diff$1 = (oldNodes, newNodes) => {
1667
1710
  });
1668
1711
  siblingOffset = 0;
1669
1712
  }
1670
- const count = getTotalChildCount(newNodes, j);
1671
- patches.push({
1672
- type: Add,
1673
- nodes: newNodes.slice(j, j + count)
1674
- });
1675
- j += count;
1713
+ const count = getTotalChildCount(newNodes, j);
1714
+ patches.push({
1715
+ type: Add,
1716
+ nodes: newNodes.slice(j, j + count)
1717
+ });
1718
+ j += count;
1719
+ }
1720
+ return patches;
1721
+ };
1722
+
1723
+ const User = 1;
1724
+ const Script = 2;
1725
+
1726
+ const clearSearchResults$1 = state => {
1727
+ return {
1728
+ ...state,
1729
+ focus: FocusSearchInput,
1730
+ focusSource: Script,
1731
+ inputSource: Script,
1732
+ items: [],
1733
+ limitHit: false,
1734
+ limitHitWarning: '',
1735
+ maxLineY: 0,
1736
+ message: '',
1737
+ minLineY: 0,
1738
+ replacement: '',
1739
+ searchInputErrorMessage: '',
1740
+ value: ''
1741
+ };
1742
+ };
1743
+
1744
+ const getFilePath = text => {
1745
+ // TODO make api stricter so that results always have the same shape
1746
+ if (text.startsWith('./')) {
1747
+ return text.slice(2);
1748
+ }
1749
+ return text;
1750
+ };
1751
+
1752
+ const getIconsCached = (dirents, fileIconCache) => {
1753
+ return dirents.map(dirent => {
1754
+ if (dirent.type === Match$1) {
1755
+ return '';
1756
+ }
1757
+ const path = getFilePath(dirent.text);
1758
+ return fileIconCache[path];
1759
+ });
1760
+ };
1761
+
1762
+ const getFileName = path => {
1763
+ const slashIndex = path.lastIndexOf('/');
1764
+ if (slashIndex === -1) {
1765
+ return path;
1766
+ }
1767
+ return path.slice(slashIndex + 1);
1768
+ };
1769
+
1770
+ const File = 1;
1771
+ const Match = 2;
1772
+
1773
+ const isFile = match => {
1774
+ return match.type === File;
1775
+ };
1776
+
1777
+ const getMissingDirents = (searchResults, fileIconCache) => {
1778
+ const missingDirents = [];
1779
+ const files = searchResults.filter(isFile);
1780
+ for (const file of files) {
1781
+ const uri = getFilePath(file.text);
1782
+ if (!(uri in fileIconCache)) {
1783
+ missingDirents.push(file);
1784
+ }
1676
1785
  }
1677
- return patches;
1786
+ return missingDirents;
1787
+ };
1788
+ const toIconRequest = item => {
1789
+ const filePath = getFilePath(item.text);
1790
+ const fileName = getFileName(filePath);
1791
+ return {
1792
+ name: fileName,
1793
+ path: filePath,
1794
+ type: File$2
1795
+ };
1796
+ };
1797
+ const getMissingIconRequests = (dirents, fileIconCache) => {
1798
+ const missingRequests = getMissingDirents(dirents, fileIconCache);
1799
+ const iconRequests = missingRequests.map(toIconRequest);
1800
+ return iconRequests;
1678
1801
  };
1679
1802
 
1680
- const User = 1;
1681
- const Script = 2;
1803
+ const Directory = 3;
1804
+ const DirectoryExpanded = 4;
1682
1805
 
1683
- const clearSearchResults$1 = state => {
1806
+ const getSimpleIconRequestType = direntType => {
1807
+ if (direntType === Directory || direntType === DirectoryExpanded) {
1808
+ return 2;
1809
+ }
1810
+ return 1;
1811
+ };
1812
+
1813
+ const toSimpleIconRequest = request => {
1684
1814
  return {
1685
- ...state,
1686
- focus: FocusSearchInput,
1687
- focusSource: Script,
1688
- inputSource: Script,
1689
- items: [],
1690
- limitHit: false,
1691
- limitHitWarning: '',
1692
- maxLineY: 0,
1693
- message: '',
1694
- minLineY: 0,
1695
- replacement: '',
1696
- searchInputErrorMessage: '',
1697
- value: ''
1815
+ name: request.name,
1816
+ type: getSimpleIconRequestType(request.type)
1698
1817
  };
1699
1818
  };
1700
1819
 
1701
- const File = 1;
1702
- const Match = 2;
1820
+ const requestFileIcons = async requests => {
1821
+ if (requests.length === 0) {
1822
+ return [];
1823
+ }
1824
+ const simpleRequests = requests.map(toSimpleIconRequest);
1825
+ const icons = await getIcons(simpleRequests);
1826
+ return icons;
1827
+ };
1828
+
1829
+ const updateIconCache = (iconCache, missingRequests, newIcons) => {
1830
+ if (missingRequests.length === 0) {
1831
+ return iconCache;
1832
+ }
1833
+ const newFileIconCache = {
1834
+ ...iconCache
1835
+ };
1836
+ for (let i = 0; i < missingRequests.length; i++) {
1837
+ const request = missingRequests[i];
1838
+ const icon = newIcons[i];
1839
+ newFileIconCache[request.path] = icon;
1840
+ }
1841
+ return newFileIconCache;
1842
+ };
1843
+
1844
+ const getFileIcons = async (items, fileIconCache) => {
1845
+ const missingRequests = getMissingIconRequests(items, fileIconCache);
1846
+ const newIcons = await requestFileIcons(missingRequests);
1847
+ const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
1848
+ const icons = getIconsCached(items, newFileIconCache);
1849
+ return {
1850
+ icons,
1851
+ newFileIconCache
1852
+ };
1853
+ };
1854
+
1855
+ // TODO optimize this function to return the minimum number
1856
+ // of visible items needed, e.g. when not scrolled 5 items with
1857
+ // 20px fill 100px but when scrolled 6 items are needed
1858
+ const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
1859
+ return Math.ceil(listHeight / itemHeight) + 1;
1860
+ };
1703
1861
 
1704
1862
  const getPaths = items => {
1705
1863
  const paths = [];
@@ -1712,15 +1870,30 @@ const getPaths = items => {
1712
1870
  };
1713
1871
  const collapseAll$1 = async state => {
1714
1872
  const {
1873
+ fileIconCache,
1874
+ headerHeight,
1875
+ height,
1876
+ itemHeight,
1715
1877
  items
1716
1878
  } = state;
1717
1879
  if (items.length === 0) {
1718
1880
  return state;
1719
1881
  }
1720
1882
  const paths = getPaths(items);
1883
+ const total = items.length;
1884
+ const listHeight = height - headerHeight;
1885
+ const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
1886
+ const maxLineY = Math.min(numberOfVisible, total);
1887
+ const visible = items.slice(0, maxLineY);
1888
+ const {
1889
+ icons,
1890
+ newFileIconCache
1891
+ } = await getFileIcons(visible, fileIconCache);
1721
1892
  return {
1722
1893
  ...state,
1723
- collapsedPaths: paths
1894
+ collapsedPaths: paths,
1895
+ fileIconCache: newFileIconCache,
1896
+ icons
1724
1897
  };
1725
1898
  };
1726
1899
 
@@ -1902,13 +2075,12 @@ const RenderIncludeValue = 5;
1902
2075
  const RenderExcludeValue = 6;
1903
2076
  const RenderFocusContext = 7;
1904
2077
  const RenderSelections = 8;
2078
+ const RenderIncremental = 9;
1905
2079
 
1906
- const diffType$5 = RenderExcludeValue;
1907
2080
  const isEqual$6 = (oldState, newState) => {
1908
2081
  return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
1909
2082
  };
1910
2083
 
1911
- const diffType$4 = RenderFocus;
1912
2084
  const isEqual$5 = (oldState, newState) => {
1913
2085
  return oldState.focus === newState.focus || newState.focusSource === User;
1914
2086
  };
@@ -1917,28 +2089,24 @@ const isEqual$4 = (oldState, newState) => {
1917
2089
  return oldState.focus === newState.focus && oldState.focused === newState.focused;
1918
2090
  };
1919
2091
 
1920
- const diffType$3 = RenderIncludeValue;
1921
2092
  const isEqual$3 = (oldState, newState) => {
1922
2093
  return oldState.includeValue === newState.includeValue || newState.inputSource === User;
1923
2094
  };
1924
2095
 
1925
- const diffType$2 = RenderItems;
1926
2096
  const isEqual$2 = (oldState, newState) => {
1927
2097
  return oldState.collapsedPaths === newState.collapsedPaths && oldState.deltaY === newState.deltaY && oldState.flags === newState.flags && oldState.focus === newState.focus && oldState.icons === newState.icons && oldState.items === newState.items && oldState.listFocused === newState.listFocused && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.loaded === newState.loaded && oldState.maxLineY === newState.maxLineY && oldState.message === newState.message && oldState.minLineY === newState.minLineY && oldState.replacement === newState.replacement && oldState.searchInputErrorMessage === newState.searchInputErrorMessage;
1928
2098
  };
1929
2099
 
1930
- const diffType$1 = RenderReplaceValue;
1931
2100
  const isEqual$1 = (oldState, newState) => {
1932
2101
  return oldState.replacement === newState.replacement || newState.inputSource === User;
1933
2102
  };
1934
2103
 
1935
- const diffType = RenderValue;
1936
2104
  const isEqual = (oldState, newState) => {
1937
2105
  return oldState.value === newState.value || newState.inputSource === User;
1938
2106
  };
1939
2107
 
1940
2108
  const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4];
1941
- const numbers = [diffType$2, diffType$4, diffType$3, diffType$5, diffType$1, diffType, RenderFocusContext];
2109
+ const numbers = [RenderItems, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext];
1942
2110
 
1943
2111
  const diff = (oldState, newState) => {
1944
2112
  const diffResult = [];
@@ -1960,114 +2128,6 @@ const diff2 = uid => {
1960
2128
  return diffResult;
1961
2129
  };
1962
2130
 
1963
- const getFilePath = text => {
1964
- // TODO make api stricter so that results always have the same shape
1965
- if (text.startsWith('./')) {
1966
- return text.slice(2);
1967
- }
1968
- return text;
1969
- };
1970
-
1971
- const getIconsCached = (dirents, fileIconCache) => {
1972
- return dirents.map(dirent => {
1973
- if (dirent.type === Match$1) {
1974
- return '';
1975
- }
1976
- const path = getFilePath(dirent.text);
1977
- return fileIconCache[path];
1978
- });
1979
- };
1980
-
1981
- const getFileName = path => {
1982
- const slashIndex = path.lastIndexOf('/');
1983
- if (slashIndex === -1) {
1984
- return path;
1985
- }
1986
- return path.slice(slashIndex + 1);
1987
- };
1988
-
1989
- const isFile = match => {
1990
- return match.type === File;
1991
- };
1992
-
1993
- const getMissingDirents = (searchResults, fileIconCache) => {
1994
- const missingDirents = [];
1995
- const files = searchResults.filter(isFile);
1996
- for (const file of files) {
1997
- const uri = getFilePath(file.text);
1998
- if (!(uri in fileIconCache)) {
1999
- missingDirents.push(file);
2000
- }
2001
- }
2002
- return missingDirents;
2003
- };
2004
- const toIconRequest = item => {
2005
- const filePath = getFilePath(item.text);
2006
- const fileName = getFileName(filePath);
2007
- return {
2008
- name: fileName,
2009
- path: filePath,
2010
- type: File$2
2011
- };
2012
- };
2013
- const getMissingIconRequests = (dirents, fileIconCache) => {
2014
- const missingRequests = getMissingDirents(dirents, fileIconCache);
2015
- const iconRequests = missingRequests.map(toIconRequest);
2016
- return iconRequests;
2017
- };
2018
-
2019
- const Directory = 3;
2020
- const DirectoryExpanded = 4;
2021
-
2022
- const getSimpleIconRequestType = direntType => {
2023
- if (direntType === Directory || direntType === DirectoryExpanded) {
2024
- return 2;
2025
- }
2026
- return 1;
2027
- };
2028
-
2029
- const toSimpleIconRequest = request => {
2030
- return {
2031
- name: request.name,
2032
- type: getSimpleIconRequestType(request.type)
2033
- };
2034
- };
2035
-
2036
- const requestFileIcons = async requests => {
2037
- if (requests.length === 0) {
2038
- return [];
2039
- }
2040
- const simpleRequests = requests.map(toSimpleIconRequest);
2041
- const icons = await getIcons(simpleRequests);
2042
- return icons;
2043
- };
2044
-
2045
- const updateIconCache = (iconCache, missingRequests, newIcons) => {
2046
- if (missingRequests.length === 0) {
2047
- return iconCache;
2048
- }
2049
- const newFileIconCache = {
2050
- ...iconCache
2051
- };
2052
- for (let i = 0; i < missingRequests.length; i++) {
2053
- const request = missingRequests[i];
2054
- const icon = newIcons[i];
2055
- newFileIconCache[request.path] = icon;
2056
- }
2057
- return newFileIconCache;
2058
- };
2059
-
2060
- const getFileIcons = async (items, fileIconCache) => {
2061
- const missingRequests = getMissingIconRequests(items, fileIconCache);
2062
- const newIcons = await requestFileIcons(missingRequests);
2063
- const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
2064
- const icons = getIconsCached(items, newFileIconCache);
2065
- return {
2066
- icons,
2067
- newFileIconCache
2068
- };
2069
- };
2070
-
2071
2131
  const getNewMinMax = (newItemsLength, minLineY, maxLineY, deltaY, itemHeight) => {
2072
2132
  if (maxLineY > newItemsLength) {
2073
2133
  const diff = maxLineY - minLineY;
@@ -2807,7 +2867,7 @@ const getMenuEntriesList = (state, props) => {
2807
2867
  };
2808
2868
 
2809
2869
  const getMenuEntries = (state, props) => {
2810
- if (props.menuId === Search$1) {
2870
+ if (props.menuId === Search$2) {
2811
2871
  return getMenuEntriesList(state, props);
2812
2872
  }
2813
2873
  if (props.menuId === InputContextMenu) {
@@ -2817,7 +2877,7 @@ const getMenuEntries = (state, props) => {
2817
2877
  };
2818
2878
 
2819
2879
  const getMenuEntryIds = () => {
2820
- return [Search$1, InputContextMenu];
2880
+ return [Search$2, InputContextMenu];
2821
2881
  };
2822
2882
 
2823
2883
  const ClearAll$1 = 'ClearAll';
@@ -2887,13 +2947,6 @@ const handleUpdateError = async (state, update, error) => {
2887
2947
  };
2888
2948
  };
2889
2949
 
2890
- // TODO optimize this function to return the minimum number
2891
- // of visible items needed, e.g. when not scrolled 5 items with
2892
- // 20px fill 100px but when scrolled 6 items are needed
2893
- const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
2894
- return Math.ceil(listHeight / itemHeight) + 1;
2895
- };
2896
-
2897
2950
  const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
2898
2951
  const getProtocol = uri => {
2899
2952
  const protocolMatch = uri.match(RE_PROTOCOL);
@@ -3050,11 +3103,6 @@ const getRipGrepArgs = ({
3050
3103
  return ripGrepArgs;
3051
3104
  };
3052
3105
 
3053
- const {
3054
- invoke,
3055
- setFactory
3056
- } = createLazyRpc(SearchProcess);
3057
-
3058
3106
  const waitForNextFrame = async () => {
3059
3107
  const {
3060
3108
  promise,
@@ -3801,11 +3849,11 @@ const launchIconThemeWorker = async () => {
3801
3849
 
3802
3850
  const initializeIconThemeWorker = async () => {
3803
3851
  const rpc = await launchIconThemeWorker();
3804
- set$2(rpc);
3852
+ set$3(rpc);
3805
3853
  };
3806
3854
 
3807
3855
  const launchSearchProcessElectron = async () => {
3808
- const rpc = await TransferMessagePortRpcParent.create({
3856
+ const rpc = await LazyTransferMessagePortRpcParent.create({
3809
3857
  commandMap: {},
3810
3858
  send: sendMessagePortToSearchProcess
3811
3859
  });
@@ -3813,7 +3861,7 @@ const launchSearchProcessElectron = async () => {
3813
3861
  };
3814
3862
 
3815
3863
  const launchSearchProcessNode = async () => {
3816
- const rpc = await WebSocketRpcParent2.create({
3864
+ const rpc = await LazyWebSocketRpcParent2.create({
3817
3865
  commandMap: {},
3818
3866
  // @ts-ignore
3819
3867
  type: 'search-process'
@@ -3821,16 +3869,18 @@ const launchSearchProcessNode = async () => {
3821
3869
  return rpc;
3822
3870
  };
3823
3871
 
3824
- const setSearchProcessFactory = platform => {
3872
+ const initializeSearchProcess = async platform => {
3825
3873
  if (platform === Electron) {
3826
- setFactory(launchSearchProcessElectron);
3874
+ const rpc = await launchSearchProcessElectron();
3875
+ set$1(rpc);
3827
3876
  } else if (platform === Remote) {
3828
- setFactory(launchSearchProcessNode);
3877
+ const rpc = await launchSearchProcessNode();
3878
+ set$1(rpc);
3829
3879
  }
3830
3880
  };
3881
+
3831
3882
  const initialize = async platform => {
3832
- setSearchProcessFactory(platform);
3833
- await initializeIconThemeWorker();
3883
+ await Promise.all([initializeSearchProcess(platform), initializeIconThemeWorker()]);
3834
3884
  };
3835
3885
 
3836
3886
  // TODO optimize this function to return the minimum number
@@ -4531,7 +4581,7 @@ const renderFocus = (oldState, newState) => {
4531
4581
  };
4532
4582
 
4533
4583
  const renderFocusContext = (oldState, newState) => {
4534
- return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
4584
+ return [SetFocusContext, newState.uid, FocusSearch$1, newState.focus];
4535
4585
  };
4536
4586
 
4537
4587
  const None = 0;
@@ -4701,7 +4751,7 @@ const getSearchDetailsToggleVirtualDom = () => {
4701
4751
  role: Button$3,
4702
4752
  tabIndex: 0,
4703
4753
  title: toggleSearchDetails(),
4704
- type: Button$2
4754
+ type: Button$1
4705
4755
  }, {
4706
4756
  childCount: 0,
4707
4757
  className: mergeClassNames(MaskIcon, MaskIconEllipsis),
@@ -4821,7 +4871,7 @@ const getSearchFieldButtonVirtualDom = button => {
4821
4871
  role,
4822
4872
  tabIndex: 0,
4823
4873
  title,
4824
- type: Button$2
4874
+ type: Button$1
4825
4875
  }, {
4826
4876
  childCount: 0,
4827
4877
  className: mergeClassNames(MaskIcon, icon),
@@ -4998,7 +5048,7 @@ const getSearchToggleVirtualDom = replaceExpanded => {
4998
5048
  name: ToggleReplace,
4999
5049
  onClick: HandleButtonClick,
5000
5050
  title: toggleReplace$1(),
5001
- type: Button$2
5051
+ type: Button$1
5002
5052
  }, {
5003
5053
  childCount: 0,
5004
5054
  className: mergeClassNames(MaskIcon, replaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
@@ -5213,7 +5263,7 @@ const getSearchRemoveVirtualDom = () => {
5213
5263
  className: SearchRemove,
5214
5264
  name: Remove,
5215
5265
  title,
5216
- type: Button$2
5266
+ type: Button$1
5217
5267
  }, closeIcon];
5218
5268
  return dom;
5219
5269
  };
@@ -5292,7 +5342,7 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
5292
5342
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
5293
5343
  };
5294
5344
 
5295
- const className = mergeClassNames(Viewlet, Search$2);
5345
+ const className = mergeClassNames(Viewlet, Search$1);
5296
5346
  const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0) => {
5297
5347
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
5298
5348
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
@@ -5309,6 +5359,14 @@ const renderItems = (oldState, newState) => {
5309
5359
  return [SetDom2, newState.uid, dom];
5310
5360
  };
5311
5361
 
5362
+ // TODO cache rendered dom so that it can be used for dom diffing
5363
+ const renderIncremental = (oldState, newState) => {
5364
+ const oldDom = renderItems(oldState, oldState);
5365
+ const newDom = renderItems(newState, newState);
5366
+ const patches = diff$1(oldDom, newDom);
5367
+ return patches;
5368
+ };
5369
+
5312
5370
  const renderSelections = (oldState, newState) => {
5313
5371
  // const { selections, uid } = newState
5314
5372
 
@@ -5339,6 +5397,8 @@ const getRenderer = diffType => {
5339
5397
  return renderFocusContext;
5340
5398
  case RenderIncludeValue:
5341
5399
  return renderIncludeValue;
5400
+ case RenderIncremental:
5401
+ return renderIncremental;
5342
5402
  case RenderItems:
5343
5403
  return renderItems;
5344
5404
  case RenderReplaceValue:
@@ -5401,7 +5461,7 @@ const getActionButtonVirtualDom = action => {
5401
5461
  className,
5402
5462
  name: id,
5403
5463
  title: label,
5404
- type: Button$2
5464
+ type: Button$1
5405
5465
  }, getIconVirtualDom(icon)];
5406
5466
  };
5407
5467
 
@@ -5498,7 +5558,7 @@ const renderEventListeners = () => {
5498
5558
  params: ['handleClickAt', ClientX, ClientY, TargetName]
5499
5559
  }, {
5500
5560
  name: HandleListPointerDown,
5501
- params: ['handleListPointerDown', Button$1, TargetName]
5561
+ params: ['handleListPointerDown', Button$2, TargetName]
5502
5562
  }, {
5503
5563
  name: HandleToggleButtonClick,
5504
5564
  params: ['handleToggleButtonClick']
@@ -5510,11 +5570,11 @@ const renderEventListeners = () => {
5510
5570
  params: ['handleListBlur']
5511
5571
  }, {
5512
5572
  name: HandleListContextMenu,
5513
- params: ['handleContextMenu', Button$1, ClientX, ClientY],
5573
+ params: ['handleContextMenu', Button$2, ClientX, ClientY],
5514
5574
  preventDefault: true
5515
5575
  }, {
5516
5576
  name: HandleInputContextMenu,
5517
- params: ['handleInputContextMenu', TargetName, Button$1, ClientX, ClientY],
5577
+ params: ['handleInputContextMenu', TargetName, Button$2, ClientX, ClientY],
5518
5578
  preventDefault: true
5519
5579
  }, {
5520
5580
  name: HandleActionClick,
@@ -5551,18 +5611,6 @@ const renderEventListeners = () => {
5551
5611
  }];
5552
5612
  };
5553
5613
 
5554
- // TODO cache rendered dom so that it can be used for dom diffing
5555
- const renderIncremental = uid => {
5556
- const {
5557
- newState,
5558
- oldState
5559
- } = get$1(uid);
5560
- const oldDom = renderItems(oldState, oldState);
5561
- const newDom = renderItems(newState, newState);
5562
- const patches = diff$1(oldDom, newDom);
5563
- return patches;
5564
- };
5565
-
5566
5614
  const prompt = (text, options) => {
5567
5615
  return invoke$1('ConfirmPrompt.prompt', text, options);
5568
5616
  };
@@ -5734,10 +5782,10 @@ const handleContextMenuKeyboard = async state => {
5734
5782
  x,
5735
5783
  y
5736
5784
  } = state; // TODO
5737
- await show2(uid, Search$1, x, y, {
5785
+ await show2(uid, Search$2, x, y, {
5738
5786
  index: 0,
5739
5787
  // TODO pass proper index
5740
- menuId: Search$1
5788
+ menuId: Search$2
5741
5789
  });
5742
5790
  return state;
5743
5791
  };
@@ -5763,9 +5811,9 @@ const handleContextMenuMouseAt = async (state, eventX, eventY) => {
5763
5811
  focusedIndex: index,
5764
5812
  listFocusedIndex: index
5765
5813
  });
5766
- await show2(uid, Search$1, x, y, {
5814
+ await show2(uid, Search$2, x, y, {
5767
5815
  index,
5768
- menuId: Search$1
5816
+ menuId: Search$2
5769
5817
  });
5770
5818
  return state;
5771
5819
  };
@@ -5991,7 +6039,7 @@ const listen = async () => {
5991
6039
  const rpc = await WebWorkerRpcClient.create({
5992
6040
  commandMap: commandMap
5993
6041
  });
5994
- set$1(rpc);
6042
+ set$2(rpc);
5995
6043
  };
5996
6044
 
5997
6045
  const main = async () => {