@lvce-editor/text-search-worker 5.1.0 → 5.3.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.
- package/dist/textSearchWorkerMain.js +354 -303
- package/package.json +1 -1
|
@@ -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
|
|
74
|
+
return Number$1;
|
|
67
75
|
case 'function':
|
|
68
|
-
return
|
|
76
|
+
return Function;
|
|
69
77
|
case 'string':
|
|
70
|
-
return
|
|
78
|
+
return String;
|
|
71
79
|
case 'object':
|
|
72
80
|
if (value === null) {
|
|
73
|
-
return
|
|
81
|
+
return Null;
|
|
74
82
|
}
|
|
75
83
|
if (Array.isArray(value)) {
|
|
76
|
-
return
|
|
84
|
+
return Array$1;
|
|
77
85
|
}
|
|
78
|
-
return
|
|
86
|
+
return Object$1;
|
|
79
87
|
case 'boolean':
|
|
80
|
-
return
|
|
88
|
+
return Boolean$1;
|
|
81
89
|
default:
|
|
82
|
-
return
|
|
90
|
+
return Unknown;
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
const object = value => {
|
|
86
94
|
const type = getType(value);
|
|
87
|
-
if (type !==
|
|
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 !==
|
|
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 !==
|
|
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 !==
|
|
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$
|
|
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$
|
|
586
|
+
create: create$7,
|
|
579
587
|
wrap
|
|
580
588
|
};
|
|
581
589
|
|
|
@@ -588,7 +596,7 @@ const create$4$1 = (method, params) => {
|
|
|
588
596
|
};
|
|
589
597
|
};
|
|
590
598
|
const callbacks = Object.create(null);
|
|
591
|
-
const set$
|
|
599
|
+
const set$2 = (id, fn) => {
|
|
592
600
|
callbacks[id] = fn;
|
|
593
601
|
};
|
|
594
602
|
const get$3 = id => {
|
|
@@ -598,22 +606,22 @@ const remove$1 = id => {
|
|
|
598
606
|
delete callbacks[id];
|
|
599
607
|
};
|
|
600
608
|
let id = 0;
|
|
601
|
-
const create$3$
|
|
609
|
+
const create$3$2 = () => {
|
|
602
610
|
return ++id;
|
|
603
611
|
};
|
|
604
612
|
const registerPromise = () => {
|
|
605
|
-
const id = create$3$
|
|
613
|
+
const id = create$3$2();
|
|
606
614
|
const {
|
|
607
615
|
resolve,
|
|
608
616
|
promise
|
|
609
617
|
} = Promise.withResolvers();
|
|
610
|
-
set$
|
|
618
|
+
set$2(id, resolve);
|
|
611
619
|
return {
|
|
612
620
|
id,
|
|
613
621
|
promise
|
|
614
622
|
};
|
|
615
623
|
};
|
|
616
|
-
const create$2$
|
|
624
|
+
const create$2$2 = (method, params) => {
|
|
617
625
|
const {
|
|
618
626
|
id,
|
|
619
627
|
promise
|
|
@@ -834,7 +842,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
834
842
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
835
843
|
return create$1$2(id, errorProperty);
|
|
836
844
|
};
|
|
837
|
-
const create$
|
|
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$
|
|
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$
|
|
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
|
|
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
|
|
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$
|
|
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
|
|
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$
|
|
1068
|
+
create: create$3$1
|
|
1047
1069
|
};
|
|
1048
|
-
const create$
|
|
1070
|
+
const create$2$1 = async ({
|
|
1049
1071
|
commandMap,
|
|
1050
1072
|
webSocket
|
|
1051
1073
|
}) => {
|
|
@@ -1059,7 +1081,36 @@ const create$1$1 = async ({
|
|
|
1059
1081
|
const rpc = createRpc(ipc);
|
|
1060
1082
|
return rpc;
|
|
1061
1083
|
};
|
|
1062
|
-
const
|
|
1084
|
+
const Https = 'https:';
|
|
1085
|
+
const Ws = 'ws:';
|
|
1086
|
+
const Wss = 'wss:';
|
|
1087
|
+
const getWebSocketProtocol = locationProtocol => {
|
|
1088
|
+
return locationProtocol === Https ? Wss : Ws;
|
|
1089
|
+
};
|
|
1090
|
+
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1091
|
+
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1092
|
+
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1093
|
+
};
|
|
1094
|
+
const getHost = () => {
|
|
1095
|
+
return location.host;
|
|
1096
|
+
};
|
|
1097
|
+
const getProtocol$1 = () => {
|
|
1098
|
+
return location.protocol;
|
|
1099
|
+
};
|
|
1100
|
+
const create$1$1 = async ({
|
|
1101
|
+
commandMap
|
|
1102
|
+
}) => {
|
|
1103
|
+
const host = getHost();
|
|
1104
|
+
const protocol = getProtocol$1();
|
|
1105
|
+
const wsUrl = getWebSocketUrl('search-process', host, protocol);
|
|
1106
|
+
const webSocket = new WebSocket(wsUrl);
|
|
1107
|
+
const rpc = await create$2$1({
|
|
1108
|
+
webSocket,
|
|
1109
|
+
commandMap
|
|
1110
|
+
});
|
|
1111
|
+
return rpc;
|
|
1112
|
+
};
|
|
1113
|
+
const WebSocketRpcParent2 = {
|
|
1063
1114
|
__proto__: null,
|
|
1064
1115
|
create: create$1$1
|
|
1065
1116
|
};
|
|
@@ -1078,6 +1129,68 @@ const WebWorkerRpcClient = {
|
|
|
1078
1129
|
create: create$4
|
|
1079
1130
|
};
|
|
1080
1131
|
|
|
1132
|
+
const create$3 = () => {
|
|
1133
|
+
const states = Object.create(null);
|
|
1134
|
+
return {
|
|
1135
|
+
get(uid) {
|
|
1136
|
+
return states[uid];
|
|
1137
|
+
},
|
|
1138
|
+
set(uid, oldState, newState) {
|
|
1139
|
+
states[uid] = {
|
|
1140
|
+
oldState,
|
|
1141
|
+
newState
|
|
1142
|
+
};
|
|
1143
|
+
},
|
|
1144
|
+
dispose(uid) {
|
|
1145
|
+
delete states[uid];
|
|
1146
|
+
},
|
|
1147
|
+
getKeys() {
|
|
1148
|
+
return Object.keys(states).map(key => {
|
|
1149
|
+
return Number.parseInt(key);
|
|
1150
|
+
});
|
|
1151
|
+
},
|
|
1152
|
+
clear() {
|
|
1153
|
+
for (const key of Object.keys(states)) {
|
|
1154
|
+
delete states[key];
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
wrapCommand(fn) {
|
|
1158
|
+
const wrapped = async (uid, ...args) => {
|
|
1159
|
+
const {
|
|
1160
|
+
newState
|
|
1161
|
+
} = states[uid];
|
|
1162
|
+
const newerState = await fn(newState, ...args);
|
|
1163
|
+
if (newState === newerState) {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
const latest = states[uid];
|
|
1167
|
+
states[uid] = {
|
|
1168
|
+
oldState: latest.oldState,
|
|
1169
|
+
newState: newerState
|
|
1170
|
+
};
|
|
1171
|
+
};
|
|
1172
|
+
return wrapped;
|
|
1173
|
+
},
|
|
1174
|
+
diff(uid, modules, numbers) {
|
|
1175
|
+
const {
|
|
1176
|
+
oldState,
|
|
1177
|
+
newState
|
|
1178
|
+
} = states[uid];
|
|
1179
|
+
const diffResult = [];
|
|
1180
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1181
|
+
const fn = modules[i];
|
|
1182
|
+
if (!fn(oldState, newState)) {
|
|
1183
|
+
diffResult.push(numbers[i]);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return diffResult;
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
};
|
|
1190
|
+
const terminate = () => {
|
|
1191
|
+
globalThis.close();
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1081
1194
|
const User = 1;
|
|
1082
1195
|
const Script = 2;
|
|
1083
1196
|
|
|
@@ -1150,7 +1263,7 @@ const get$2 = id => {
|
|
|
1150
1263
|
|
|
1151
1264
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1152
1265
|
|
|
1153
|
-
const create$
|
|
1266
|
+
const create$2 = rpcId => {
|
|
1154
1267
|
return {
|
|
1155
1268
|
// @ts-ignore
|
|
1156
1269
|
invoke(method, ...params) {
|
|
@@ -1179,26 +1292,68 @@ const RpcId = {
|
|
|
1179
1292
|
__proto__: null,
|
|
1180
1293
|
SearchProcess: SearchProcess$1};
|
|
1181
1294
|
const {
|
|
1182
|
-
invoke: invoke$
|
|
1295
|
+
invoke: invoke$3,
|
|
1183
1296
|
invokeAndTransfer: invokeAndTransfer$3,
|
|
1184
|
-
set: set$3} = create$
|
|
1297
|
+
set: set$3} = create$2(RendererWorker$1);
|
|
1298
|
+
const showContextMenu$1 = async (x, y, id, ...args) => {
|
|
1299
|
+
return invoke$3('ContextMenu.show', x, y, id, ...args);
|
|
1300
|
+
};
|
|
1301
|
+
const getFileIcon$2 = async options => {
|
|
1302
|
+
return invoke$3('IconTheme.getFileIcon', options);
|
|
1303
|
+
};
|
|
1304
|
+
const sendMessagePortToSearchProcess$1 = async port => {
|
|
1305
|
+
await invokeAndTransfer$3('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
|
|
1306
|
+
};
|
|
1307
|
+
const writeClipBoardText$1 = async text => {
|
|
1308
|
+
await invoke$3('ClipBoard.writeText', /* text */text);
|
|
1309
|
+
};
|
|
1310
|
+
const openUri$2 = async (uri, focus, options) => {
|
|
1311
|
+
await invoke$3('Main.openUri', uri, focus, options);
|
|
1312
|
+
};
|
|
1185
1313
|
const RendererWorker = {
|
|
1186
1314
|
__proto__: null,
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1315
|
+
getFileIcon: getFileIcon$2,
|
|
1316
|
+
invoke: invoke$3,
|
|
1317
|
+
openUri: openUri$2,
|
|
1318
|
+
sendMessagePortToSearchProcess: sendMessagePortToSearchProcess$1,
|
|
1319
|
+
set: set$3,
|
|
1320
|
+
showContextMenu: showContextMenu$1,
|
|
1321
|
+
writeClipBoardText: writeClipBoardText$1
|
|
1190
1322
|
};
|
|
1191
|
-
const {
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1323
|
+
const createLazyRpc = rpcId => {
|
|
1324
|
+
let rpcPromise;
|
|
1325
|
+
let factory;
|
|
1326
|
+
const createRpc = async () => {
|
|
1327
|
+
const rpc = await factory();
|
|
1328
|
+
set$g(rpcId, rpc);
|
|
1329
|
+
};
|
|
1330
|
+
const ensureRpc = async () => {
|
|
1331
|
+
if (!rpcPromise) {
|
|
1332
|
+
rpcPromise = createRpc();
|
|
1333
|
+
}
|
|
1334
|
+
await rpcPromise;
|
|
1335
|
+
};
|
|
1336
|
+
return {
|
|
1337
|
+
setFactory(value) {
|
|
1338
|
+
factory = value;
|
|
1339
|
+
},
|
|
1340
|
+
async invoke(method, ...params) {
|
|
1341
|
+
await ensureRpc();
|
|
1342
|
+
const rpc = get$2(rpcId);
|
|
1343
|
+
return rpc.invoke(method, ...params);
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1196
1346
|
};
|
|
1197
1347
|
|
|
1198
1348
|
const {
|
|
1349
|
+
getFileIcon: getFileIcon$1,
|
|
1199
1350
|
invoke: invoke$1,
|
|
1200
|
-
|
|
1201
|
-
|
|
1351
|
+
openUri: openUri$1,
|
|
1352
|
+
sendMessagePortToSearchProcess,
|
|
1353
|
+
set: set$1,
|
|
1354
|
+
showContextMenu,
|
|
1355
|
+
writeClipBoardText
|
|
1356
|
+
} = RendererWorker;
|
|
1202
1357
|
|
|
1203
1358
|
const copy = async state => {
|
|
1204
1359
|
const {
|
|
@@ -1209,76 +1364,17 @@ const copy = async state => {
|
|
|
1209
1364
|
return state;
|
|
1210
1365
|
}
|
|
1211
1366
|
const item = items[listFocusedIndex];
|
|
1212
|
-
await
|
|
1367
|
+
await writeClipBoardText(item.text);
|
|
1213
1368
|
return state;
|
|
1214
1369
|
};
|
|
1215
1370
|
|
|
1216
1371
|
const minimumSliderSize = 20;
|
|
1217
1372
|
|
|
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
1373
|
const {
|
|
1278
1374
|
get: get$1,
|
|
1279
|
-
set
|
|
1375
|
+
set,
|
|
1280
1376
|
wrapCommand
|
|
1281
|
-
} = create$
|
|
1377
|
+
} = create$3();
|
|
1282
1378
|
|
|
1283
1379
|
const List$1 = 1;
|
|
1284
1380
|
|
|
@@ -1351,9 +1447,11 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
1351
1447
|
historyIndex: -1,
|
|
1352
1448
|
viewMode: List$1,
|
|
1353
1449
|
incrementalSearch: false,
|
|
1354
|
-
searchId: ''
|
|
1450
|
+
searchId: '',
|
|
1451
|
+
useChevrons: true,
|
|
1452
|
+
useFileIcons: true
|
|
1355
1453
|
};
|
|
1356
|
-
set
|
|
1454
|
+
set(uid, state, state);
|
|
1357
1455
|
return state;
|
|
1358
1456
|
};
|
|
1359
1457
|
|
|
@@ -2010,7 +2108,7 @@ const handleUpdateError = async (state, update, error) => {
|
|
|
2010
2108
|
|
|
2011
2109
|
const getFileIcon = async result => {
|
|
2012
2110
|
if (result.type === File) {
|
|
2013
|
-
return
|
|
2111
|
+
return getFileIcon$1({
|
|
2014
2112
|
name: result.text
|
|
2015
2113
|
});
|
|
2016
2114
|
}
|
|
@@ -2031,7 +2129,7 @@ const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
|
|
|
2031
2129
|
};
|
|
2032
2130
|
|
|
2033
2131
|
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2034
|
-
const getProtocol
|
|
2132
|
+
const getProtocol = uri => {
|
|
2035
2133
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
2036
2134
|
if (protocolMatch) {
|
|
2037
2135
|
return protocolMatch[1];
|
|
@@ -2085,7 +2183,7 @@ const getTextSearchProvider = scheme => {
|
|
|
2085
2183
|
const textSearch$6 = async (root, query, options, assetDir, platform) => {
|
|
2086
2184
|
string(root);
|
|
2087
2185
|
string(query);
|
|
2088
|
-
const scheme = getProtocol
|
|
2186
|
+
const scheme = getProtocol(root);
|
|
2089
2187
|
const provider = getTextSearchProvider(scheme);
|
|
2090
2188
|
const results = await provider(scheme, root, query, options, assetDir, platform);
|
|
2091
2189
|
return results;
|
|
@@ -2110,7 +2208,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
2110
2208
|
platform
|
|
2111
2209
|
} = partialNewState;
|
|
2112
2210
|
const root = state.workspacePath;
|
|
2113
|
-
const scheme = getProtocol
|
|
2211
|
+
const scheme = getProtocol(root);
|
|
2114
2212
|
const results = await textSearch$6(root, value, {
|
|
2115
2213
|
threads,
|
|
2116
2214
|
isCaseSensitive: Boolean(flags & MatchCase$2),
|
|
@@ -2185,43 +2283,20 @@ const getRipGrepArgs = ({
|
|
|
2185
2283
|
return ripGrepArgs;
|
|
2186
2284
|
};
|
|
2187
2285
|
|
|
2188
|
-
const createLazyRpc = rpcId => {
|
|
2189
|
-
let rpcPromise;
|
|
2190
|
-
let factory;
|
|
2191
|
-
const createRpc = async () => {
|
|
2192
|
-
const rpc = await factory();
|
|
2193
|
-
set$g(rpcId, rpc);
|
|
2194
|
-
};
|
|
2195
|
-
const ensureRpc = async () => {
|
|
2196
|
-
if (!rpcPromise) {
|
|
2197
|
-
rpcPromise = createRpc();
|
|
2198
|
-
}
|
|
2199
|
-
await rpcPromise;
|
|
2200
|
-
};
|
|
2201
|
-
return {
|
|
2202
|
-
setFactory(value) {
|
|
2203
|
-
factory = value;
|
|
2204
|
-
},
|
|
2205
|
-
async invoke(method, ...params) {
|
|
2206
|
-
await ensureRpc();
|
|
2207
|
-
const rpc = get$2(rpcId);
|
|
2208
|
-
return rpc.invoke(method, ...params);
|
|
2209
|
-
}
|
|
2210
|
-
};
|
|
2211
|
-
};
|
|
2212
|
-
|
|
2213
|
-
const {
|
|
2214
|
-
set} = SearchProcess;
|
|
2215
2286
|
const {
|
|
2216
2287
|
invoke,
|
|
2217
2288
|
setFactory
|
|
2218
2289
|
} = createLazyRpc(RpcId.SearchProcess);
|
|
2219
2290
|
|
|
2220
2291
|
const waitForNextFrame = async () => {
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2292
|
+
const {
|
|
2293
|
+
resolve,
|
|
2294
|
+
promise
|
|
2295
|
+
} = Promise.withResolvers();
|
|
2296
|
+
requestAnimationFrame(resolve);
|
|
2297
|
+
await promise;
|
|
2224
2298
|
};
|
|
2299
|
+
|
|
2225
2300
|
const textSearchIncremental = async (root, query, options, assetDir, platform, searchId, uid) => {
|
|
2226
2301
|
string(root);
|
|
2227
2302
|
string(query);
|
|
@@ -2260,7 +2335,7 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
|
|
|
2260
2335
|
minLineY: 0,
|
|
2261
2336
|
maxLineY: visible.length
|
|
2262
2337
|
};
|
|
2263
|
-
set
|
|
2338
|
+
set(uid, latest2.oldState, updatedState2);
|
|
2264
2339
|
// @ts-ignore
|
|
2265
2340
|
await invoke$1('Search.rerender');
|
|
2266
2341
|
await waitForNextFrame();
|
|
@@ -2284,7 +2359,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
2284
2359
|
platform
|
|
2285
2360
|
} = partialNewState;
|
|
2286
2361
|
const root = state.workspacePath;
|
|
2287
|
-
const scheme = getProtocol
|
|
2362
|
+
const scheme = getProtocol(root);
|
|
2288
2363
|
const searchId = crypto.randomUUID(); // TODO try to avoid side effect
|
|
2289
2364
|
const latest1 = get$1(uid);
|
|
2290
2365
|
const updatedState1 = {
|
|
@@ -2292,7 +2367,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
2292
2367
|
...partialNewState,
|
|
2293
2368
|
searchId
|
|
2294
2369
|
};
|
|
2295
|
-
set
|
|
2370
|
+
set(uid, latest1.oldState, updatedState1);
|
|
2296
2371
|
|
|
2297
2372
|
// TODO await promise?
|
|
2298
2373
|
void textSearchIncremental(root, value, {
|
|
@@ -2642,62 +2717,19 @@ const handleSharedInput = (state, name, value, inputSource = Script) => {
|
|
|
2642
2717
|
return fn(state, value, inputSource);
|
|
2643
2718
|
};
|
|
2644
2719
|
|
|
2645
|
-
const getPortTuple = () => {
|
|
2646
|
-
const {
|
|
2647
|
-
port1,
|
|
2648
|
-
port2
|
|
2649
|
-
} = new MessageChannel();
|
|
2650
|
-
return {
|
|
2651
|
-
port1,
|
|
2652
|
-
port2
|
|
2653
|
-
};
|
|
2654
|
-
};
|
|
2655
|
-
|
|
2656
2720
|
const launchSearchProcessElectron = async () => {
|
|
2657
|
-
const {
|
|
2658
|
-
port1,
|
|
2659
|
-
port2
|
|
2660
|
-
} = getPortTuple();
|
|
2661
|
-
const rpcPromise = MessagePortRpcParent.create({
|
|
2662
|
-
messagePort: port2,
|
|
2721
|
+
const rpc = await TransferMessagePortRpcParent.create({
|
|
2663
2722
|
commandMap: {},
|
|
2664
|
-
|
|
2723
|
+
send: sendMessagePortToSearchProcess
|
|
2665
2724
|
});
|
|
2666
|
-
await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port1, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
|
|
2667
|
-
port2.start();
|
|
2668
|
-
const rpc = await rpcPromise;
|
|
2669
|
-
set(rpc);
|
|
2670
2725
|
return rpc;
|
|
2671
2726
|
};
|
|
2672
2727
|
|
|
2673
|
-
const Https = 'https:';
|
|
2674
|
-
const Ws = 'ws:';
|
|
2675
|
-
const Wss = 'wss:';
|
|
2676
|
-
|
|
2677
|
-
const getWebSocketProtocol = locationProtocol => {
|
|
2678
|
-
return locationProtocol === Https ? Wss : Ws;
|
|
2679
|
-
};
|
|
2680
|
-
|
|
2681
|
-
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
2682
|
-
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
2683
|
-
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
2684
|
-
};
|
|
2685
|
-
|
|
2686
|
-
const getHost = () => {
|
|
2687
|
-
return location.host;
|
|
2688
|
-
};
|
|
2689
|
-
const getProtocol = () => {
|
|
2690
|
-
return location.protocol;
|
|
2691
|
-
};
|
|
2692
|
-
|
|
2693
2728
|
const launchSearchProcessNode = async () => {
|
|
2694
|
-
const
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
const rpc = await WebSocketRpcParent.create({
|
|
2699
|
-
webSocket,
|
|
2700
|
-
commandMap: {}
|
|
2729
|
+
const rpc = await WebSocketRpcParent2.create({
|
|
2730
|
+
commandMap: {},
|
|
2731
|
+
// @ts-ignore
|
|
2732
|
+
type: 'search-process'
|
|
2701
2733
|
});
|
|
2702
2734
|
return rpc;
|
|
2703
2735
|
};
|
|
@@ -3070,7 +3102,7 @@ const getFileIndex = (items, index) => {
|
|
|
3070
3102
|
};
|
|
3071
3103
|
|
|
3072
3104
|
const openUri = async (path, focus = true, props = {}) => {
|
|
3073
|
-
await
|
|
3105
|
+
await openUri$1(path, focus, props);
|
|
3074
3106
|
};
|
|
3075
3107
|
|
|
3076
3108
|
// TODO this should be in FileSystem module
|
|
@@ -3336,18 +3368,6 @@ const getMatchCount = (results, startIndex) => {
|
|
|
3336
3368
|
return results.length - startIndex - 1;
|
|
3337
3369
|
};
|
|
3338
3370
|
|
|
3339
|
-
const getChildCount = (expanded, matchCount) => {
|
|
3340
|
-
let childCount = 1;
|
|
3341
|
-
if (expanded === Expanded || expanded === Collapsed) {
|
|
3342
|
-
childCount += 2;
|
|
3343
|
-
}
|
|
3344
|
-
if (matchCount) {
|
|
3345
|
-
childCount++;
|
|
3346
|
-
}
|
|
3347
|
-
childCount++;
|
|
3348
|
-
return childCount;
|
|
3349
|
-
};
|
|
3350
|
-
|
|
3351
3371
|
const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults) => {
|
|
3352
3372
|
const path = text;
|
|
3353
3373
|
const absolutePath = getRelativePath(path);
|
|
@@ -3355,11 +3375,9 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
|
|
|
3355
3375
|
const index = originalResults.indexOf(results[i]);
|
|
3356
3376
|
const matchCount = getMatchCount(results, index);
|
|
3357
3377
|
const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
|
|
3358
|
-
const childCount = getChildCount(expanded, matchCount);
|
|
3359
3378
|
const badgeText = `${matchCount}`;
|
|
3360
3379
|
return {
|
|
3361
3380
|
badgeText,
|
|
3362
|
-
childCount,
|
|
3363
3381
|
depth: 0,
|
|
3364
3382
|
expanded,
|
|
3365
3383
|
focused,
|
|
@@ -3377,7 +3395,6 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
|
|
|
3377
3395
|
const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, posInSet, start, focused) => {
|
|
3378
3396
|
return {
|
|
3379
3397
|
badgeText: '',
|
|
3380
|
-
childCount: getChildCount(None$1, 0),
|
|
3381
3398
|
depth: 1,
|
|
3382
3399
|
expanded: None$1,
|
|
3383
3400
|
focused,
|
|
@@ -3388,7 +3405,7 @@ const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, pos
|
|
|
3388
3405
|
replacement,
|
|
3389
3406
|
setSize,
|
|
3390
3407
|
text: text,
|
|
3391
|
-
title: text
|
|
3408
|
+
title: text.trim()
|
|
3392
3409
|
};
|
|
3393
3410
|
};
|
|
3394
3411
|
|
|
@@ -3588,7 +3605,32 @@ const ClassNames = {
|
|
|
3588
3605
|
const mergeClassNames = (...classNames) => {
|
|
3589
3606
|
return classNames.filter(Boolean).join(' ');
|
|
3590
3607
|
};
|
|
3591
|
-
const
|
|
3608
|
+
const Button$2 = 1;
|
|
3609
|
+
const Div = 4;
|
|
3610
|
+
const Span = 8;
|
|
3611
|
+
const Text = 12;
|
|
3612
|
+
const Img = 17;
|
|
3613
|
+
const Ins = 20;
|
|
3614
|
+
const Del = 21;
|
|
3615
|
+
const H4 = 24;
|
|
3616
|
+
const TextArea = 62;
|
|
3617
|
+
const VirtualDomElements = {
|
|
3618
|
+
__proto__: null,
|
|
3619
|
+
Button: Button$2,
|
|
3620
|
+
Del,
|
|
3621
|
+
Div,
|
|
3622
|
+
H4,
|
|
3623
|
+
Img,
|
|
3624
|
+
Ins,
|
|
3625
|
+
Span,
|
|
3626
|
+
TextArea};
|
|
3627
|
+
const text = data => {
|
|
3628
|
+
return {
|
|
3629
|
+
type: Text,
|
|
3630
|
+
text: data,
|
|
3631
|
+
childCount: 0
|
|
3632
|
+
};
|
|
3633
|
+
};
|
|
3592
3634
|
const SetText = 1;
|
|
3593
3635
|
const SetAttribute = 3;
|
|
3594
3636
|
const RemoveAttribute = 4;
|
|
@@ -3678,7 +3720,7 @@ const diff = (oldNodes, newNodes) => {
|
|
|
3678
3720
|
j += newTotal;
|
|
3679
3721
|
continue;
|
|
3680
3722
|
}
|
|
3681
|
-
if (oldNode.type === Text
|
|
3723
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
3682
3724
|
if (oldNode.text !== newNode.text) {
|
|
3683
3725
|
if (siblingOffset !== 0) {
|
|
3684
3726
|
pendingPatches.push(NavigateSibling, siblingOffset);
|
|
@@ -3801,7 +3843,7 @@ const diff = (oldNodes, newNodes) => {
|
|
|
3801
3843
|
};
|
|
3802
3844
|
|
|
3803
3845
|
const Alert = 'alert';
|
|
3804
|
-
const Button$
|
|
3846
|
+
const Button$1 = 'button';
|
|
3805
3847
|
const CheckBox = 'checkbox';
|
|
3806
3848
|
const None = 'none';
|
|
3807
3849
|
const ScrollBar = 'scrollbar';
|
|
@@ -3827,41 +3869,23 @@ const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
|
|
|
3827
3869
|
const HandleToggleButtonClick = 'handleToggleButtonClick';
|
|
3828
3870
|
const HandleWheel = 'handleWheel';
|
|
3829
3871
|
|
|
3830
|
-
const Button$1 = 1;
|
|
3831
|
-
const Del = 21;
|
|
3832
|
-
const Div = 4;
|
|
3833
|
-
const H4 = 24;
|
|
3834
|
-
const Img = 17;
|
|
3835
|
-
const Ins = 20;
|
|
3836
|
-
const Span = 8;
|
|
3837
|
-
const Text = 12;
|
|
3838
|
-
const TextArea = 62;
|
|
3839
|
-
|
|
3840
3872
|
const getSearchDetailsToggleVirtualDom = () => {
|
|
3841
3873
|
return [{
|
|
3842
|
-
type: Div,
|
|
3874
|
+
type: VirtualDomElements.Div,
|
|
3843
3875
|
className: ClassNames.ToggleDetails,
|
|
3844
|
-
role: Button$
|
|
3876
|
+
role: Button$1,
|
|
3845
3877
|
tabIndex: 0,
|
|
3846
3878
|
ariaLabel: toggleSearchDetails(),
|
|
3847
3879
|
title: toggleSearchDetails(),
|
|
3848
3880
|
name: ToggleSearchDetails,
|
|
3849
3881
|
childCount: 1
|
|
3850
3882
|
}, {
|
|
3851
|
-
type: Div,
|
|
3883
|
+
type: VirtualDomElements.Div,
|
|
3852
3884
|
className: mergeClassNames(ClassNames.MaskIcon, ClassNames.MaskIconEllipsis),
|
|
3853
3885
|
childCount: 0
|
|
3854
3886
|
}];
|
|
3855
3887
|
};
|
|
3856
3888
|
|
|
3857
|
-
const text = data => {
|
|
3858
|
-
return {
|
|
3859
|
-
type: Text,
|
|
3860
|
-
text: data,
|
|
3861
|
-
childCount: 0
|
|
3862
|
-
};
|
|
3863
|
-
};
|
|
3864
|
-
|
|
3865
3889
|
const getClassName = indented => {
|
|
3866
3890
|
if (indented) {
|
|
3867
3891
|
return mergeClassNames(ClassNames.ViewletSearchMessage, ClassNames.ViewletSearchMessageIndented);
|
|
@@ -3870,7 +3894,7 @@ const getClassName = indented => {
|
|
|
3870
3894
|
};
|
|
3871
3895
|
const getSearchMessageVirtualDom = (message, indented) => {
|
|
3872
3896
|
return [{
|
|
3873
|
-
type: Div,
|
|
3897
|
+
type: VirtualDomElements.Div,
|
|
3874
3898
|
className: getClassName(indented),
|
|
3875
3899
|
role: Status,
|
|
3876
3900
|
tabIndex: 0,
|
|
@@ -3880,7 +3904,7 @@ const getSearchMessageVirtualDom = (message, indented) => {
|
|
|
3880
3904
|
|
|
3881
3905
|
const getSearchHeaderDetailsCollapsedVirtualDom = message => {
|
|
3882
3906
|
return [{
|
|
3883
|
-
type: Div,
|
|
3907
|
+
type: VirtualDomElements.Div,
|
|
3884
3908
|
className: ClassNames.SearchHeaderDetails,
|
|
3885
3909
|
childCount: 2
|
|
3886
3910
|
}, ...getSearchMessageVirtualDom(message, true), ...getSearchDetailsToggleVirtualDom()];
|
|
@@ -3966,7 +3990,7 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
3966
3990
|
const role = getRole(flag);
|
|
3967
3991
|
const disabled = getDisabled(flag);
|
|
3968
3992
|
return [{
|
|
3969
|
-
type: Button
|
|
3993
|
+
type: VirtualDomElements.Button,
|
|
3970
3994
|
className: getSearchFieldButtonClassName(flag),
|
|
3971
3995
|
name,
|
|
3972
3996
|
title,
|
|
@@ -3976,7 +4000,7 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
3976
4000
|
tabIndex: 0,
|
|
3977
4001
|
childCount: 1
|
|
3978
4002
|
}, {
|
|
3979
|
-
type: Span,
|
|
4003
|
+
type: VirtualDomElements.Span,
|
|
3980
4004
|
className: mergeClassNames(ClassNames.MaskIcon, icon),
|
|
3981
4005
|
childCount: 0
|
|
3982
4006
|
}];
|
|
@@ -3991,7 +4015,7 @@ const getOutSideButtonsDom = outsideButtons => {
|
|
|
3991
4015
|
}
|
|
3992
4016
|
return {
|
|
3993
4017
|
preNodes: [{
|
|
3994
|
-
type: Div,
|
|
4018
|
+
type: VirtualDomElements.Div,
|
|
3995
4019
|
className: ClassNames.SearchFieldContainer,
|
|
3996
4020
|
role: None,
|
|
3997
4021
|
childCount: 1 + outsideButtons.length
|
|
@@ -4007,12 +4031,12 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
4007
4031
|
} = getOutSideButtonsDom(outsideButtons);
|
|
4008
4032
|
const searchFieldClassName = hasError ? mergeClassNames(ClassNames.SearchField, ClassNames.SearchFieldError) : ClassNames.SearchField;
|
|
4009
4033
|
const dom = [...preNodes, {
|
|
4010
|
-
type: Div,
|
|
4034
|
+
type: VirtualDomElements.Div,
|
|
4011
4035
|
className: searchFieldClassName,
|
|
4012
4036
|
role: None,
|
|
4013
4037
|
childCount: 2
|
|
4014
4038
|
}, {
|
|
4015
|
-
type: TextArea,
|
|
4039
|
+
type: VirtualDomElements.TextArea,
|
|
4016
4040
|
className: ClassNames.MultilineInputBox,
|
|
4017
4041
|
spellcheck: false,
|
|
4018
4042
|
autocapitalize: 'off',
|
|
@@ -4023,7 +4047,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
4023
4047
|
onFocus,
|
|
4024
4048
|
childCount: 0
|
|
4025
4049
|
}, {
|
|
4026
|
-
type: Div,
|
|
4050
|
+
type: VirtualDomElements.Div,
|
|
4027
4051
|
className: ClassNames.SearchFieldButtons,
|
|
4028
4052
|
childCount: insideButtons.length
|
|
4029
4053
|
}, ...insideButtons.flatMap(getSearchFieldButtonVirtualDom), ...postNodes];
|
|
@@ -4036,19 +4060,19 @@ const getSearchHeaderDetailsExpandedVirtualDom = (flags, message) => {
|
|
|
4036
4060
|
const includePlaceholder = include();
|
|
4037
4061
|
const excludePlaceholder = exclude();
|
|
4038
4062
|
return [{
|
|
4039
|
-
type: Div,
|
|
4063
|
+
type: VirtualDomElements.Div,
|
|
4040
4064
|
className: ClassNames.SearchHeaderDetailsExpanded,
|
|
4041
4065
|
childCount: 5
|
|
4042
4066
|
}, {
|
|
4043
|
-
type: Div,
|
|
4067
|
+
type: VirtualDomElements.Div,
|
|
4044
4068
|
className: ClassNames.SearchHeaderDetailsExpandedTop,
|
|
4045
4069
|
childCount: 2
|
|
4046
4070
|
}, ...getSearchDetailsToggleVirtualDom(), {
|
|
4047
|
-
type: H4,
|
|
4071
|
+
type: VirtualDomElements.H4,
|
|
4048
4072
|
className: ClassNames.SearchHeaderDetailsHeading,
|
|
4049
4073
|
childCount: 1
|
|
4050
4074
|
}, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, includePlaceholder, HandleInput2, includeButtons.inside, includeButtons.outside), {
|
|
4051
|
-
type: H4,
|
|
4075
|
+
type: VirtualDomElements.H4,
|
|
4052
4076
|
className: ClassNames.SearchHeaderDetailsHeading,
|
|
4053
4077
|
childCount: 1
|
|
4054
4078
|
}, text(filesToExclude()), ...getSearchFieldVirtualDom(FilesToExclude, excludePlaceholder, HandleInput2, excludeButtons.inside, excludeButtons.outside), ...getSearchMessageVirtualDom(message, false)];
|
|
@@ -4120,7 +4144,7 @@ const getSearchPlaceholder = focus => {
|
|
|
4120
4144
|
|
|
4121
4145
|
const getSearchToggleVirtualDom = replaceExpanded => {
|
|
4122
4146
|
return [{
|
|
4123
|
-
type: Button
|
|
4147
|
+
type: VirtualDomElements.Button,
|
|
4124
4148
|
className: mergeClassNames(ClassNames.IconButton, ClassNames.SearchToggleButton, replaceExpanded ? ClassNames.SearchToggleButtonExpanded : ''),
|
|
4125
4149
|
title: toggleReplace$1(),
|
|
4126
4150
|
ariaLabel: toggleReplace$1(),
|
|
@@ -4129,7 +4153,7 @@ const getSearchToggleVirtualDom = replaceExpanded => {
|
|
|
4129
4153
|
'data-command': 'toggleReplace',
|
|
4130
4154
|
name: ToggleReplace
|
|
4131
4155
|
}, {
|
|
4132
|
-
type: Div,
|
|
4156
|
+
type: VirtualDomElements.Div,
|
|
4133
4157
|
className: mergeClassNames(ClassNames.MaskIcon, replaceExpanded ? ClassNames.MaskIconChevronDown : ClassNames.MaskIconChevronRight),
|
|
4134
4158
|
childCount: 0
|
|
4135
4159
|
}];
|
|
@@ -4142,12 +4166,12 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
|
|
|
4142
4166
|
const replacePlaceholder = getReplacePlaceholder(focus);
|
|
4143
4167
|
const replaceExpanded = flags & ReplaceExpanded;
|
|
4144
4168
|
const dom = [{
|
|
4145
|
-
type: Div,
|
|
4169
|
+
type: VirtualDomElements.Div,
|
|
4146
4170
|
className: ClassNames.SearchHeaderTop,
|
|
4147
4171
|
role: None,
|
|
4148
4172
|
childCount: 2
|
|
4149
4173
|
}, ...getSearchToggleVirtualDom(replaceExpanded), {
|
|
4150
|
-
type: Div,
|
|
4174
|
+
type: VirtualDomElements.Div,
|
|
4151
4175
|
className: ClassNames.SearchHeaderTopRight,
|
|
4152
4176
|
role: None,
|
|
4153
4177
|
childCount: replaceExpanded ? 2 : 1
|
|
@@ -4159,7 +4183,7 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
|
|
|
4159
4183
|
};
|
|
4160
4184
|
|
|
4161
4185
|
const parentNode = {
|
|
4162
|
-
type: Div,
|
|
4186
|
+
type: VirtualDomElements.Div,
|
|
4163
4187
|
className: ClassNames.SearchHeader,
|
|
4164
4188
|
role: None,
|
|
4165
4189
|
childCount: 2,
|
|
@@ -4178,7 +4202,7 @@ const getSearchInputErrorVirtualDom = errorMessage => {
|
|
|
4178
4202
|
return [];
|
|
4179
4203
|
}
|
|
4180
4204
|
return [{
|
|
4181
|
-
type: Div,
|
|
4205
|
+
type: VirtualDomElements.Div,
|
|
4182
4206
|
className: ClassNames.SearchInputError,
|
|
4183
4207
|
role: Alert,
|
|
4184
4208
|
childCount: 1
|
|
@@ -4192,7 +4216,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
|
|
|
4192
4216
|
return [];
|
|
4193
4217
|
}
|
|
4194
4218
|
return [{
|
|
4195
|
-
type: Div,
|
|
4219
|
+
type: VirtualDomElements.Div,
|
|
4196
4220
|
className: mergeClassNames(ClassNames.ScrollBar, ClassNames.ScrollBarVertical),
|
|
4197
4221
|
childCount: 1,
|
|
4198
4222
|
onPointerDown: HandleScrollBarPointerDown,
|
|
@@ -4200,7 +4224,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
|
|
|
4200
4224
|
ariaControls: TreeItems,
|
|
4201
4225
|
ariaValueNow: scrollBarValue
|
|
4202
4226
|
}, {
|
|
4203
|
-
type: Div,
|
|
4227
|
+
type: VirtualDomElements.Div,
|
|
4204
4228
|
className: ClassNames.ScrollBarThumb,
|
|
4205
4229
|
height: scrollBarHeight,
|
|
4206
4230
|
translate: `0 ${scrollBarY}px`,
|
|
@@ -4221,31 +4245,43 @@ const getAriaExpanded = expanded => {
|
|
|
4221
4245
|
}
|
|
4222
4246
|
};
|
|
4223
4247
|
|
|
4224
|
-
const
|
|
4248
|
+
const badge = {
|
|
4249
|
+
type: VirtualDomElements.Div,
|
|
4250
|
+
className: mergeClassNames(ClassNames.Badge, ClassNames.SourceControlBadge),
|
|
4251
|
+
childCount: 1
|
|
4252
|
+
};
|
|
4253
|
+
const getBadgeVirtualDom = badgeText => {
|
|
4225
4254
|
if (!badgeText) {
|
|
4226
4255
|
return [];
|
|
4227
4256
|
}
|
|
4228
|
-
return [
|
|
4229
|
-
type: Div,
|
|
4230
|
-
className: mergeClassNames(ClassNames.Badge, className),
|
|
4231
|
-
childCount: 1
|
|
4232
|
-
}, text(badgeText)];
|
|
4257
|
+
return [badge, text(badgeText)];
|
|
4233
4258
|
};
|
|
4234
4259
|
|
|
4235
4260
|
const chevronDownVirtualDom = {
|
|
4236
|
-
type: Div,
|
|
4261
|
+
type: VirtualDomElements.Div,
|
|
4237
4262
|
className: mergeClassNames(ClassNames.Chevron, ClassNames.MaskIconChevronDown),
|
|
4238
4263
|
childCount: 0
|
|
4239
4264
|
};
|
|
4240
4265
|
const chevronRightVirtualDom = {
|
|
4241
|
-
type: Div,
|
|
4266
|
+
type: VirtualDomElements.Div,
|
|
4242
4267
|
className: mergeClassNames(ClassNames.Chevron, ClassNames.MaskIconChevronRight),
|
|
4243
4268
|
childCount: 0
|
|
4244
4269
|
};
|
|
4245
4270
|
|
|
4271
|
+
const getChevronVirtualDom = expanded => {
|
|
4272
|
+
switch (expanded) {
|
|
4273
|
+
case Expanded:
|
|
4274
|
+
return [chevronDownVirtualDom];
|
|
4275
|
+
case Collapsed:
|
|
4276
|
+
return [chevronRightVirtualDom];
|
|
4277
|
+
default:
|
|
4278
|
+
return [];
|
|
4279
|
+
}
|
|
4280
|
+
};
|
|
4281
|
+
|
|
4246
4282
|
const getFileIconVirtualDom = icon => {
|
|
4247
4283
|
return {
|
|
4248
|
-
type: Img,
|
|
4284
|
+
type: VirtualDomElements.Img,
|
|
4249
4285
|
className: ClassNames.FileIcon,
|
|
4250
4286
|
src: icon,
|
|
4251
4287
|
role: None,
|
|
@@ -4253,34 +4289,30 @@ const getFileIconVirtualDom = icon => {
|
|
|
4253
4289
|
};
|
|
4254
4290
|
};
|
|
4255
4291
|
|
|
4256
|
-
const getIconsVirtualDom =
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
return [chevronDownVirtualDom, getFileIconVirtualDom(icon)];
|
|
4260
|
-
case Collapsed:
|
|
4261
|
-
return [chevronRightVirtualDom, getFileIconVirtualDom(icon)];
|
|
4262
|
-
default:
|
|
4263
|
-
return [];
|
|
4292
|
+
const getIconsVirtualDom = icon => {
|
|
4293
|
+
if (icon) {
|
|
4294
|
+
return [getFileIconVirtualDom(icon)];
|
|
4264
4295
|
}
|
|
4296
|
+
return [];
|
|
4265
4297
|
};
|
|
4266
4298
|
|
|
4267
4299
|
const deleted = {
|
|
4268
|
-
type: Del,
|
|
4300
|
+
type: VirtualDomElements.Del,
|
|
4269
4301
|
className: ClassNames.HighlightDeleted,
|
|
4270
4302
|
childCount: 1
|
|
4271
4303
|
};
|
|
4272
4304
|
const inserted = {
|
|
4273
|
-
type: Ins,
|
|
4305
|
+
type: VirtualDomElements.Ins,
|
|
4274
4306
|
className: ClassNames.HighlightInserted,
|
|
4275
4307
|
childCount: 1
|
|
4276
4308
|
};
|
|
4277
4309
|
const highlighted = {
|
|
4278
|
-
type: Span,
|
|
4310
|
+
type: VirtualDomElements.Span,
|
|
4279
4311
|
className: ClassNames.Highlight,
|
|
4280
4312
|
childCount: 1
|
|
4281
4313
|
};
|
|
4282
4314
|
const label1 = {
|
|
4283
|
-
type: Div,
|
|
4315
|
+
type: VirtualDomElements.Div,
|
|
4284
4316
|
className: mergeClassNames(ClassNames.Label, ClassNames.Grow),
|
|
4285
4317
|
childCount: 1
|
|
4286
4318
|
};
|
|
@@ -4309,6 +4341,36 @@ const getPaddingLeft = depth => {
|
|
|
4309
4341
|
return `${Number(depth) + 1}rem`; // TODO use classname and dynamic css
|
|
4310
4342
|
};
|
|
4311
4343
|
|
|
4344
|
+
const getChildCount = (icon, expanded, badgeText) => {
|
|
4345
|
+
let childCount = 0;
|
|
4346
|
+
if (expanded) {
|
|
4347
|
+
childCount++; // chevron
|
|
4348
|
+
}
|
|
4349
|
+
if (icon) {
|
|
4350
|
+
childCount++; // file icon
|
|
4351
|
+
}
|
|
4352
|
+
childCount++; // label
|
|
4353
|
+
if (badgeText) {
|
|
4354
|
+
childCount++; // badge
|
|
4355
|
+
}
|
|
4356
|
+
childCount++; // remove button
|
|
4357
|
+
return childCount;
|
|
4358
|
+
};
|
|
4359
|
+
|
|
4360
|
+
const getSearchRemoveVirtualDom = () => {
|
|
4361
|
+
// TODO add title/aria label
|
|
4362
|
+
const dom = [{
|
|
4363
|
+
type: VirtualDomElements.Div,
|
|
4364
|
+
className: ClassNames.SearchRemove,
|
|
4365
|
+
childCount: 1
|
|
4366
|
+
}, {
|
|
4367
|
+
type: VirtualDomElements.Div,
|
|
4368
|
+
className: ClassNames.CloseMaskIcon,
|
|
4369
|
+
childCount: 0
|
|
4370
|
+
}];
|
|
4371
|
+
return dom;
|
|
4372
|
+
};
|
|
4373
|
+
|
|
4312
4374
|
const getSearchResultClassName = focused => {
|
|
4313
4375
|
if (focused) {
|
|
4314
4376
|
return ClassNames.TreeItem + ' ' + ClassNames.TreeItemActive;
|
|
@@ -4331,11 +4393,11 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
4331
4393
|
replacement,
|
|
4332
4394
|
focused,
|
|
4333
4395
|
expanded,
|
|
4334
|
-
childCount,
|
|
4335
4396
|
badgeText
|
|
4336
4397
|
} = rowInfo;
|
|
4398
|
+
const childCount = getChildCount(icon, expanded, badgeText);
|
|
4337
4399
|
const dom = [{
|
|
4338
|
-
type: Div,
|
|
4400
|
+
type: VirtualDomElements.Div,
|
|
4339
4401
|
role: TreeItem,
|
|
4340
4402
|
className: getSearchResultClassName(focused),
|
|
4341
4403
|
title,
|
|
@@ -4348,22 +4410,14 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
4348
4410
|
paddingLeft: getPaddingLeft(depth),
|
|
4349
4411
|
paddingRight: PaddingRight,
|
|
4350
4412
|
ariaExpanded: getAriaExpanded(expanded)
|
|
4351
|
-
}, ...
|
|
4352
|
-
type: Div,
|
|
4353
|
-
className: ClassNames.SearchRemove,
|
|
4354
|
-
childCount: 1
|
|
4355
|
-
}, {
|
|
4356
|
-
type: Div,
|
|
4357
|
-
className: ClassNames.CloseMaskIcon,
|
|
4358
|
-
childCount: 0
|
|
4359
|
-
}];
|
|
4413
|
+
}, ...getChevronVirtualDom(expanded), ...getIconsVirtualDom(icon), ...getLabelVirtualDom(displayText, matchLength, matchStart, replacement), ...getBadgeVirtualDom(badgeText), ...getSearchRemoveVirtualDom()];
|
|
4360
4414
|
return dom;
|
|
4361
4415
|
};
|
|
4362
4416
|
|
|
4363
4417
|
const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
|
|
4364
4418
|
const pixelOffset = deltaY % itemHeight;
|
|
4365
4419
|
return [{
|
|
4366
|
-
type: Div,
|
|
4420
|
+
type: VirtualDomElements.Div,
|
|
4367
4421
|
className: ClassNames.TreeItems,
|
|
4368
4422
|
childCount: visibleItems.length,
|
|
4369
4423
|
onClick: HandleClick,
|
|
@@ -4376,13 +4430,13 @@ const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
|
|
|
4376
4430
|
};
|
|
4377
4431
|
|
|
4378
4432
|
const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
|
|
4379
|
-
const
|
|
4433
|
+
const childCount = scrollbarHeight === 0 ? 1 : 2;
|
|
4380
4434
|
return [{
|
|
4381
|
-
type: Div,
|
|
4435
|
+
type: VirtualDomElements.Div,
|
|
4382
4436
|
className: mergeClassNames(ClassNames.Viewlet, ClassNames.List, ClassNames.Tree, focusOutline ? ClassNames.FocusOutline : ClassNames.Empty),
|
|
4383
4437
|
role: Tree,
|
|
4384
4438
|
tabIndex: 0,
|
|
4385
|
-
childCount
|
|
4439
|
+
childCount
|
|
4386
4440
|
}, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
|
|
4387
4441
|
};
|
|
4388
4442
|
|
|
@@ -4390,7 +4444,7 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchI
|
|
|
4390
4444
|
const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
|
|
4391
4445
|
const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
|
|
4392
4446
|
return [{
|
|
4393
|
-
type: Div,
|
|
4447
|
+
type: VirtualDomElements.Div,
|
|
4394
4448
|
className: mergeClassNames(ClassNames.Viewlet, ClassNames.Search),
|
|
4395
4449
|
childCount
|
|
4396
4450
|
}, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
|
|
@@ -4450,14 +4504,14 @@ const render2 = (uid, diffResult) => {
|
|
|
4450
4504
|
oldState,
|
|
4451
4505
|
newState
|
|
4452
4506
|
} = get$1(uid);
|
|
4453
|
-
set
|
|
4507
|
+
set(uid, newState, newState);
|
|
4454
4508
|
const commands = applyRender(oldState, newState, diffResult);
|
|
4455
4509
|
return commands;
|
|
4456
4510
|
};
|
|
4457
4511
|
|
|
4458
4512
|
const Button = 1;
|
|
4459
4513
|
|
|
4460
|
-
const getIconVirtualDom = (icon, type = Div) => {
|
|
4514
|
+
const getIconVirtualDom = (icon, type = VirtualDomElements.Div) => {
|
|
4461
4515
|
return {
|
|
4462
4516
|
type,
|
|
4463
4517
|
className: mergeClassNames(ClassNames.MaskIcon, `MaskIcon${icon}`),
|
|
@@ -4473,7 +4527,7 @@ const getActionButtonVirtualDom = action => {
|
|
|
4473
4527
|
command
|
|
4474
4528
|
} = action;
|
|
4475
4529
|
return [{
|
|
4476
|
-
type: Button
|
|
4530
|
+
type: VirtualDomElements.Button,
|
|
4477
4531
|
className: ClassNames.IconButton,
|
|
4478
4532
|
title: id,
|
|
4479
4533
|
'data-command': command,
|
|
@@ -4492,7 +4546,7 @@ const getActionVirtualDom = action => {
|
|
|
4492
4546
|
|
|
4493
4547
|
const getActionsVirtualDom = actions => {
|
|
4494
4548
|
return [{
|
|
4495
|
-
type: Div,
|
|
4549
|
+
type: VirtualDomElements.Div,
|
|
4496
4550
|
className: ClassNames.Actions,
|
|
4497
4551
|
role: ToolBar,
|
|
4498
4552
|
childCount: actions.length
|
|
@@ -4796,10 +4850,6 @@ const submit = state => {
|
|
|
4796
4850
|
});
|
|
4797
4851
|
};
|
|
4798
4852
|
|
|
4799
|
-
const terminate = () => {
|
|
4800
|
-
globalThis.close();
|
|
4801
|
-
};
|
|
4802
|
-
|
|
4803
4853
|
const viewAsTree = async state => {
|
|
4804
4854
|
return state;
|
|
4805
4855
|
};
|
|
@@ -4812,7 +4862,7 @@ const show = async (x, y, id, ...args) => {
|
|
|
4812
4862
|
number(y);
|
|
4813
4863
|
number(id);
|
|
4814
4864
|
// TODO
|
|
4815
|
-
await
|
|
4865
|
+
await showContextMenu(x, y, id, ...args);
|
|
4816
4866
|
};
|
|
4817
4867
|
|
|
4818
4868
|
const Search = 18;
|
|
@@ -4965,6 +5015,7 @@ const textSearch$1 = async (scheme, root, query, options, assetDir, platform) =>
|
|
|
4965
5015
|
// @ts-ignore
|
|
4966
5016
|
return result.results;
|
|
4967
5017
|
}
|
|
5018
|
+
// TODO always create search process messageport rpc to have one api, in web can send the messageport to renderer worker
|
|
4968
5019
|
const results = await invoke$1('SearchProcess.invoke', 'TextSearch.search', actualOptions);
|
|
4969
5020
|
// TODO api is weird
|
|
4970
5021
|
return results.results;
|
|
@@ -5000,7 +5051,7 @@ const listen = async () => {
|
|
|
5000
5051
|
const rpc = await WebWorkerRpcClient.create({
|
|
5001
5052
|
commandMap: commandMap
|
|
5002
5053
|
});
|
|
5003
|
-
set$
|
|
5054
|
+
set$1(rpc);
|
|
5004
5055
|
};
|
|
5005
5056
|
|
|
5006
5057
|
const main = async () => {
|