@lvce-editor/text-search-worker 5.0.0 → 5.2.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.
@@ -60,49 +60,57 @@ class AssertionError extends Error {
60
60
  this.name = 'AssertionError';
61
61
  }
62
62
  }
63
+ const Object$1 = 1;
64
+ const Number$1 = 2;
65
+ const Array$1 = 3;
66
+ const String = 4;
67
+ const Boolean$1 = 5;
68
+ const Function = 6;
69
+ const Null = 7;
70
+ const Unknown = 8;
63
71
  const getType = value => {
64
72
  switch (typeof value) {
65
73
  case 'number':
66
- return 'number';
74
+ return Number$1;
67
75
  case 'function':
68
- return 'function';
76
+ return Function;
69
77
  case 'string':
70
- return 'string';
78
+ return String;
71
79
  case 'object':
72
80
  if (value === null) {
73
- return 'null';
81
+ return Null;
74
82
  }
75
83
  if (Array.isArray(value)) {
76
- return 'array';
84
+ return Array$1;
77
85
  }
78
- return 'object';
86
+ return Object$1;
79
87
  case 'boolean':
80
- return 'boolean';
88
+ return Boolean$1;
81
89
  default:
82
- return 'unknown';
90
+ return Unknown;
83
91
  }
84
92
  };
85
93
  const object = value => {
86
94
  const type = getType(value);
87
- if (type !== 'object') {
95
+ if (type !== Object$1) {
88
96
  throw new AssertionError('expected value to be of type object');
89
97
  }
90
98
  };
91
99
  const number = value => {
92
100
  const type = getType(value);
93
- if (type !== 'number') {
101
+ if (type !== Number$1) {
94
102
  throw new AssertionError('expected value to be of type number');
95
103
  }
96
104
  };
97
105
  const array = value => {
98
106
  const type = getType(value);
99
- if (type !== 'array') {
107
+ if (type !== Array$1) {
100
108
  throw new AssertionError('expected value to be of type array');
101
109
  }
102
110
  };
103
111
  const string = value => {
104
112
  const type = getType(value);
105
- if (type !== 'string') {
113
+ if (type !== String) {
106
114
  throw new AssertionError('expected value to be of type string');
107
115
  }
108
116
  };
@@ -538,7 +546,7 @@ const waitForWebSocketToBeOpen = webSocket => {
538
546
  error: Error$3
539
547
  });
540
548
  };
541
- const create$6 = async ({
549
+ const create$7 = async ({
542
550
  webSocket
543
551
  }) => {
544
552
  const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
@@ -575,7 +583,7 @@ const wrap = webSocket => {
575
583
  };
576
584
  const IpcParentWithWebSocket$1 = {
577
585
  __proto__: null,
578
- create: create$6,
586
+ create: create$7,
579
587
  wrap
580
588
  };
581
589
 
@@ -588,32 +596,32 @@ const create$4$1 = (method, params) => {
588
596
  };
589
597
  };
590
598
  const callbacks = Object.create(null);
591
- const set$4 = (id, fn) => {
599
+ const set$2 = (id, fn) => {
592
600
  callbacks[id] = fn;
593
601
  };
594
- const get$2 = id => {
602
+ const get$3 = id => {
595
603
  return callbacks[id];
596
604
  };
597
605
  const remove$1 = id => {
598
606
  delete callbacks[id];
599
607
  };
600
608
  let id = 0;
601
- const create$3$1 = () => {
609
+ const create$3$2 = () => {
602
610
  return ++id;
603
611
  };
604
612
  const registerPromise = () => {
605
- const id = create$3$1();
613
+ const id = create$3$2();
606
614
  const {
607
615
  resolve,
608
616
  promise
609
617
  } = Promise.withResolvers();
610
- set$4(id, resolve);
618
+ set$2(id, resolve);
611
619
  return {
612
620
  id,
613
621
  promise
614
622
  };
615
623
  };
616
- const create$2$1 = (method, params) => {
624
+ const create$2$2 = (method, params) => {
617
625
  const {
618
626
  id,
619
627
  promise
@@ -771,7 +779,7 @@ const warn = (...args) => {
771
779
  console.warn(...args);
772
780
  };
773
781
  const resolve = (id, response) => {
774
- const fn = get$2(id);
782
+ const fn = get$3(id);
775
783
  if (!fn) {
776
784
  console.log(response);
777
785
  warn(`callback ${id} may already be disposed`);
@@ -821,7 +829,7 @@ const getErrorProperty = (error, prettyError) => {
821
829
  }
822
830
  };
823
831
  };
824
- const create$1$2 = (id, error) => {
832
+ const create$1$1 = (id, error) => {
825
833
  return {
826
834
  jsonrpc: Two,
827
835
  id,
@@ -832,9 +840,9 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
832
840
  const prettyError = preparePrettyError(error);
833
841
  logError(error, prettyError);
834
842
  const errorProperty = getErrorProperty(error, prettyError);
835
- return create$1$2(id, errorProperty);
843
+ return create$1$1(id, errorProperty);
836
844
  };
837
- const create$5 = (message, result) => {
845
+ const create$6 = (message, result) => {
838
846
  return {
839
847
  jsonrpc: Two,
840
848
  id: message.id,
@@ -843,7 +851,7 @@ const create$5 = (message, result) => {
843
851
  };
844
852
  const getSuccessResponse = (message, result) => {
845
853
  const resultProperty = result ?? null;
846
- return create$5(message, resultProperty);
854
+ return create$6(message, resultProperty);
847
855
  };
848
856
  const getErrorResponseSimple = (id, error) => {
849
857
  return {
@@ -938,7 +946,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
938
946
  const {
939
947
  message,
940
948
  promise
941
- } = create$2$1(method, params);
949
+ } = create$2$2(method, params);
942
950
  if (useSendAndTransfer && ipc.sendAndTransfer) {
943
951
  ipc.sendAndTransfer(message);
944
952
  } else {
@@ -954,7 +962,7 @@ const send = (transport, method, ...params) => {
954
962
  const invoke$2 = (ipc, method, ...params) => {
955
963
  return invokeHelper(ipc, method, params, false);
956
964
  };
957
- const invokeAndTransfer$1 = (ipc, method, ...params) => {
965
+ const invokeAndTransfer = (ipc, method, ...params) => {
958
966
  return invokeHelper(ipc, method, params, true);
959
967
  };
960
968
 
@@ -987,7 +995,7 @@ const createRpc = ipc => {
987
995
  return invoke$2(ipc, method, ...params);
988
996
  },
989
997
  invokeAndTransfer(method, ...params) {
990
- return invokeAndTransfer$1(ipc, method, ...params);
998
+ return invokeAndTransfer(ipc, method, ...params);
991
999
  },
992
1000
  async dispose() {
993
1001
  await ipc?.dispose();
@@ -1025,27 +1033,41 @@ const listen$1 = async (module, options) => {
1025
1033
  const ipc = module.wrap(rawIpc);
1026
1034
  return ipc;
1027
1035
  };
1028
- const create$9 = async ({
1036
+ const create$5 = async ({
1029
1037
  commandMap,
1030
- messagePort,
1031
- isMessagePortOpen
1038
+ messagePort
1032
1039
  }) => {
1033
1040
  // TODO create a commandMap per rpc instance
1034
1041
  register(commandMap);
1035
1042
  const rawIpc = await IpcParentWithMessagePort$1.create({
1036
1043
  messagePort,
1037
- isMessagePortOpen
1044
+ isMessagePortOpen: true
1038
1045
  });
1039
1046
  const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1040
1047
  handleIpc(ipc);
1041
1048
  const rpc = createRpc(ipc);
1049
+ messagePort.start();
1042
1050
  return rpc;
1043
1051
  };
1044
- const MessagePortRpcParent = {
1052
+ const create$3$1 = async ({
1053
+ commandMap,
1054
+ send
1055
+ }) => {
1056
+ const {
1057
+ port1,
1058
+ port2
1059
+ } = new MessageChannel();
1060
+ await send(port1);
1061
+ return create$5({
1062
+ commandMap,
1063
+ messagePort: port2
1064
+ });
1065
+ };
1066
+ const TransferMessagePortRpcParent = {
1045
1067
  __proto__: null,
1046
- create: create$9
1068
+ create: create$3$1
1047
1069
  };
1048
- const create$1$1 = async ({
1070
+ const create$2$1 = async ({
1049
1071
  commandMap,
1050
1072
  webSocket
1051
1073
  }) => {
@@ -1061,7 +1083,7 @@ const create$1$1 = async ({
1061
1083
  };
1062
1084
  const WebSocketRpcParent = {
1063
1085
  __proto__: null,
1064
- create: create$1$1
1086
+ create: create$2$1
1065
1087
  };
1066
1088
  const create$4 = async ({
1067
1089
  commandMap
@@ -1078,6 +1100,68 @@ const WebWorkerRpcClient = {
1078
1100
  create: create$4
1079
1101
  };
1080
1102
 
1103
+ const create$3 = () => {
1104
+ const states = Object.create(null);
1105
+ return {
1106
+ get(uid) {
1107
+ return states[uid];
1108
+ },
1109
+ set(uid, oldState, newState) {
1110
+ states[uid] = {
1111
+ oldState,
1112
+ newState
1113
+ };
1114
+ },
1115
+ dispose(uid) {
1116
+ delete states[uid];
1117
+ },
1118
+ getKeys() {
1119
+ return Object.keys(states).map(key => {
1120
+ return Number.parseInt(key);
1121
+ });
1122
+ },
1123
+ clear() {
1124
+ for (const key of Object.keys(states)) {
1125
+ delete states[key];
1126
+ }
1127
+ },
1128
+ wrapCommand(fn) {
1129
+ const wrapped = async (uid, ...args) => {
1130
+ const {
1131
+ newState
1132
+ } = states[uid];
1133
+ const newerState = await fn(newState, ...args);
1134
+ if (newState === newerState) {
1135
+ return;
1136
+ }
1137
+ const latest = states[uid];
1138
+ states[uid] = {
1139
+ oldState: latest.oldState,
1140
+ newState: newerState
1141
+ };
1142
+ };
1143
+ return wrapped;
1144
+ },
1145
+ diff(uid, modules, numbers) {
1146
+ const {
1147
+ oldState,
1148
+ newState
1149
+ } = states[uid];
1150
+ const diffResult = [];
1151
+ for (let i = 0; i < modules.length; i++) {
1152
+ const fn = modules[i];
1153
+ if (!fn(oldState, newState)) {
1154
+ diffResult.push(numbers[i]);
1155
+ }
1156
+ }
1157
+ return diffResult;
1158
+ }
1159
+ };
1160
+ };
1161
+ const terminate = () => {
1162
+ globalThis.close();
1163
+ };
1164
+
1081
1165
  const User = 1;
1082
1166
  const Script = 2;
1083
1167
 
@@ -1144,23 +1228,23 @@ const rpcs = Object.create(null);
1144
1228
  const set$g = (id, rpc) => {
1145
1229
  rpcs[id] = rpc;
1146
1230
  };
1147
- const get$1 = id => {
1231
+ const get$2 = id => {
1148
1232
  return rpcs[id];
1149
1233
  };
1150
1234
 
1151
1235
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
1152
1236
 
1153
- const create$3 = rpcId => {
1237
+ const create$2 = rpcId => {
1154
1238
  return {
1155
1239
  // @ts-ignore
1156
1240
  invoke(method, ...params) {
1157
- const rpc = get$1(rpcId);
1241
+ const rpc = get$2(rpcId);
1158
1242
  // @ts-ignore
1159
1243
  return rpc.invoke(method, ...params);
1160
1244
  },
1161
1245
  // @ts-ignore
1162
1246
  invokeAndTransfer(method, ...params) {
1163
- const rpc = get$1(rpcId);
1247
+ const rpc = get$2(rpcId);
1164
1248
  // @ts-ignore
1165
1249
  return rpc.invokeAndTransfer(method, ...params);
1166
1250
  },
@@ -1168,7 +1252,7 @@ const create$3 = rpcId => {
1168
1252
  set$g(rpcId, rpc);
1169
1253
  },
1170
1254
  async dispose() {
1171
- const rpc = get$1(rpcId);
1255
+ const rpc = get$2(rpcId);
1172
1256
  await rpc.dispose();
1173
1257
  }
1174
1258
  };
@@ -1179,26 +1263,68 @@ const RpcId = {
1179
1263
  __proto__: null,
1180
1264
  SearchProcess: SearchProcess$1};
1181
1265
  const {
1182
- invoke: invoke$4,
1266
+ invoke: invoke$3,
1183
1267
  invokeAndTransfer: invokeAndTransfer$3,
1184
- set: set$3} = create$3(RendererWorker$1);
1268
+ set: set$3} = create$2(RendererWorker$1);
1269
+ const showContextMenu$1 = async (x, y, id, ...args) => {
1270
+ return invoke$3('ContextMenu.show', x, y, id, ...args);
1271
+ };
1272
+ const getFileIcon$2 = async options => {
1273
+ return invoke$3('IconTheme.getFileIcon', options);
1274
+ };
1275
+ const sendMessagePortToSearchProcess$1 = async port => {
1276
+ await invokeAndTransfer$3('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
1277
+ };
1278
+ const writeClipBoardText$1 = async text => {
1279
+ await invoke$3('ClipBoard.writeText', /* text */text);
1280
+ };
1281
+ const openUri$2 = async (uri, focus, options) => {
1282
+ await invoke$3('Main.openUri', uri, focus, options);
1283
+ };
1185
1284
  const RendererWorker = {
1186
1285
  __proto__: null,
1187
- invoke: invoke$4,
1188
- invokeAndTransfer: invokeAndTransfer$3,
1189
- set: set$3
1286
+ getFileIcon: getFileIcon$2,
1287
+ invoke: invoke$3,
1288
+ openUri: openUri$2,
1289
+ sendMessagePortToSearchProcess: sendMessagePortToSearchProcess$1,
1290
+ set: set$3,
1291
+ showContextMenu: showContextMenu$1,
1292
+ writeClipBoardText: writeClipBoardText$1
1190
1293
  };
1191
- const {
1192
- set: set$2$1} = create$3(SearchProcess$1);
1193
- const SearchProcess = {
1194
- __proto__: null,
1195
- set: set$2$1
1294
+ const createLazyRpc = rpcId => {
1295
+ let rpcPromise;
1296
+ let factory;
1297
+ const createRpc = async () => {
1298
+ const rpc = await factory();
1299
+ set$g(rpcId, rpc);
1300
+ };
1301
+ const ensureRpc = async () => {
1302
+ if (!rpcPromise) {
1303
+ rpcPromise = createRpc();
1304
+ }
1305
+ await rpcPromise;
1306
+ };
1307
+ return {
1308
+ setFactory(value) {
1309
+ factory = value;
1310
+ },
1311
+ async invoke(method, ...params) {
1312
+ await ensureRpc();
1313
+ const rpc = get$2(rpcId);
1314
+ return rpc.invoke(method, ...params);
1315
+ }
1316
+ };
1196
1317
  };
1197
1318
 
1198
1319
  const {
1320
+ getFileIcon: getFileIcon$1,
1199
1321
  invoke: invoke$1,
1200
- invokeAndTransfer,
1201
- set: set$2} = RendererWorker;
1322
+ openUri: openUri$1,
1323
+ sendMessagePortToSearchProcess,
1324
+ set: set$1,
1325
+ showContextMenu,
1326
+ writeClipBoardText
1327
+ } = RendererWorker;
1202
1328
 
1203
1329
  const copy = async state => {
1204
1330
  const {
@@ -1209,76 +1335,17 @@ const copy = async state => {
1209
1335
  return state;
1210
1336
  }
1211
1337
  const item = items[listFocusedIndex];
1212
- await invoke$1('ClipBoard.writeText', item.text);
1338
+ await writeClipBoardText(item.text);
1213
1339
  return state;
1214
1340
  };
1215
1341
 
1216
1342
  const minimumSliderSize = 20;
1217
1343
 
1218
- const create$2 = () => {
1219
- const states = Object.create(null);
1220
- return {
1221
- get(uid) {
1222
- return states[uid];
1223
- },
1224
- set(uid, oldState, newState) {
1225
- states[uid] = {
1226
- oldState,
1227
- newState
1228
- };
1229
- },
1230
- dispose(uid) {
1231
- delete states[uid];
1232
- },
1233
- getKeys() {
1234
- return Object.keys(states).map(key => {
1235
- return Number.parseInt(key);
1236
- });
1237
- },
1238
- clear() {
1239
- for (const key of Object.keys(states)) {
1240
- delete states[key];
1241
- }
1242
- },
1243
- wrapCommand(fn) {
1244
- const wrapped = async (uid, ...args) => {
1245
- const {
1246
- newState
1247
- } = states[uid];
1248
- const newerState = await fn(newState, ...args);
1249
- if (newState === newerState) {
1250
- return;
1251
- }
1252
- const latest = states[uid];
1253
- states[uid] = {
1254
- oldState: latest.oldState,
1255
- newState: newerState
1256
- };
1257
- };
1258
- return wrapped;
1259
- },
1260
- diff(uid, modules, numbers) {
1261
- const {
1262
- oldState,
1263
- newState
1264
- } = states[uid];
1265
- const diffResult = [];
1266
- for (let i = 0; i < modules.length; i++) {
1267
- const fn = modules[i];
1268
- if (!fn(oldState, newState)) {
1269
- diffResult.push(numbers[i]);
1270
- }
1271
- }
1272
- return diffResult;
1273
- }
1274
- };
1275
- };
1276
-
1277
1344
  const {
1278
- get,
1279
- set: set$1,
1345
+ get: get$1,
1346
+ set,
1280
1347
  wrapCommand
1281
- } = create$2();
1348
+ } = create$3();
1282
1349
 
1283
1350
  const List$1 = 1;
1284
1351
 
@@ -1353,7 +1420,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
1353
1420
  incrementalSearch: false,
1354
1421
  searchId: ''
1355
1422
  };
1356
- set$1(uid, state, state);
1423
+ set(uid, state, state);
1357
1424
  return state;
1358
1425
  };
1359
1426
 
@@ -1417,7 +1484,7 @@ const diff2 = uid => {
1417
1484
  const {
1418
1485
  oldState,
1419
1486
  newState
1420
- } = get(uid);
1487
+ } = get$1(uid);
1421
1488
  const diffResult = diff$1(oldState, newState);
1422
1489
  return diffResult;
1423
1490
  };
@@ -2010,7 +2077,7 @@ const handleUpdateError = async (state, update, error) => {
2010
2077
 
2011
2078
  const getFileIcon = async result => {
2012
2079
  if (result.type === File) {
2013
- return invoke$1('IconTheme.getFileIcon', {
2080
+ return getFileIcon$1({
2014
2081
  name: result.text
2015
2082
  });
2016
2083
  }
@@ -2070,142 +2137,23 @@ const getScrollBarOffset$1 = (delta, finalDelta, size, scrollBarSize) => {
2070
2137
  };
2071
2138
  const getScrollBarY$1 = getScrollBarOffset$1;
2072
2139
 
2073
- const textSearch$6 = async (scheme, root, query) => {
2074
- string(scheme);
2075
- string(query);
2076
- const result = await invoke$1('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
2077
- return result;
2078
- };
2079
-
2080
- const textSearch$5 = async (scheme, root, query, options, assetDir) => {
2081
- return invoke$1('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
2082
- };
2083
-
2084
- const textSearch$4 = async (scheme, root, query) => {
2085
- return invoke$1('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
2086
- };
2087
-
2088
- const textSearch$3 = async (scheme, root, query, options, assetDir) => {
2089
- return invoke$1('ExtensionHostTextSearch.textSearchMemory', scheme, root, query, options, assetDir);
2090
- };
2091
-
2092
- const getRipGrepArgs = ({
2093
- threads,
2094
- isCaseSensitive,
2095
- searchString,
2096
- useRegularExpression
2097
- }) => {
2098
- const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json'];
2099
- ripGrepArgs.push('--threads', `${threads}`);
2100
- if (isCaseSensitive) {
2101
- ripGrepArgs.push('--case-sensitive');
2102
- } else {
2103
- ripGrepArgs.push('--ignore-case');
2104
- }
2105
- if (useRegularExpression) {
2106
- ripGrepArgs.push('--regexp', searchString);
2107
- } else {
2108
- ripGrepArgs.push('--fixed-strings');
2109
- ripGrepArgs.push('--');
2110
- ripGrepArgs.push(searchString);
2111
- }
2112
- ripGrepArgs.push('.');
2113
- return ripGrepArgs;
2114
- };
2115
-
2116
- const Electron = 2;
2117
- const Remote = 3;
2118
-
2119
- const createLazyRpc = rpcId => {
2120
- let rpcPromise;
2121
- let factory;
2122
- const createRpc = async () => {
2123
- const rpc = await factory();
2124
- set$g(rpcId, rpc);
2125
- };
2126
- const ensureRpc = async () => {
2127
- if (!rpcPromise) {
2128
- rpcPromise = createRpc();
2129
- }
2130
- await rpcPromise;
2131
- };
2132
- return {
2133
- setFactory(value) {
2134
- factory = value;
2135
- },
2136
- async invoke(method, ...params) {
2137
- await ensureRpc();
2138
- const rpc = get$1(rpcId);
2139
- return rpc.invoke(method, ...params);
2140
- }
2141
- };
2140
+ const providers = Object.create(null);
2141
+ const add = providerMap => {
2142
+ Object.assign(providers, providerMap);
2142
2143
  };
2143
-
2144
- const {
2145
- set} = SearchProcess;
2146
- const {
2147
- invoke,
2148
- setFactory
2149
- } = createLazyRpc(RpcId.SearchProcess);
2150
-
2151
- const textSearch$2 = async (scheme, root, query, options, assetDir, platform) => {
2152
- const ripGrepArgs = getRipGrepArgs({
2153
- ...options,
2154
- searchString: query
2155
- });
2156
- const actualOptions = {
2157
- ripGrepArgs,
2158
- searchDir: root
2159
- };
2160
- if (platform === Remote || platform === Electron) {
2161
- const result = await invoke('TextSearch.search', actualOptions);
2162
- // TODO api is weird
2163
- // @ts-ignore
2164
- return result.results;
2165
- }
2166
- const results = await invoke$1('SearchProcess.invoke', 'TextSearch.search', actualOptions);
2167
- // TODO api is weird
2168
- return results.results;
2144
+ const get = protocol => {
2145
+ return providers[protocol] || providers['default'];
2169
2146
  };
2170
2147
 
2171
- const textSearch$1 = async (scheme, root, query) => {
2172
- // TODO ask renderer worker for files
2173
- const entries = Object.entries({});
2174
- const results = [];
2175
- for (const [key, value] of entries) {
2176
- // @ts-ignore
2177
- if (value.includes(query)) {
2178
- results.push([key, [{
2179
- absoluteOffset: 0,
2180
- preview: value
2181
- }]]);
2182
- }
2183
- }
2184
- return results;
2148
+ const getTextSearchProvider = scheme => {
2149
+ return get(scheme);
2185
2150
  };
2186
2151
 
2187
- const getProvider = scheme => {
2188
- switch (scheme) {
2189
- case '':
2190
- return textSearch$2;
2191
- case 'web':
2192
- return textSearch$1;
2193
- case 'fetch':
2194
- return textSearch$5;
2195
- case 'html':
2196
- return textSearch$4;
2197
- case 'memfs':
2198
- return textSearch$3;
2199
- default:
2200
- return textSearch$6;
2201
- }
2202
- };
2203
-
2204
- const textSearch = async (root, query, options, assetDir, platform) => {
2152
+ const textSearch$6 = async (root, query, options, assetDir, platform) => {
2205
2153
  string(root);
2206
2154
  string(query);
2207
2155
  const scheme = getProtocol$1(root);
2208
- const provider = getProvider(scheme);
2156
+ const provider = getTextSearchProvider(scheme);
2209
2157
  const results = await provider(scheme, root, query, options, assetDir, platform);
2210
2158
  return results;
2211
2159
  };
@@ -2224,23 +2172,25 @@ const handleUpdateFull = async (state, update) => {
2224
2172
  value,
2225
2173
  threads,
2226
2174
  includeValue,
2227
- excludeValue
2175
+ excludeValue,
2176
+ assetDir,
2177
+ platform
2228
2178
  } = partialNewState;
2229
2179
  const root = state.workspacePath;
2230
2180
  const scheme = getProtocol$1(root);
2231
- const results = await textSearch(root, value, {
2181
+ const results = await textSearch$6(root, value, {
2232
2182
  threads,
2233
2183
  isCaseSensitive: Boolean(flags & MatchCase$2),
2234
2184
  useRegularExpression: Boolean(flags & UseRegularExpression$2),
2235
2185
  exclude: excludeValue,
2236
2186
  include: includeValue,
2237
- assetDir: state.assetDir,
2187
+ assetDir: assetDir,
2238
2188
  root,
2239
2189
  query: value,
2240
2190
  scheme,
2241
2191
  flags,
2242
2192
  matchWholeWord: Boolean(flags & MatchWholeWord$2)
2243
- }, state.assetDir, state.platform);
2193
+ }, assetDir, platform);
2244
2194
  if (!Array.isArray(results)) {
2245
2195
  throw new TypeError('results must be of type array');
2246
2196
  }
@@ -2278,6 +2228,35 @@ const handleUpdateFull = async (state, update) => {
2278
2228
  };
2279
2229
  };
2280
2230
 
2231
+ const getRipGrepArgs = ({
2232
+ threads,
2233
+ isCaseSensitive,
2234
+ searchString,
2235
+ useRegularExpression
2236
+ }) => {
2237
+ const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json'];
2238
+ ripGrepArgs.push('--threads', `${threads}`);
2239
+ if (isCaseSensitive) {
2240
+ ripGrepArgs.push('--case-sensitive');
2241
+ } else {
2242
+ ripGrepArgs.push('--ignore-case');
2243
+ }
2244
+ if (useRegularExpression) {
2245
+ ripGrepArgs.push('--regexp', searchString);
2246
+ } else {
2247
+ ripGrepArgs.push('--fixed-strings');
2248
+ ripGrepArgs.push('--');
2249
+ ripGrepArgs.push(searchString);
2250
+ }
2251
+ ripGrepArgs.push('.');
2252
+ return ripGrepArgs;
2253
+ };
2254
+
2255
+ const {
2256
+ invoke,
2257
+ setFactory
2258
+ } = createLazyRpc(RpcId.SearchProcess);
2259
+
2281
2260
  const waitForNextFrame = async () => {
2282
2261
  await new Promise(r => {
2283
2262
  requestAnimationFrame(r);
@@ -2297,7 +2276,7 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
2297
2276
  };
2298
2277
  const resultPromise = invoke('TextSearch.searchIncremental', actualOptions);
2299
2278
  for (let i = 0; i < 100; i++) {
2300
- const latest = get(uid);
2279
+ const latest = get$1(uid);
2301
2280
  const {
2302
2281
  newState
2303
2282
  } = latest;
@@ -2310,7 +2289,7 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
2310
2289
  const listHeight = height - headerHeight;
2311
2290
  const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
2312
2291
  const visible = await invoke('TextSearch.getIncrementalResults', searchId, minLineY, minLineY + numberOfVisible);
2313
- const latest2 = get(uid);
2292
+ const latest2 = get$1(uid);
2314
2293
  if (!latest2 || latest2.newState.searchId !== searchId) {
2315
2294
  return;
2316
2295
  }
@@ -2321,7 +2300,7 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
2321
2300
  minLineY: 0,
2322
2301
  maxLineY: visible.length
2323
2302
  };
2324
- set$1(uid, latest2.oldState, updatedState2);
2303
+ set(uid, latest2.oldState, updatedState2);
2325
2304
  // @ts-ignore
2326
2305
  await invoke$1('Search.rerender');
2327
2306
  await waitForNextFrame();
@@ -2347,13 +2326,13 @@ const handleUpdateIncremental = async (state, update) => {
2347
2326
  const root = state.workspacePath;
2348
2327
  const scheme = getProtocol$1(root);
2349
2328
  const searchId = crypto.randomUUID(); // TODO try to avoid side effect
2350
- const latest1 = get(uid);
2329
+ const latest1 = get$1(uid);
2351
2330
  const updatedState1 = {
2352
2331
  ...latest1.newState,
2353
2332
  ...partialNewState,
2354
2333
  searchId
2355
2334
  };
2356
- set$1(uid, latest1.oldState, updatedState1);
2335
+ set(uid, latest1.oldState, updatedState1);
2357
2336
 
2358
2337
  // TODO await promise?
2359
2338
  void textSearchIncremental(root, value, {
@@ -2703,31 +2682,11 @@ const handleSharedInput = (state, name, value, inputSource = Script) => {
2703
2682
  return fn(state, value, inputSource);
2704
2683
  };
2705
2684
 
2706
- const getPortTuple = () => {
2707
- const {
2708
- port1,
2709
- port2
2710
- } = new MessageChannel();
2711
- return {
2712
- port1,
2713
- port2
2714
- };
2715
- };
2716
-
2717
2685
  const launchSearchProcessElectron = async () => {
2718
- const {
2719
- port1,
2720
- port2
2721
- } = getPortTuple();
2722
- const rpcPromise = MessagePortRpcParent.create({
2723
- messagePort: port2,
2686
+ const rpc = await TransferMessagePortRpcParent.create({
2724
2687
  commandMap: {},
2725
- isMessagePortOpen: true
2688
+ send: sendMessagePortToSearchProcess
2726
2689
  });
2727
- await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port1, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
2728
- port2.start();
2729
- const rpc = await rpcPromise;
2730
- set(rpc);
2731
2690
  return rpc;
2732
2691
  };
2733
2692
 
@@ -2763,6 +2722,9 @@ const launchSearchProcessNode = async () => {
2763
2722
  return rpc;
2764
2723
  };
2765
2724
 
2725
+ const Electron = 2;
2726
+ const Remote = 3;
2727
+
2766
2728
  const initialize = async platform => {
2767
2729
  if (platform === Electron) {
2768
2730
  setFactory(launchSearchProcessElectron);
@@ -3128,7 +3090,7 @@ const getFileIndex = (items, index) => {
3128
3090
  };
3129
3091
 
3130
3092
  const openUri = async (path, focus = true, props = {}) => {
3131
- await invoke$1(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
3093
+ await openUri$1(path, focus, props);
3132
3094
  };
3133
3095
 
3134
3096
  // TODO this should be in FileSystem module
@@ -3646,7 +3608,26 @@ const ClassNames = {
3646
3608
  const mergeClassNames = (...classNames) => {
3647
3609
  return classNames.filter(Boolean).join(' ');
3648
3610
  };
3649
- const Text$1 = 12;
3611
+ const Button$2 = 1;
3612
+ const Div = 4;
3613
+ const Span = 8;
3614
+ const Text = 12;
3615
+ const Img = 17;
3616
+ const Ins = 20;
3617
+ const Del = 21;
3618
+ const H4 = 24;
3619
+ const TextArea = 62;
3620
+ const VirtualDomElements = {
3621
+ __proto__: null,
3622
+ Button: Button$2,
3623
+ Del,
3624
+ Div,
3625
+ H4,
3626
+ Img,
3627
+ Ins,
3628
+ Span,
3629
+ Text,
3630
+ TextArea};
3650
3631
  const SetText = 1;
3651
3632
  const SetAttribute = 3;
3652
3633
  const RemoveAttribute = 4;
@@ -3736,7 +3717,7 @@ const diff = (oldNodes, newNodes) => {
3736
3717
  j += newTotal;
3737
3718
  continue;
3738
3719
  }
3739
- if (oldNode.type === Text$1 && newNode.type === Text$1) {
3720
+ if (oldNode.type === Text && newNode.type === Text) {
3740
3721
  if (oldNode.text !== newNode.text) {
3741
3722
  if (siblingOffset !== 0) {
3742
3723
  pendingPatches.push(NavigateSibling, siblingOffset);
@@ -3859,7 +3840,7 @@ const diff = (oldNodes, newNodes) => {
3859
3840
  };
3860
3841
 
3861
3842
  const Alert = 'alert';
3862
- const Button$2 = 'button';
3843
+ const Button$1 = 'button';
3863
3844
  const CheckBox = 'checkbox';
3864
3845
  const None = 'none';
3865
3846
  const ScrollBar = 'scrollbar';
@@ -3885,28 +3866,18 @@ const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
3885
3866
  const HandleToggleButtonClick = 'handleToggleButtonClick';
3886
3867
  const HandleWheel = 'handleWheel';
3887
3868
 
3888
- const Button$1 = 1;
3889
- const Del = 21;
3890
- const Div = 4;
3891
- const H4 = 24;
3892
- const Img = 17;
3893
- const Ins = 20;
3894
- const Span = 8;
3895
- const Text = 12;
3896
- const TextArea = 62;
3897
-
3898
3869
  const getSearchDetailsToggleVirtualDom = () => {
3899
3870
  return [{
3900
- type: Div,
3871
+ type: VirtualDomElements.Div,
3901
3872
  className: ClassNames.ToggleDetails,
3902
- role: Button$2,
3873
+ role: Button$1,
3903
3874
  tabIndex: 0,
3904
3875
  ariaLabel: toggleSearchDetails(),
3905
3876
  title: toggleSearchDetails(),
3906
3877
  name: ToggleSearchDetails,
3907
3878
  childCount: 1
3908
3879
  }, {
3909
- type: Div,
3880
+ type: VirtualDomElements.Div,
3910
3881
  className: mergeClassNames(ClassNames.MaskIcon, ClassNames.MaskIconEllipsis),
3911
3882
  childCount: 0
3912
3883
  }];
@@ -3914,7 +3885,7 @@ const getSearchDetailsToggleVirtualDom = () => {
3914
3885
 
3915
3886
  const text = data => {
3916
3887
  return {
3917
- type: Text,
3888
+ type: VirtualDomElements.Text,
3918
3889
  text: data,
3919
3890
  childCount: 0
3920
3891
  };
@@ -3928,7 +3899,7 @@ const getClassName = indented => {
3928
3899
  };
3929
3900
  const getSearchMessageVirtualDom = (message, indented) => {
3930
3901
  return [{
3931
- type: Div,
3902
+ type: VirtualDomElements.Div,
3932
3903
  className: getClassName(indented),
3933
3904
  role: Status,
3934
3905
  tabIndex: 0,
@@ -3938,7 +3909,7 @@ const getSearchMessageVirtualDom = (message, indented) => {
3938
3909
 
3939
3910
  const getSearchHeaderDetailsCollapsedVirtualDom = message => {
3940
3911
  return [{
3941
- type: Div,
3912
+ type: VirtualDomElements.Div,
3942
3913
  className: ClassNames.SearchHeaderDetails,
3943
3914
  childCount: 2
3944
3915
  }, ...getSearchMessageVirtualDom(message, true), ...getSearchDetailsToggleVirtualDom()];
@@ -4024,7 +3995,7 @@ const getSearchFieldButtonVirtualDom = button => {
4024
3995
  const role = getRole(flag);
4025
3996
  const disabled = getDisabled(flag);
4026
3997
  return [{
4027
- type: Button$1,
3998
+ type: VirtualDomElements.Button,
4028
3999
  className: getSearchFieldButtonClassName(flag),
4029
4000
  name,
4030
4001
  title,
@@ -4034,7 +4005,7 @@ const getSearchFieldButtonVirtualDom = button => {
4034
4005
  tabIndex: 0,
4035
4006
  childCount: 1
4036
4007
  }, {
4037
- type: Span,
4008
+ type: VirtualDomElements.Span,
4038
4009
  className: mergeClassNames(ClassNames.MaskIcon, icon),
4039
4010
  childCount: 0
4040
4011
  }];
@@ -4049,7 +4020,7 @@ const getOutSideButtonsDom = outsideButtons => {
4049
4020
  }
4050
4021
  return {
4051
4022
  preNodes: [{
4052
- type: Div,
4023
+ type: VirtualDomElements.Div,
4053
4024
  className: ClassNames.SearchFieldContainer,
4054
4025
  role: None,
4055
4026
  childCount: 1 + outsideButtons.length
@@ -4065,12 +4036,12 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
4065
4036
  } = getOutSideButtonsDom(outsideButtons);
4066
4037
  const searchFieldClassName = hasError ? mergeClassNames(ClassNames.SearchField, ClassNames.SearchFieldError) : ClassNames.SearchField;
4067
4038
  const dom = [...preNodes, {
4068
- type: Div,
4039
+ type: VirtualDomElements.Div,
4069
4040
  className: searchFieldClassName,
4070
4041
  role: None,
4071
4042
  childCount: 2
4072
4043
  }, {
4073
- type: TextArea,
4044
+ type: VirtualDomElements.TextArea,
4074
4045
  className: ClassNames.MultilineInputBox,
4075
4046
  spellcheck: false,
4076
4047
  autocapitalize: 'off',
@@ -4081,7 +4052,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
4081
4052
  onFocus,
4082
4053
  childCount: 0
4083
4054
  }, {
4084
- type: Div,
4055
+ type: VirtualDomElements.Div,
4085
4056
  className: ClassNames.SearchFieldButtons,
4086
4057
  childCount: insideButtons.length
4087
4058
  }, ...insideButtons.flatMap(getSearchFieldButtonVirtualDom), ...postNodes];
@@ -4094,19 +4065,19 @@ const getSearchHeaderDetailsExpandedVirtualDom = (flags, message) => {
4094
4065
  const includePlaceholder = include();
4095
4066
  const excludePlaceholder = exclude();
4096
4067
  return [{
4097
- type: Div,
4068
+ type: VirtualDomElements.Div,
4098
4069
  className: ClassNames.SearchHeaderDetailsExpanded,
4099
4070
  childCount: 5
4100
4071
  }, {
4101
- type: Div,
4072
+ type: VirtualDomElements.Div,
4102
4073
  className: ClassNames.SearchHeaderDetailsExpandedTop,
4103
4074
  childCount: 2
4104
4075
  }, ...getSearchDetailsToggleVirtualDom(), {
4105
- type: H4,
4076
+ type: VirtualDomElements.H4,
4106
4077
  className: ClassNames.SearchHeaderDetailsHeading,
4107
4078
  childCount: 1
4108
4079
  }, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, includePlaceholder, HandleInput2, includeButtons.inside, includeButtons.outside), {
4109
- type: H4,
4080
+ type: VirtualDomElements.H4,
4110
4081
  className: ClassNames.SearchHeaderDetailsHeading,
4111
4082
  childCount: 1
4112
4083
  }, text(filesToExclude()), ...getSearchFieldVirtualDom(FilesToExclude, excludePlaceholder, HandleInput2, excludeButtons.inside, excludeButtons.outside), ...getSearchMessageVirtualDom(message, false)];
@@ -4178,7 +4149,7 @@ const getSearchPlaceholder = focus => {
4178
4149
 
4179
4150
  const getSearchToggleVirtualDom = replaceExpanded => {
4180
4151
  return [{
4181
- type: Button$1,
4152
+ type: VirtualDomElements.Button,
4182
4153
  className: mergeClassNames(ClassNames.IconButton, ClassNames.SearchToggleButton, replaceExpanded ? ClassNames.SearchToggleButtonExpanded : ''),
4183
4154
  title: toggleReplace$1(),
4184
4155
  ariaLabel: toggleReplace$1(),
@@ -4187,7 +4158,7 @@ const getSearchToggleVirtualDom = replaceExpanded => {
4187
4158
  'data-command': 'toggleReplace',
4188
4159
  name: ToggleReplace
4189
4160
  }, {
4190
- type: Div,
4161
+ type: VirtualDomElements.Div,
4191
4162
  className: mergeClassNames(ClassNames.MaskIcon, replaceExpanded ? ClassNames.MaskIconChevronDown : ClassNames.MaskIconChevronRight),
4192
4163
  childCount: 0
4193
4164
  }];
@@ -4200,12 +4171,12 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
4200
4171
  const replacePlaceholder = getReplacePlaceholder(focus);
4201
4172
  const replaceExpanded = flags & ReplaceExpanded;
4202
4173
  const dom = [{
4203
- type: Div,
4174
+ type: VirtualDomElements.Div,
4204
4175
  className: ClassNames.SearchHeaderTop,
4205
4176
  role: None,
4206
4177
  childCount: 2
4207
4178
  }, ...getSearchToggleVirtualDom(replaceExpanded), {
4208
- type: Div,
4179
+ type: VirtualDomElements.Div,
4209
4180
  className: ClassNames.SearchHeaderTopRight,
4210
4181
  role: None,
4211
4182
  childCount: replaceExpanded ? 2 : 1
@@ -4217,7 +4188,7 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
4217
4188
  };
4218
4189
 
4219
4190
  const parentNode = {
4220
- type: Div,
4191
+ type: VirtualDomElements.Div,
4221
4192
  className: ClassNames.SearchHeader,
4222
4193
  role: None,
4223
4194
  childCount: 2,
@@ -4236,7 +4207,7 @@ const getSearchInputErrorVirtualDom = errorMessage => {
4236
4207
  return [];
4237
4208
  }
4238
4209
  return [{
4239
- type: Div,
4210
+ type: VirtualDomElements.Div,
4240
4211
  className: ClassNames.SearchInputError,
4241
4212
  role: Alert,
4242
4213
  childCount: 1
@@ -4250,7 +4221,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
4250
4221
  return [];
4251
4222
  }
4252
4223
  return [{
4253
- type: Div,
4224
+ type: VirtualDomElements.Div,
4254
4225
  className: mergeClassNames(ClassNames.ScrollBar, ClassNames.ScrollBarVertical),
4255
4226
  childCount: 1,
4256
4227
  onPointerDown: HandleScrollBarPointerDown,
@@ -4258,7 +4229,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
4258
4229
  ariaControls: TreeItems,
4259
4230
  ariaValueNow: scrollBarValue
4260
4231
  }, {
4261
- type: Div,
4232
+ type: VirtualDomElements.Div,
4262
4233
  className: ClassNames.ScrollBarThumb,
4263
4234
  height: scrollBarHeight,
4264
4235
  translate: `0 ${scrollBarY}px`,
@@ -4284,26 +4255,26 @@ const getBadgeVirtualDom = (className, badgeText) => {
4284
4255
  return [];
4285
4256
  }
4286
4257
  return [{
4287
- type: Div,
4258
+ type: VirtualDomElements.Div,
4288
4259
  className: mergeClassNames(ClassNames.Badge, className),
4289
4260
  childCount: 1
4290
4261
  }, text(badgeText)];
4291
4262
  };
4292
4263
 
4293
4264
  const chevronDownVirtualDom = {
4294
- type: Div,
4265
+ type: VirtualDomElements.Div,
4295
4266
  className: mergeClassNames(ClassNames.Chevron, ClassNames.MaskIconChevronDown),
4296
4267
  childCount: 0
4297
4268
  };
4298
4269
  const chevronRightVirtualDom = {
4299
- type: Div,
4270
+ type: VirtualDomElements.Div,
4300
4271
  className: mergeClassNames(ClassNames.Chevron, ClassNames.MaskIconChevronRight),
4301
4272
  childCount: 0
4302
4273
  };
4303
4274
 
4304
4275
  const getFileIconVirtualDom = icon => {
4305
4276
  return {
4306
- type: Img,
4277
+ type: VirtualDomElements.Img,
4307
4278
  className: ClassNames.FileIcon,
4308
4279
  src: icon,
4309
4280
  role: None,
@@ -4323,22 +4294,22 @@ const getIconsVirtualDom = (expanded, icon) => {
4323
4294
  };
4324
4295
 
4325
4296
  const deleted = {
4326
- type: Del,
4297
+ type: VirtualDomElements.Del,
4327
4298
  className: ClassNames.HighlightDeleted,
4328
4299
  childCount: 1
4329
4300
  };
4330
4301
  const inserted = {
4331
- type: Ins,
4302
+ type: VirtualDomElements.Ins,
4332
4303
  className: ClassNames.HighlightInserted,
4333
4304
  childCount: 1
4334
4305
  };
4335
4306
  const highlighted = {
4336
- type: Span,
4307
+ type: VirtualDomElements.Span,
4337
4308
  className: ClassNames.Highlight,
4338
4309
  childCount: 1
4339
4310
  };
4340
4311
  const label1 = {
4341
- type: Div,
4312
+ type: VirtualDomElements.Div,
4342
4313
  className: mergeClassNames(ClassNames.Label, ClassNames.Grow),
4343
4314
  childCount: 1
4344
4315
  };
@@ -4393,7 +4364,7 @@ const getSearchResultVirtualDom = rowInfo => {
4393
4364
  badgeText
4394
4365
  } = rowInfo;
4395
4366
  const dom = [{
4396
- type: Div,
4367
+ type: VirtualDomElements.Div,
4397
4368
  role: TreeItem,
4398
4369
  className: getSearchResultClassName(focused),
4399
4370
  title,
@@ -4407,11 +4378,11 @@ const getSearchResultVirtualDom = rowInfo => {
4407
4378
  paddingRight: PaddingRight,
4408
4379
  ariaExpanded: getAriaExpanded(expanded)
4409
4380
  }, ...getIconsVirtualDom(expanded, icon), ...getLabelVirtualDom(displayText, matchLength, matchStart, replacement), ...getBadgeVirtualDom(ClassNames.SourceControlBadge, badgeText), {
4410
- type: Div,
4381
+ type: VirtualDomElements.Div,
4411
4382
  className: ClassNames.SearchRemove,
4412
4383
  childCount: 1
4413
4384
  }, {
4414
- type: Div,
4385
+ type: VirtualDomElements.Div,
4415
4386
  className: ClassNames.CloseMaskIcon,
4416
4387
  childCount: 0
4417
4388
  }];
@@ -4421,7 +4392,7 @@ const getSearchResultVirtualDom = rowInfo => {
4421
4392
  const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
4422
4393
  const pixelOffset = deltaY % itemHeight;
4423
4394
  return [{
4424
- type: Div,
4395
+ type: VirtualDomElements.Div,
4425
4396
  className: ClassNames.TreeItems,
4426
4397
  childCount: visibleItems.length,
4427
4398
  onClick: HandleClick,
@@ -4436,7 +4407,7 @@ const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
4436
4407
  const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
4437
4408
  const scrollBarDomNodes = scrollbarHeight === 0 ? 0 : 1;
4438
4409
  return [{
4439
- type: Div,
4410
+ type: VirtualDomElements.Div,
4440
4411
  className: mergeClassNames(ClassNames.Viewlet, ClassNames.List, ClassNames.Tree, focusOutline ? ClassNames.FocusOutline : ClassNames.Empty),
4441
4412
  role: Tree,
4442
4413
  tabIndex: 0,
@@ -4448,7 +4419,7 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchI
4448
4419
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
4449
4420
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
4450
4421
  return [{
4451
- type: Div,
4422
+ type: VirtualDomElements.Div,
4452
4423
  className: mergeClassNames(ClassNames.Viewlet, ClassNames.Search),
4453
4424
  childCount
4454
4425
  }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
@@ -4507,15 +4478,15 @@ const render2 = (uid, diffResult) => {
4507
4478
  const {
4508
4479
  oldState,
4509
4480
  newState
4510
- } = get(uid);
4511
- set$1(uid, newState, newState);
4481
+ } = get$1(uid);
4482
+ set(uid, newState, newState);
4512
4483
  const commands = applyRender(oldState, newState, diffResult);
4513
4484
  return commands;
4514
4485
  };
4515
4486
 
4516
4487
  const Button = 1;
4517
4488
 
4518
- const getIconVirtualDom = (icon, type = Div) => {
4489
+ const getIconVirtualDom = (icon, type = VirtualDomElements.Div) => {
4519
4490
  return {
4520
4491
  type,
4521
4492
  className: mergeClassNames(ClassNames.MaskIcon, `MaskIcon${icon}`),
@@ -4531,7 +4502,7 @@ const getActionButtonVirtualDom = action => {
4531
4502
  command
4532
4503
  } = action;
4533
4504
  return [{
4534
- type: Button$1,
4505
+ type: VirtualDomElements.Button,
4535
4506
  className: ClassNames.IconButton,
4536
4507
  title: id,
4537
4508
  'data-command': command,
@@ -4550,7 +4521,7 @@ const getActionVirtualDom = action => {
4550
4521
 
4551
4522
  const getActionsVirtualDom = actions => {
4552
4523
  return [{
4553
- type: Div,
4524
+ type: VirtualDomElements.Div,
4554
4525
  className: ClassNames.Actions,
4555
4526
  role: ToolBar,
4556
4527
  childCount: actions.length
@@ -4667,7 +4638,7 @@ const renderIncremental = uid => {
4667
4638
  const {
4668
4639
  oldState,
4669
4640
  newState
4670
- } = get(uid);
4641
+ } = get$1(uid);
4671
4642
  const oldDom = getDom(oldState);
4672
4643
  const newDom = getDom(newState);
4673
4644
  const patches = diff(oldDom, newDom);
@@ -4727,7 +4698,7 @@ const rerender = state => {
4727
4698
  const saveState = uid => {
4728
4699
  const {
4729
4700
  newState
4730
- } = get(uid);
4701
+ } = get$1(uid);
4731
4702
  const {
4732
4703
  value,
4733
4704
  replacement,
@@ -4854,10 +4825,6 @@ const submit = state => {
4854
4825
  });
4855
4826
  };
4856
4827
 
4857
- const terminate = () => {
4858
- globalThis.close();
4859
- };
4860
-
4861
4828
  const viewAsTree = async state => {
4862
4829
  return state;
4863
4830
  };
@@ -4870,7 +4837,7 @@ const show = async (x, y, id, ...args) => {
4870
4837
  number(y);
4871
4838
  number(id);
4872
4839
  // TODO
4873
- await invoke$1('ContextMenu.show', x, y, id, ...args);
4840
+ await showContextMenu(x, y, id, ...args);
4874
4841
  };
4875
4842
 
4876
4843
  const Search = 18;
@@ -4986,14 +4953,80 @@ const commandMap = {
4986
4953
  'TextSearch.renderActions': renderActions,
4987
4954
  // TODO needed?
4988
4955
  'TextSearch.replaceAllAndPrompt': replaceAllAndPrompt,
4989
- 'TextSearch.textSearch': textSearch
4956
+ 'TextSearch.textSearch': textSearch$6
4957
+ };
4958
+
4959
+ const textSearch$5 = async (scheme, root, query) => {
4960
+ string(scheme);
4961
+ string(query);
4962
+ const result = await invoke$1('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
4963
+ return result;
4964
+ };
4965
+
4966
+ const textSearch$4 = async (scheme, root, query, options, assetDir) => {
4967
+ return invoke$1('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
4968
+ };
4969
+
4970
+ const textSearch$3 = async (scheme, root, query) => {
4971
+ return invoke$1('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
4972
+ };
4973
+
4974
+ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
4975
+ return invoke$1('ExtensionHostTextSearch.textSearchMemory', scheme, root, query, options, assetDir);
4976
+ };
4977
+
4978
+ const textSearch$1 = async (scheme, root, query, options, assetDir, platform) => {
4979
+ const ripGrepArgs = getRipGrepArgs({
4980
+ ...options,
4981
+ searchString: query
4982
+ });
4983
+ const actualOptions = {
4984
+ ripGrepArgs,
4985
+ searchDir: root
4986
+ };
4987
+ if (platform === Remote || platform === Electron) {
4988
+ const result = await invoke('TextSearch.search', actualOptions);
4989
+ // TODO api is weird
4990
+ // @ts-ignore
4991
+ return result.results;
4992
+ }
4993
+ // TODO always create search process messageport rpc to have one api, in web can send the messageport to renderer worker
4994
+ const results = await invoke$1('SearchProcess.invoke', 'TextSearch.search', actualOptions);
4995
+ // TODO api is weird
4996
+ return results.results;
4997
+ };
4998
+
4999
+ const textSearch = async (scheme, root, query) => {
5000
+ // TODO ask renderer worker for files
5001
+ const entries = Object.entries({});
5002
+ const results = [];
5003
+ for (const [key, value] of entries) {
5004
+ // @ts-ignore
5005
+ if (value.includes(query)) {
5006
+ results.push([key, [{
5007
+ absoluteOffset: 0,
5008
+ preview: value
5009
+ }]]);
5010
+ }
5011
+ }
5012
+ return results;
5013
+ };
5014
+
5015
+ const textSearchProviderMap = {
5016
+ '': textSearch$1,
5017
+ web: textSearch,
5018
+ fetch: textSearch$4,
5019
+ html: textSearch$3,
5020
+ memfs: textSearch$2,
5021
+ default: textSearch$5
4990
5022
  };
4991
5023
 
4992
5024
  const listen = async () => {
5025
+ add(textSearchProviderMap);
4993
5026
  const rpc = await WebWorkerRpcClient.create({
4994
5027
  commandMap: commandMap
4995
5028
  });
4996
- set$2(rpc);
5029
+ set$1(rpc);
4997
5030
  };
4998
5031
 
4999
5032
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"