@lvce-editor/text-search-worker 5.33.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/textSearchWorkerMain.js +672 -523
- package/package.json +1 -1
|
@@ -243,8 +243,8 @@ const getModuleNotFoundError = stderr => {
|
|
|
243
243
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
244
244
|
const message = lines[messageIndex];
|
|
245
245
|
return {
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
247
|
+
message
|
|
248
248
|
};
|
|
249
249
|
};
|
|
250
250
|
const isModuleNotFoundError = stderr => {
|
|
@@ -267,14 +267,14 @@ const isUnhelpfulNativeModuleError = stderr => {
|
|
|
267
267
|
const getNativeModuleErrorMessage = stderr => {
|
|
268
268
|
const message = getMessageCodeBlock(stderr);
|
|
269
269
|
return {
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
271
|
+
message: `Incompatible native node module: ${message}`
|
|
272
272
|
};
|
|
273
273
|
};
|
|
274
274
|
const getModuleSyntaxError = () => {
|
|
275
275
|
return {
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
277
|
+
message: `ES Modules are not supported in electron`
|
|
278
278
|
};
|
|
279
279
|
};
|
|
280
280
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -293,8 +293,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
293
293
|
rest
|
|
294
294
|
} = getDetails(lines);
|
|
295
295
|
return {
|
|
296
|
-
message: actualMessage,
|
|
297
296
|
code: '',
|
|
297
|
+
message: actualMessage,
|
|
298
298
|
stack: rest
|
|
299
299
|
};
|
|
300
300
|
};
|
|
@@ -304,8 +304,8 @@ class IpcError extends VError {
|
|
|
304
304
|
if (stdout || stderr) {
|
|
305
305
|
// @ts-ignore
|
|
306
306
|
const {
|
|
307
|
-
message,
|
|
308
307
|
code,
|
|
308
|
+
message,
|
|
309
309
|
stack
|
|
310
310
|
} = getHelpfulChildProcessError(stdout, stderr);
|
|
311
311
|
const cause = new Error(message);
|
|
@@ -366,8 +366,8 @@ const wrap$f = global => {
|
|
|
366
366
|
};
|
|
367
367
|
const waitForFirstMessage = async port => {
|
|
368
368
|
const {
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
promise,
|
|
370
|
+
resolve
|
|
371
371
|
} = Promise.withResolvers();
|
|
372
372
|
port.addEventListener('message', resolve, {
|
|
373
373
|
once: true
|
|
@@ -387,8 +387,8 @@ const listen$6 = async () => {
|
|
|
387
387
|
const type = firstMessage.params[0];
|
|
388
388
|
if (type === 'message-port') {
|
|
389
389
|
parentIpc.send({
|
|
390
|
-
jsonrpc: '2.0',
|
|
391
390
|
id: firstMessage.id,
|
|
391
|
+
jsonrpc: '2.0',
|
|
392
392
|
result: null
|
|
393
393
|
});
|
|
394
394
|
parentIpc.dispose();
|
|
@@ -448,8 +448,8 @@ const removeListener = (emitter, type, callback) => {
|
|
|
448
448
|
};
|
|
449
449
|
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
450
450
|
const {
|
|
451
|
-
|
|
452
|
-
|
|
451
|
+
promise,
|
|
452
|
+
resolve
|
|
453
453
|
} = Promise.withResolvers();
|
|
454
454
|
const listenerMap = Object.create(null);
|
|
455
455
|
const cleanup = value => {
|
|
@@ -461,8 +461,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
461
461
|
for (const [event, type] of Object.entries(eventMap)) {
|
|
462
462
|
const listener = event => {
|
|
463
463
|
cleanup({
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
event,
|
|
465
|
+
type
|
|
466
466
|
});
|
|
467
467
|
};
|
|
468
468
|
addListener(eventEmitter, event, listener);
|
|
@@ -472,8 +472,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
472
472
|
};
|
|
473
473
|
const Message$1 = 3;
|
|
474
474
|
const create$5$1 = async ({
|
|
475
|
-
|
|
476
|
-
|
|
475
|
+
isMessagePortOpen,
|
|
476
|
+
messagePort
|
|
477
477
|
}) => {
|
|
478
478
|
if (!isMessagePort(messagePort)) {
|
|
479
479
|
throw new IpcError('port must be of type MessagePort');
|
|
@@ -486,8 +486,8 @@ const create$5$1 = async ({
|
|
|
486
486
|
});
|
|
487
487
|
messagePort.start();
|
|
488
488
|
const {
|
|
489
|
-
|
|
490
|
-
|
|
489
|
+
event,
|
|
490
|
+
type
|
|
491
491
|
} = await eventPromise;
|
|
492
492
|
if (type !== Message$1) {
|
|
493
493
|
throw new IpcError('Failed to wait for ipc message');
|
|
@@ -541,12 +541,12 @@ const parse = content => {
|
|
|
541
541
|
};
|
|
542
542
|
const waitForWebSocketToBeOpen = webSocket => {
|
|
543
543
|
return getFirstEvent(webSocket, {
|
|
544
|
-
open: Open,
|
|
545
544
|
close: Close,
|
|
546
|
-
error: Error$3
|
|
545
|
+
error: Error$3,
|
|
546
|
+
open: Open
|
|
547
547
|
});
|
|
548
548
|
};
|
|
549
|
-
const create$
|
|
549
|
+
const create$6 = async ({
|
|
550
550
|
webSocket
|
|
551
551
|
}) => {
|
|
552
552
|
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
@@ -583,60 +583,18 @@ const wrap = webSocket => {
|
|
|
583
583
|
};
|
|
584
584
|
const IpcParentWithWebSocket$1 = {
|
|
585
585
|
__proto__: null,
|
|
586
|
-
create: create$
|
|
586
|
+
create: create$6,
|
|
587
587
|
wrap
|
|
588
588
|
};
|
|
589
589
|
|
|
590
|
-
const Two = '2.0';
|
|
591
|
-
const create$4$1 = (method, params) => {
|
|
592
|
-
return {
|
|
593
|
-
jsonrpc: Two,
|
|
594
|
-
method,
|
|
595
|
-
params
|
|
596
|
-
};
|
|
597
|
-
};
|
|
590
|
+
const Two$1 = '2.0';
|
|
598
591
|
const callbacks = Object.create(null);
|
|
599
|
-
const set$4 = (id, fn) => {
|
|
600
|
-
callbacks[id] = fn;
|
|
601
|
-
};
|
|
602
592
|
const get$3 = id => {
|
|
603
593
|
return callbacks[id];
|
|
604
594
|
};
|
|
605
|
-
const remove$
|
|
595
|
+
const remove$3 = id => {
|
|
606
596
|
delete callbacks[id];
|
|
607
597
|
};
|
|
608
|
-
let id = 0;
|
|
609
|
-
const create$3$2 = () => {
|
|
610
|
-
return ++id;
|
|
611
|
-
};
|
|
612
|
-
const registerPromise = () => {
|
|
613
|
-
const id = create$3$2();
|
|
614
|
-
const {
|
|
615
|
-
resolve,
|
|
616
|
-
promise
|
|
617
|
-
} = Promise.withResolvers();
|
|
618
|
-
set$4(id, resolve);
|
|
619
|
-
return {
|
|
620
|
-
id,
|
|
621
|
-
promise
|
|
622
|
-
};
|
|
623
|
-
};
|
|
624
|
-
const create$2$2 = (method, params) => {
|
|
625
|
-
const {
|
|
626
|
-
id,
|
|
627
|
-
promise
|
|
628
|
-
} = registerPromise();
|
|
629
|
-
const message = {
|
|
630
|
-
jsonrpc: Two,
|
|
631
|
-
method,
|
|
632
|
-
params,
|
|
633
|
-
id
|
|
634
|
-
};
|
|
635
|
-
return {
|
|
636
|
-
message,
|
|
637
|
-
promise
|
|
638
|
-
};
|
|
639
|
-
};
|
|
640
598
|
class JsonRpcError extends Error {
|
|
641
599
|
constructor(message) {
|
|
642
600
|
super(message);
|
|
@@ -787,7 +745,7 @@ const resolve = (id, response) => {
|
|
|
787
745
|
return;
|
|
788
746
|
}
|
|
789
747
|
fn(response);
|
|
790
|
-
remove$
|
|
748
|
+
remove$3(id);
|
|
791
749
|
};
|
|
792
750
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
793
751
|
const getErrorType = prettyError => {
|
|
@@ -832,7 +790,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
832
790
|
};
|
|
833
791
|
const create$1$2 = (id, error) => {
|
|
834
792
|
return {
|
|
835
|
-
jsonrpc: Two,
|
|
793
|
+
jsonrpc: Two$1,
|
|
836
794
|
id,
|
|
837
795
|
error
|
|
838
796
|
};
|
|
@@ -843,20 +801,20 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
843
801
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
844
802
|
return create$1$2(id, errorProperty);
|
|
845
803
|
};
|
|
846
|
-
const create$
|
|
804
|
+
const create$5 = (message, result) => {
|
|
847
805
|
return {
|
|
848
|
-
jsonrpc: Two,
|
|
806
|
+
jsonrpc: Two$1,
|
|
849
807
|
id: message.id,
|
|
850
808
|
result: result ?? null
|
|
851
809
|
};
|
|
852
810
|
};
|
|
853
811
|
const getSuccessResponse = (message, result) => {
|
|
854
812
|
const resultProperty = result ?? null;
|
|
855
|
-
return create$
|
|
813
|
+
return create$5(message, resultProperty);
|
|
856
814
|
};
|
|
857
815
|
const getErrorResponseSimple = (id, error) => {
|
|
858
816
|
return {
|
|
859
|
-
jsonrpc: Two,
|
|
817
|
+
jsonrpc: Two$1,
|
|
860
818
|
id,
|
|
861
819
|
error: {
|
|
862
820
|
code: Custom,
|
|
@@ -943,29 +901,6 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
943
901
|
}
|
|
944
902
|
throw new JsonRpcError('unexpected message');
|
|
945
903
|
};
|
|
946
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
947
|
-
const {
|
|
948
|
-
message,
|
|
949
|
-
promise
|
|
950
|
-
} = create$2$2(method, params);
|
|
951
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
952
|
-
ipc.sendAndTransfer(message);
|
|
953
|
-
} else {
|
|
954
|
-
ipc.send(message);
|
|
955
|
-
}
|
|
956
|
-
const responseMessage = await promise;
|
|
957
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
958
|
-
};
|
|
959
|
-
const send$1 = (transport, method, ...params) => {
|
|
960
|
-
const message = create$4$1(method, params);
|
|
961
|
-
transport.send(message);
|
|
962
|
-
};
|
|
963
|
-
const invoke$3 = (ipc, method, ...params) => {
|
|
964
|
-
return invokeHelper(ipc, method, params, false);
|
|
965
|
-
};
|
|
966
|
-
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
967
|
-
return invokeHelper(ipc, method, params, true);
|
|
968
|
-
};
|
|
969
904
|
|
|
970
905
|
class CommandNotFoundError extends Error {
|
|
971
906
|
constructor(command) {
|
|
@@ -988,24 +923,87 @@ const execute = (command, ...args) => {
|
|
|
988
923
|
return fn(...args);
|
|
989
924
|
};
|
|
990
925
|
|
|
926
|
+
const Two = '2.0';
|
|
927
|
+
const create$s = (method, params) => {
|
|
928
|
+
return {
|
|
929
|
+
jsonrpc: Two,
|
|
930
|
+
method,
|
|
931
|
+
params
|
|
932
|
+
};
|
|
933
|
+
};
|
|
934
|
+
const create$r = (id, method, params) => {
|
|
935
|
+
const message = {
|
|
936
|
+
id,
|
|
937
|
+
jsonrpc: Two,
|
|
938
|
+
method,
|
|
939
|
+
params
|
|
940
|
+
};
|
|
941
|
+
return message;
|
|
942
|
+
};
|
|
943
|
+
let id = 0;
|
|
944
|
+
const create$q = () => {
|
|
945
|
+
return ++id;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
949
|
+
|
|
950
|
+
const registerPromise = map => {
|
|
951
|
+
const id = create$q();
|
|
952
|
+
const {
|
|
953
|
+
promise,
|
|
954
|
+
resolve
|
|
955
|
+
} = Promise.withResolvers();
|
|
956
|
+
map[id] = resolve;
|
|
957
|
+
return {
|
|
958
|
+
id,
|
|
959
|
+
promise
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
// @ts-ignore
|
|
964
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
965
|
+
const {
|
|
966
|
+
id,
|
|
967
|
+
promise
|
|
968
|
+
} = registerPromise(callbacks);
|
|
969
|
+
const message = create$r(id, method, params);
|
|
970
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
971
|
+
ipc.sendAndTransfer(message);
|
|
972
|
+
} else {
|
|
973
|
+
ipc.send(message);
|
|
974
|
+
}
|
|
975
|
+
const responseMessage = await promise;
|
|
976
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
977
|
+
};
|
|
991
978
|
const createRpc = ipc => {
|
|
979
|
+
const callbacks = Object.create(null);
|
|
980
|
+
ipc._resolve = (id, response) => {
|
|
981
|
+
const fn = callbacks[id];
|
|
982
|
+
if (!fn) {
|
|
983
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
fn(response);
|
|
987
|
+
delete callbacks[id];
|
|
988
|
+
};
|
|
992
989
|
const rpc = {
|
|
990
|
+
async dispose() {
|
|
991
|
+
await ipc?.dispose();
|
|
992
|
+
},
|
|
993
|
+
invoke(method, ...params) {
|
|
994
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
995
|
+
},
|
|
996
|
+
invokeAndTransfer(method, ...params) {
|
|
997
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
998
|
+
},
|
|
993
999
|
// @ts-ignore
|
|
994
1000
|
ipc,
|
|
995
1001
|
/**
|
|
996
1002
|
* @deprecated
|
|
997
1003
|
*/
|
|
998
1004
|
send(method, ...params) {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
invoke(method, ...params) {
|
|
1002
|
-
return invoke$3(ipc, method, ...params);
|
|
1003
|
-
},
|
|
1004
|
-
invokeAndTransfer(method, ...params) {
|
|
1005
|
-
return invokeAndTransfer$1(ipc, method, ...params);
|
|
1006
|
-
},
|
|
1007
|
-
async dispose() {
|
|
1008
|
-
await ipc?.dispose();
|
|
1005
|
+
const message = create$s(method, params);
|
|
1006
|
+
ipc.send(message);
|
|
1009
1007
|
}
|
|
1010
1008
|
};
|
|
1011
1009
|
return rpc;
|
|
@@ -1022,7 +1020,7 @@ const logError = () => {
|
|
|
1022
1020
|
const handleMessage = event => {
|
|
1023
1021
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1024
1022
|
const actualExecute = event?.target?.execute || execute;
|
|
1025
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
1023
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1026
1024
|
};
|
|
1027
1025
|
const handleIpc = ipc => {
|
|
1028
1026
|
if ('addEventListener' in ipc) {
|
|
@@ -1040,53 +1038,52 @@ const listen$1 = async (module, options) => {
|
|
|
1040
1038
|
const ipc = module.wrap(rawIpc);
|
|
1041
1039
|
return ipc;
|
|
1042
1040
|
};
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1041
|
+
|
|
1042
|
+
/* eslint-disable @typescript-eslint/no-misused-promises */
|
|
1043
|
+
|
|
1044
|
+
const createSharedLazyRpc = factory => {
|
|
1045
|
+
let rpcPromise;
|
|
1046
|
+
const getOrCreate = () => {
|
|
1047
|
+
if (!rpcPromise) {
|
|
1048
|
+
rpcPromise = factory();
|
|
1049
|
+
}
|
|
1050
|
+
return rpcPromise;
|
|
1051
|
+
};
|
|
1052
|
+
return {
|
|
1053
|
+
async dispose() {
|
|
1054
|
+
const rpc = await getOrCreate();
|
|
1055
|
+
await rpc.dispose();
|
|
1056
|
+
},
|
|
1057
|
+
async invoke(method, ...params) {
|
|
1058
|
+
const rpc = await getOrCreate();
|
|
1059
|
+
return rpc.invoke(method, ...params);
|
|
1060
|
+
},
|
|
1061
|
+
async invokeAndTransfer(method, ...params) {
|
|
1062
|
+
const rpc = await getOrCreate();
|
|
1063
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1064
|
+
},
|
|
1065
|
+
async send(method, ...params) {
|
|
1066
|
+
const rpc = await getOrCreate();
|
|
1067
|
+
rpc.send(method, ...params);
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1058
1070
|
};
|
|
1059
|
-
const create$
|
|
1071
|
+
const create$i = async ({
|
|
1060
1072
|
commandMap,
|
|
1073
|
+
isMessagePortOpen,
|
|
1061
1074
|
send
|
|
1062
1075
|
}) => {
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
commandMap,
|
|
1070
|
-
messagePort: port2
|
|
1076
|
+
return createSharedLazyRpc(() => {
|
|
1077
|
+
return create$2$1({
|
|
1078
|
+
commandMap,
|
|
1079
|
+
isMessagePortOpen,
|
|
1080
|
+
send
|
|
1081
|
+
});
|
|
1071
1082
|
});
|
|
1072
1083
|
};
|
|
1073
|
-
const
|
|
1084
|
+
const LazyTransferMessagePortRpcParent = {
|
|
1074
1085
|
__proto__: null,
|
|
1075
|
-
create: create$
|
|
1076
|
-
};
|
|
1077
|
-
const create$2$1 = async ({
|
|
1078
|
-
commandMap,
|
|
1079
|
-
webSocket
|
|
1080
|
-
}) => {
|
|
1081
|
-
// TODO create a commandMap per rpc instance
|
|
1082
|
-
register(commandMap);
|
|
1083
|
-
const rawIpc = await IpcParentWithWebSocket$1.create({
|
|
1084
|
-
webSocket
|
|
1085
|
-
});
|
|
1086
|
-
const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
|
|
1087
|
-
handleIpc(ipc);
|
|
1088
|
-
const rpc = createRpc(ipc);
|
|
1089
|
-
return rpc;
|
|
1086
|
+
create: create$i
|
|
1090
1087
|
};
|
|
1091
1088
|
const Https = 'https:';
|
|
1092
1089
|
const Ws = 'ws:';
|
|
@@ -1104,7 +1101,21 @@ const getHost = () => {
|
|
|
1104
1101
|
const getProtocol$1 = () => {
|
|
1105
1102
|
return location.protocol;
|
|
1106
1103
|
};
|
|
1107
|
-
const create$
|
|
1104
|
+
const create$h = async ({
|
|
1105
|
+
commandMap,
|
|
1106
|
+
webSocket
|
|
1107
|
+
}) => {
|
|
1108
|
+
// TODO create a commandMap per rpc instance
|
|
1109
|
+
register(commandMap);
|
|
1110
|
+
const rawIpc = await IpcParentWithWebSocket$1.create({
|
|
1111
|
+
webSocket
|
|
1112
|
+
});
|
|
1113
|
+
const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
|
|
1114
|
+
handleIpc(ipc);
|
|
1115
|
+
const rpc = createRpc(ipc);
|
|
1116
|
+
return rpc;
|
|
1117
|
+
};
|
|
1118
|
+
const create$g = async ({
|
|
1108
1119
|
commandMap,
|
|
1109
1120
|
type
|
|
1110
1121
|
}) => {
|
|
@@ -1112,17 +1123,65 @@ const create$1$1 = async ({
|
|
|
1112
1123
|
const protocol = getProtocol$1();
|
|
1113
1124
|
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1114
1125
|
const webSocket = new WebSocket(wsUrl);
|
|
1115
|
-
const rpc = await create$
|
|
1116
|
-
|
|
1117
|
-
|
|
1126
|
+
const rpc = await create$h({
|
|
1127
|
+
commandMap,
|
|
1128
|
+
webSocket
|
|
1118
1129
|
});
|
|
1119
1130
|
return rpc;
|
|
1120
1131
|
};
|
|
1121
|
-
const
|
|
1132
|
+
const create$f = async ({
|
|
1133
|
+
commandMap,
|
|
1134
|
+
type
|
|
1135
|
+
}) => {
|
|
1136
|
+
return createSharedLazyRpc(() => {
|
|
1137
|
+
return create$g({
|
|
1138
|
+
commandMap,
|
|
1139
|
+
type
|
|
1140
|
+
});
|
|
1141
|
+
});
|
|
1142
|
+
};
|
|
1143
|
+
const LazyWebSocketRpcParent2 = {
|
|
1122
1144
|
__proto__: null,
|
|
1123
|
-
create: create$
|
|
1145
|
+
create: create$f
|
|
1124
1146
|
};
|
|
1125
1147
|
const create$4 = async ({
|
|
1148
|
+
commandMap,
|
|
1149
|
+
isMessagePortOpen = true,
|
|
1150
|
+
messagePort
|
|
1151
|
+
}) => {
|
|
1152
|
+
// TODO create a commandMap per rpc instance
|
|
1153
|
+
register(commandMap);
|
|
1154
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1155
|
+
isMessagePortOpen,
|
|
1156
|
+
messagePort
|
|
1157
|
+
});
|
|
1158
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1159
|
+
handleIpc(ipc);
|
|
1160
|
+
const rpc = createRpc(ipc);
|
|
1161
|
+
messagePort.start();
|
|
1162
|
+
return rpc;
|
|
1163
|
+
};
|
|
1164
|
+
const create$2$1 = async ({
|
|
1165
|
+
commandMap,
|
|
1166
|
+
isMessagePortOpen,
|
|
1167
|
+
send
|
|
1168
|
+
}) => {
|
|
1169
|
+
const {
|
|
1170
|
+
port1,
|
|
1171
|
+
port2
|
|
1172
|
+
} = new MessageChannel();
|
|
1173
|
+
await send(port1);
|
|
1174
|
+
return create$4({
|
|
1175
|
+
commandMap,
|
|
1176
|
+
isMessagePortOpen,
|
|
1177
|
+
messagePort: port2
|
|
1178
|
+
});
|
|
1179
|
+
};
|
|
1180
|
+
const TransferMessagePortRpcParent = {
|
|
1181
|
+
__proto__: null,
|
|
1182
|
+
create: create$2$1
|
|
1183
|
+
};
|
|
1184
|
+
const create$1$1 = async ({
|
|
1126
1185
|
commandMap
|
|
1127
1186
|
}) => {
|
|
1128
1187
|
// TODO create a commandMap per rpc instance
|
|
@@ -1134,7 +1193,26 @@ const create$4 = async ({
|
|
|
1134
1193
|
};
|
|
1135
1194
|
const WebWorkerRpcClient = {
|
|
1136
1195
|
__proto__: null,
|
|
1137
|
-
create: create$
|
|
1196
|
+
create: create$1$1
|
|
1197
|
+
};
|
|
1198
|
+
const createMockRpc = ({
|
|
1199
|
+
commandMap
|
|
1200
|
+
}) => {
|
|
1201
|
+
const invocations = [];
|
|
1202
|
+
const invoke = (method, ...params) => {
|
|
1203
|
+
invocations.push([method, ...params]);
|
|
1204
|
+
const command = commandMap[method];
|
|
1205
|
+
if (!command) {
|
|
1206
|
+
throw new Error(`command ${method} not found`);
|
|
1207
|
+
}
|
|
1208
|
+
return command(...params);
|
|
1209
|
+
};
|
|
1210
|
+
const mockRpc = {
|
|
1211
|
+
invocations,
|
|
1212
|
+
invoke,
|
|
1213
|
+
invokeAndTransfer: invoke
|
|
1214
|
+
};
|
|
1215
|
+
return mockRpc;
|
|
1138
1216
|
};
|
|
1139
1217
|
|
|
1140
1218
|
const Alert = 'alert';
|
|
@@ -1241,9 +1319,9 @@ const LeftClick = 0;
|
|
|
1241
1319
|
const Electron = 2;
|
|
1242
1320
|
const Remote = 3;
|
|
1243
1321
|
|
|
1322
|
+
const IconThemeWorker = 7009;
|
|
1244
1323
|
const RendererWorker = 1;
|
|
1245
1324
|
const SearchProcess = 77;
|
|
1246
|
-
const IconThemeWorker = 7009;
|
|
1247
1325
|
|
|
1248
1326
|
const File$1 = 1;
|
|
1249
1327
|
const Match$1 = 2;
|
|
@@ -1271,15 +1349,23 @@ const FocusToggleDetails = 1010;
|
|
|
1271
1349
|
const FocusToggleReplace = 1020;
|
|
1272
1350
|
|
|
1273
1351
|
const rpcs = Object.create(null);
|
|
1274
|
-
const set$
|
|
1352
|
+
const set$4 = (id, rpc) => {
|
|
1275
1353
|
rpcs[id] = rpc;
|
|
1276
1354
|
};
|
|
1277
1355
|
const get$2 = id => {
|
|
1278
1356
|
return rpcs[id];
|
|
1279
1357
|
};
|
|
1358
|
+
const remove$2 = id => {
|
|
1359
|
+
delete rpcs[id];
|
|
1360
|
+
};
|
|
1280
1361
|
|
|
1362
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1281
1363
|
const create$3 = rpcId => {
|
|
1282
1364
|
return {
|
|
1365
|
+
async dispose() {
|
|
1366
|
+
const rpc = get$2(rpcId);
|
|
1367
|
+
await rpc.dispose();
|
|
1368
|
+
},
|
|
1283
1369
|
// @ts-ignore
|
|
1284
1370
|
invoke(method, ...params) {
|
|
1285
1371
|
const rpc = get$2(rpcId);
|
|
@@ -1292,19 +1378,28 @@ const create$3 = rpcId => {
|
|
|
1292
1378
|
// @ts-ignore
|
|
1293
1379
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1294
1380
|
},
|
|
1295
|
-
|
|
1296
|
-
|
|
1381
|
+
registerMockRpc(commandMap) {
|
|
1382
|
+
const mockRpc = createMockRpc({
|
|
1383
|
+
commandMap
|
|
1384
|
+
});
|
|
1385
|
+
set$4(rpcId, mockRpc);
|
|
1386
|
+
// @ts-ignore
|
|
1387
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1388
|
+
remove$2(rpcId);
|
|
1389
|
+
};
|
|
1390
|
+
// @ts-ignore
|
|
1391
|
+
return mockRpc;
|
|
1297
1392
|
},
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
await rpc.dispose();
|
|
1393
|
+
set(rpc) {
|
|
1394
|
+
set$4(rpcId, rpc);
|
|
1301
1395
|
}
|
|
1302
1396
|
};
|
|
1303
1397
|
};
|
|
1304
1398
|
|
|
1305
1399
|
const {
|
|
1306
1400
|
invoke: invoke$2,
|
|
1307
|
-
set: set$
|
|
1401
|
+
set: set$3
|
|
1402
|
+
} = create$3(IconThemeWorker);
|
|
1308
1403
|
const getIcons = async iconRequests => {
|
|
1309
1404
|
// @ts-ignore
|
|
1310
1405
|
return invoke$2('IconTheme.getIcons', iconRequests);
|
|
@@ -1313,7 +1408,8 @@ const getIcons = async iconRequests => {
|
|
|
1313
1408
|
const {
|
|
1314
1409
|
invoke: invoke$1,
|
|
1315
1410
|
invokeAndTransfer,
|
|
1316
|
-
set: set$
|
|
1411
|
+
set: set$2
|
|
1412
|
+
} = create$3(RendererWorker);
|
|
1317
1413
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1318
1414
|
number(uid);
|
|
1319
1415
|
number(menuId);
|
|
@@ -1340,30 +1436,10 @@ const openUri$1 = async (uri, focus, options) => {
|
|
|
1340
1436
|
await invoke$1('Main.openUri', uri, focus, options);
|
|
1341
1437
|
};
|
|
1342
1438
|
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
const rpc = await factory();
|
|
1348
|
-
set$3(rpcId, rpc);
|
|
1349
|
-
};
|
|
1350
|
-
const ensureRpc = async () => {
|
|
1351
|
-
if (!rpcPromise) {
|
|
1352
|
-
rpcPromise = createRpc();
|
|
1353
|
-
}
|
|
1354
|
-
await rpcPromise;
|
|
1355
|
-
};
|
|
1356
|
-
return {
|
|
1357
|
-
setFactory(value) {
|
|
1358
|
-
factory = value;
|
|
1359
|
-
},
|
|
1360
|
-
async invoke(method, ...params) {
|
|
1361
|
-
await ensureRpc();
|
|
1362
|
-
const rpc = get$2(rpcId);
|
|
1363
|
-
return rpc.invoke(method, ...params);
|
|
1364
|
-
}
|
|
1365
|
-
};
|
|
1366
|
-
};
|
|
1439
|
+
const {
|
|
1440
|
+
invoke,
|
|
1441
|
+
set: set$1
|
|
1442
|
+
} = create$3(SearchProcess);
|
|
1367
1443
|
|
|
1368
1444
|
const toCommandId = key => {
|
|
1369
1445
|
const dotIndex = key.indexOf('.');
|
|
@@ -1456,13 +1532,14 @@ const mergeClassNames = (...classNames) => {
|
|
|
1456
1532
|
|
|
1457
1533
|
const text = data => {
|
|
1458
1534
|
return {
|
|
1459
|
-
|
|
1535
|
+
childCount: 0,
|
|
1460
1536
|
text: data,
|
|
1461
|
-
|
|
1537
|
+
type: Text
|
|
1462
1538
|
};
|
|
1463
1539
|
};
|
|
1464
1540
|
|
|
1465
1541
|
const SetText = 1;
|
|
1542
|
+
const Replace$1 = 2;
|
|
1466
1543
|
const SetAttribute = 3;
|
|
1467
1544
|
const RemoveAttribute = 4;
|
|
1468
1545
|
const Add = 6;
|
|
@@ -1471,24 +1548,6 @@ const NavigateParent = 8;
|
|
|
1471
1548
|
const RemoveChild = 9;
|
|
1472
1549
|
const NavigateSibling = 10;
|
|
1473
1550
|
|
|
1474
|
-
const applyPendingPatches = (patches, pendingPatches, skip) => {
|
|
1475
|
-
for (let k = 0; k < pendingPatches.length - skip; k += 2) {
|
|
1476
|
-
const type = pendingPatches[k];
|
|
1477
|
-
const index = pendingPatches[k + 1];
|
|
1478
|
-
if (type === NavigateParent) {
|
|
1479
|
-
patches.push({
|
|
1480
|
-
type
|
|
1481
|
-
});
|
|
1482
|
-
} else {
|
|
1483
|
-
patches.push({
|
|
1484
|
-
type,
|
|
1485
|
-
index
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
pendingPatches.length = 0;
|
|
1490
|
-
};
|
|
1491
|
-
|
|
1492
1551
|
const isKey = key => {
|
|
1493
1552
|
return key !== 'type' && key !== 'childCount';
|
|
1494
1553
|
};
|
|
@@ -1498,208 +1557,402 @@ const getKeys = node => {
|
|
|
1498
1557
|
return keys;
|
|
1499
1558
|
};
|
|
1500
1559
|
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1503
|
-
let
|
|
1504
|
-
while (
|
|
1560
|
+
const arrayToTree = nodes => {
|
|
1561
|
+
const result = [];
|
|
1562
|
+
let i = 0;
|
|
1563
|
+
while (i < nodes.length) {
|
|
1564
|
+
const node = nodes[i];
|
|
1565
|
+
const {
|
|
1566
|
+
children,
|
|
1567
|
+
nodesConsumed
|
|
1568
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
1569
|
+
result.push({
|
|
1570
|
+
node,
|
|
1571
|
+
children
|
|
1572
|
+
});
|
|
1573
|
+
i += 1 + nodesConsumed;
|
|
1574
|
+
}
|
|
1575
|
+
return result;
|
|
1576
|
+
};
|
|
1577
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
1578
|
+
if (childCount === 0) {
|
|
1579
|
+
return {
|
|
1580
|
+
children: [],
|
|
1581
|
+
nodesConsumed: 0
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
const children = [];
|
|
1585
|
+
let i = startIndex;
|
|
1586
|
+
let remaining = childCount;
|
|
1587
|
+
let totalConsumed = 0;
|
|
1588
|
+
while (remaining > 0 && i < nodes.length) {
|
|
1505
1589
|
const node = nodes[i];
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1590
|
+
const nodeChildCount = node.childCount || 0;
|
|
1591
|
+
const {
|
|
1592
|
+
children: nodeChildren,
|
|
1593
|
+
nodesConsumed
|
|
1594
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
1595
|
+
children.push({
|
|
1596
|
+
node,
|
|
1597
|
+
children: nodeChildren
|
|
1598
|
+
});
|
|
1599
|
+
const nodeSize = 1 + nodesConsumed;
|
|
1600
|
+
i += nodeSize;
|
|
1601
|
+
totalConsumed += nodeSize;
|
|
1602
|
+
remaining--;
|
|
1509
1603
|
}
|
|
1510
|
-
return
|
|
1604
|
+
return {
|
|
1605
|
+
children,
|
|
1606
|
+
nodesConsumed: totalConsumed
|
|
1607
|
+
};
|
|
1511
1608
|
};
|
|
1512
1609
|
|
|
1513
|
-
const
|
|
1610
|
+
const compareNodes = (oldNode, newNode) => {
|
|
1514
1611
|
const patches = [];
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
indexStack.pop();
|
|
1528
|
-
pendingPatches.push(NavigateParent, 0);
|
|
1529
|
-
maxSiblingOffset = indexStack.pop();
|
|
1530
|
-
siblingOffset = indexStack.pop() + 1;
|
|
1531
|
-
}
|
|
1532
|
-
while (siblingOffset === maxSiblingOffset) {
|
|
1533
|
-
pendingPatches.push(NavigateParent, 0);
|
|
1534
|
-
maxSiblingOffset = indexStack.pop();
|
|
1535
|
-
siblingOffset = indexStack.pop() + 1;
|
|
1612
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
1613
|
+
// (caller should handle this with a Replace operation)
|
|
1614
|
+
if (oldNode.type !== newNode.type) {
|
|
1615
|
+
return null;
|
|
1616
|
+
}
|
|
1617
|
+
// Handle text nodes
|
|
1618
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
1619
|
+
if (oldNode.text !== newNode.text) {
|
|
1620
|
+
patches.push({
|
|
1621
|
+
type: SetText,
|
|
1622
|
+
value: newNode.text
|
|
1623
|
+
});
|
|
1536
1624
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1625
|
+
return patches;
|
|
1626
|
+
}
|
|
1627
|
+
// Compare attributes
|
|
1628
|
+
const oldKeys = getKeys(oldNode);
|
|
1629
|
+
const newKeys = getKeys(newNode);
|
|
1630
|
+
// Check for attribute changes
|
|
1631
|
+
for (const key of newKeys) {
|
|
1632
|
+
if (oldNode[key] !== newNode[key]) {
|
|
1545
1633
|
patches.push({
|
|
1546
|
-
type:
|
|
1547
|
-
|
|
1634
|
+
type: SetAttribute,
|
|
1635
|
+
key,
|
|
1636
|
+
value: newNode[key]
|
|
1548
1637
|
});
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
// Check for removed attributes
|
|
1641
|
+
for (const key of oldKeys) {
|
|
1642
|
+
if (!(key in newNode)) {
|
|
1549
1643
|
patches.push({
|
|
1550
|
-
type:
|
|
1551
|
-
|
|
1644
|
+
type: RemoveAttribute,
|
|
1645
|
+
key
|
|
1552
1646
|
});
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
return patches;
|
|
1650
|
+
};
|
|
1651
|
+
|
|
1652
|
+
const treeToArray = node => {
|
|
1653
|
+
const result = [node.node];
|
|
1654
|
+
for (const child of node.children) {
|
|
1655
|
+
result.push(...treeToArray(child));
|
|
1656
|
+
}
|
|
1657
|
+
return result;
|
|
1658
|
+
};
|
|
1659
|
+
|
|
1660
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
1661
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
1662
|
+
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
1663
|
+
let currentChildIndex = -1;
|
|
1664
|
+
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
1665
|
+
const indicesToRemove = [];
|
|
1666
|
+
for (let i = 0; i < maxLength; i++) {
|
|
1667
|
+
const oldNode = oldChildren[i];
|
|
1668
|
+
const newNode = newChildren[i];
|
|
1669
|
+
if (!oldNode && !newNode) {
|
|
1556
1670
|
continue;
|
|
1557
1671
|
}
|
|
1558
|
-
if (oldNode
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
}
|
|
1563
|
-
applyPendingPatches(patches, pendingPatches, 0);
|
|
1672
|
+
if (!oldNode) {
|
|
1673
|
+
// Add new node - we should be at the parent
|
|
1674
|
+
if (currentChildIndex >= 0) {
|
|
1675
|
+
// Navigate back to parent
|
|
1564
1676
|
patches.push({
|
|
1565
|
-
type:
|
|
1566
|
-
value: newNode.text
|
|
1677
|
+
type: NavigateParent
|
|
1567
1678
|
});
|
|
1679
|
+
currentChildIndex = -1;
|
|
1568
1680
|
}
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
}
|
|
1583
|
-
for (const key of oldKeys) {
|
|
1584
|
-
if (!(key in newNode)) {
|
|
1585
|
-
hasAttributeChanges = true;
|
|
1586
|
-
break;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
if (hasAttributeChanges) {
|
|
1590
|
-
if (siblingOffset > 0) {
|
|
1591
|
-
pendingPatches.push(NavigateSibling, siblingOffset);
|
|
1592
|
-
}
|
|
1593
|
-
applyPendingPatches(patches, pendingPatches, 0);
|
|
1594
|
-
for (const key of newKeys) {
|
|
1595
|
-
if (oldNode[key] !== newNode[key]) {
|
|
1681
|
+
// Flatten the entire subtree so renderInternal can handle it
|
|
1682
|
+
const flatNodes = treeToArray(newNode);
|
|
1683
|
+
patches.push({
|
|
1684
|
+
type: Add,
|
|
1685
|
+
nodes: flatNodes
|
|
1686
|
+
});
|
|
1687
|
+
} else if (newNode) {
|
|
1688
|
+
// Compare nodes to see if we need any patches
|
|
1689
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1690
|
+
// If nodePatches is null, the node types are incompatible - need to replace
|
|
1691
|
+
if (nodePatches === null) {
|
|
1692
|
+
// Navigate to this child
|
|
1693
|
+
if (currentChildIndex === -1) {
|
|
1596
1694
|
patches.push({
|
|
1597
|
-
type:
|
|
1598
|
-
|
|
1599
|
-
value: newNode[key]
|
|
1695
|
+
type: NavigateChild,
|
|
1696
|
+
index: i
|
|
1600
1697
|
});
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
for (const key of oldKeys) {
|
|
1604
|
-
if (!(key in newNode)) {
|
|
1698
|
+
currentChildIndex = i;
|
|
1699
|
+
} else if (currentChildIndex !== i) {
|
|
1605
1700
|
patches.push({
|
|
1606
|
-
type:
|
|
1607
|
-
|
|
1701
|
+
type: NavigateSibling,
|
|
1702
|
+
index: i
|
|
1608
1703
|
});
|
|
1704
|
+
currentChildIndex = i;
|
|
1609
1705
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
if (oldNode.childCount && newNode.childCount) {
|
|
1613
|
-
maxSiblingOffset = oldNode.childCount;
|
|
1614
|
-
indexStack.push(0, maxSiblingOffset);
|
|
1615
|
-
pendingPatches.push(NavigateChild, 0);
|
|
1616
|
-
i++;
|
|
1617
|
-
j++;
|
|
1618
|
-
continue;
|
|
1619
|
-
}
|
|
1620
|
-
if (oldNode.childCount) {
|
|
1621
|
-
applyPendingPatches(patches, pendingPatches, 0);
|
|
1622
|
-
for (let k = 0; k < oldNode.childCount; k++) {
|
|
1706
|
+
// Replace the entire subtree
|
|
1707
|
+
const flatNodes = treeToArray(newNode);
|
|
1623
1708
|
patches.push({
|
|
1624
|
-
type:
|
|
1625
|
-
|
|
1709
|
+
type: Replace$1,
|
|
1710
|
+
nodes: flatNodes
|
|
1626
1711
|
});
|
|
1712
|
+
// After replace, we're at the new element (same position)
|
|
1713
|
+
continue;
|
|
1627
1714
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1715
|
+
// Check if we need to recurse into children
|
|
1716
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
1717
|
+
// Only navigate to this element if we need to do something
|
|
1718
|
+
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
1719
|
+
// Navigate to this child if not already there
|
|
1720
|
+
if (currentChildIndex === -1) {
|
|
1721
|
+
patches.push({
|
|
1722
|
+
type: NavigateChild,
|
|
1723
|
+
index: i
|
|
1724
|
+
});
|
|
1725
|
+
currentChildIndex = i;
|
|
1726
|
+
} else if (currentChildIndex !== i) {
|
|
1727
|
+
patches.push({
|
|
1728
|
+
type: NavigateSibling,
|
|
1729
|
+
index: i
|
|
1730
|
+
});
|
|
1731
|
+
currentChildIndex = i;
|
|
1732
|
+
}
|
|
1733
|
+
// Apply node patches (these apply to the current element, not children)
|
|
1734
|
+
if (nodePatches.length > 0) {
|
|
1735
|
+
patches.push(...nodePatches);
|
|
1736
|
+
}
|
|
1737
|
+
// Compare children recursively
|
|
1738
|
+
if (hasChildrenToCompare) {
|
|
1739
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
} else {
|
|
1743
|
+
// Remove old node - collect the index for later removal
|
|
1744
|
+
indicesToRemove.push(i);
|
|
1632
1745
|
}
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1746
|
+
}
|
|
1747
|
+
// Navigate back to parent if we ended at a child
|
|
1748
|
+
if (currentChildIndex >= 0) {
|
|
1749
|
+
patches.push({
|
|
1750
|
+
type: NavigateParent
|
|
1751
|
+
});
|
|
1752
|
+
currentChildIndex = -1;
|
|
1753
|
+
}
|
|
1754
|
+
// Add remove patches in reverse order (highest index first)
|
|
1755
|
+
// This ensures indices remain valid as we remove
|
|
1756
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
1757
|
+
patches.push({
|
|
1758
|
+
type: RemoveChild,
|
|
1759
|
+
index: indicesToRemove[j]
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
1764
|
+
// At the root level (path.length === 0), we're already AT the element
|
|
1765
|
+
// So we compare the root node directly, then compare its children
|
|
1766
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
1767
|
+
const oldNode = oldTree[0];
|
|
1768
|
+
const newNode = newTree[0];
|
|
1769
|
+
// Compare root nodes
|
|
1770
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1771
|
+
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
1772
|
+
if (nodePatches === null) {
|
|
1773
|
+
const flatNodes = treeToArray(newNode);
|
|
1636
1774
|
patches.push({
|
|
1637
|
-
type:
|
|
1638
|
-
nodes:
|
|
1775
|
+
type: Replace$1,
|
|
1776
|
+
nodes: flatNodes
|
|
1639
1777
|
});
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
if (nodePatches.length > 0) {
|
|
1781
|
+
patches.push(...nodePatches);
|
|
1782
|
+
}
|
|
1783
|
+
// Compare children
|
|
1784
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
1785
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1786
|
+
}
|
|
1787
|
+
} else {
|
|
1788
|
+
// Non-root level or multiple root elements - use the regular comparison
|
|
1789
|
+
diffChildren(oldTree, newTree, patches);
|
|
1790
|
+
}
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
const removeTrailingNavigationPatches = patches => {
|
|
1794
|
+
// Find the last non-navigation patch
|
|
1795
|
+
let lastNonNavigationIndex = -1;
|
|
1796
|
+
for (let i = patches.length - 1; i >= 0; i--) {
|
|
1797
|
+
const patch = patches[i];
|
|
1798
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
1799
|
+
lastNonNavigationIndex = i;
|
|
1800
|
+
break;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
// Return patches up to and including the last non-navigation patch
|
|
1804
|
+
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
1805
|
+
};
|
|
1806
|
+
|
|
1807
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
1808
|
+
// Step 1: Convert flat arrays to tree structures
|
|
1809
|
+
const oldTree = arrayToTree(oldNodes);
|
|
1810
|
+
const newTree = arrayToTree(newNodes);
|
|
1811
|
+
// Step 3: Compare the trees
|
|
1812
|
+
const patches = [];
|
|
1813
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
1814
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
1815
|
+
return removeTrailingNavigationPatches(patches);
|
|
1816
|
+
};
|
|
1817
|
+
|
|
1818
|
+
const User = 1;
|
|
1819
|
+
const Script = 2;
|
|
1820
|
+
|
|
1821
|
+
const clearSearchResults$1 = state => {
|
|
1822
|
+
return {
|
|
1823
|
+
...state,
|
|
1824
|
+
focus: FocusSearchInput,
|
|
1825
|
+
focusSource: Script,
|
|
1826
|
+
inputSource: Script,
|
|
1827
|
+
items: [],
|
|
1828
|
+
limitHit: false,
|
|
1829
|
+
limitHitWarning: '',
|
|
1830
|
+
maxLineY: 0,
|
|
1831
|
+
message: '',
|
|
1832
|
+
minLineY: 0,
|
|
1833
|
+
replacement: '',
|
|
1834
|
+
searchInputErrorMessage: '',
|
|
1835
|
+
value: ''
|
|
1836
|
+
};
|
|
1837
|
+
};
|
|
1838
|
+
|
|
1839
|
+
const getFilePath = text => {
|
|
1840
|
+
// TODO make api stricter so that results always have the same shape
|
|
1841
|
+
if (text.startsWith('./')) {
|
|
1842
|
+
return text.slice(2);
|
|
1843
|
+
}
|
|
1844
|
+
return text;
|
|
1845
|
+
};
|
|
1846
|
+
|
|
1847
|
+
const getIconsCached = (dirents, fileIconCache) => {
|
|
1848
|
+
return dirents.map(dirent => {
|
|
1849
|
+
if (dirent.type === Match$1) {
|
|
1850
|
+
return '';
|
|
1851
|
+
}
|
|
1852
|
+
const path = getFilePath(dirent.text);
|
|
1853
|
+
return fileIconCache[path];
|
|
1854
|
+
});
|
|
1855
|
+
};
|
|
1856
|
+
|
|
1857
|
+
const getFileName = path => {
|
|
1858
|
+
const slashIndex = path.lastIndexOf('/');
|
|
1859
|
+
if (slashIndex === -1) {
|
|
1860
|
+
return path;
|
|
1861
|
+
}
|
|
1862
|
+
return path.slice(slashIndex + 1);
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1865
|
+
const File = 1;
|
|
1866
|
+
const Match = 2;
|
|
1867
|
+
|
|
1868
|
+
const isFile = match => {
|
|
1869
|
+
return match.type === File;
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
const getMissingDirents = (searchResults, fileIconCache) => {
|
|
1873
|
+
const missingDirents = [];
|
|
1874
|
+
const files = searchResults.filter(isFile);
|
|
1875
|
+
for (const file of files) {
|
|
1876
|
+
const uri = getFilePath(file.text);
|
|
1877
|
+
if (!(uri in fileIconCache)) {
|
|
1878
|
+
missingDirents.push(file);
|
|
1643
1879
|
}
|
|
1644
|
-
i++;
|
|
1645
|
-
j++;
|
|
1646
|
-
siblingOffset++;
|
|
1647
1880
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1881
|
+
return missingDirents;
|
|
1882
|
+
};
|
|
1883
|
+
const toIconRequest = item => {
|
|
1884
|
+
const filePath = getFilePath(item.text);
|
|
1885
|
+
const fileName = getFileName(filePath);
|
|
1886
|
+
return {
|
|
1887
|
+
name: fileName,
|
|
1888
|
+
path: filePath,
|
|
1889
|
+
type: File$2
|
|
1890
|
+
};
|
|
1891
|
+
};
|
|
1892
|
+
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
1893
|
+
const missingRequests = getMissingDirents(dirents, fileIconCache);
|
|
1894
|
+
const iconRequests = missingRequests.map(toIconRequest);
|
|
1895
|
+
return iconRequests;
|
|
1896
|
+
};
|
|
1897
|
+
|
|
1898
|
+
const Directory = 3;
|
|
1899
|
+
const DirectoryExpanded = 4;
|
|
1900
|
+
|
|
1901
|
+
const getSimpleIconRequestType = direntType => {
|
|
1902
|
+
if (direntType === Directory || direntType === DirectoryExpanded) {
|
|
1903
|
+
return 2;
|
|
1661
1904
|
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
j += count;
|
|
1905
|
+
return 1;
|
|
1906
|
+
};
|
|
1907
|
+
|
|
1908
|
+
const toSimpleIconRequest = request => {
|
|
1909
|
+
return {
|
|
1910
|
+
name: request.name,
|
|
1911
|
+
type: getSimpleIconRequestType(request.type)
|
|
1912
|
+
};
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
|
+
const requestFileIcons = async requests => {
|
|
1916
|
+
if (requests.length === 0) {
|
|
1917
|
+
return [];
|
|
1676
1918
|
}
|
|
1677
|
-
|
|
1919
|
+
const simpleRequests = requests.map(toSimpleIconRequest);
|
|
1920
|
+
const icons = await getIcons(simpleRequests);
|
|
1921
|
+
return icons;
|
|
1678
1922
|
};
|
|
1679
1923
|
|
|
1680
|
-
const
|
|
1681
|
-
|
|
1924
|
+
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
1925
|
+
if (missingRequests.length === 0) {
|
|
1926
|
+
return iconCache;
|
|
1927
|
+
}
|
|
1928
|
+
const newFileIconCache = {
|
|
1929
|
+
...iconCache
|
|
1930
|
+
};
|
|
1931
|
+
for (let i = 0; i < missingRequests.length; i++) {
|
|
1932
|
+
const request = missingRequests[i];
|
|
1933
|
+
const icon = newIcons[i];
|
|
1934
|
+
newFileIconCache[request.path] = icon;
|
|
1935
|
+
}
|
|
1936
|
+
return newFileIconCache;
|
|
1937
|
+
};
|
|
1682
1938
|
|
|
1683
|
-
const
|
|
1939
|
+
const getFileIcons = async (items, fileIconCache) => {
|
|
1940
|
+
const missingRequests = getMissingIconRequests(items, fileIconCache);
|
|
1941
|
+
const newIcons = await requestFileIcons(missingRequests);
|
|
1942
|
+
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
1943
|
+
const icons = getIconsCached(items, newFileIconCache);
|
|
1684
1944
|
return {
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
focusSource: Script,
|
|
1688
|
-
inputSource: Script,
|
|
1689
|
-
items: [],
|
|
1690
|
-
limitHit: false,
|
|
1691
|
-
limitHitWarning: '',
|
|
1692
|
-
maxLineY: 0,
|
|
1693
|
-
message: '',
|
|
1694
|
-
minLineY: 0,
|
|
1695
|
-
replacement: '',
|
|
1696
|
-
searchInputErrorMessage: '',
|
|
1697
|
-
value: ''
|
|
1945
|
+
icons,
|
|
1946
|
+
newFileIconCache
|
|
1698
1947
|
};
|
|
1699
1948
|
};
|
|
1700
1949
|
|
|
1701
|
-
|
|
1702
|
-
|
|
1950
|
+
// TODO optimize this function to return the minimum number
|
|
1951
|
+
// of visible items needed, e.g. when not scrolled 5 items with
|
|
1952
|
+
// 20px fill 100px but when scrolled 6 items are needed
|
|
1953
|
+
const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
|
|
1954
|
+
return Math.ceil(listHeight / itemHeight) + 1;
|
|
1955
|
+
};
|
|
1703
1956
|
|
|
1704
1957
|
const getPaths = items => {
|
|
1705
1958
|
const paths = [];
|
|
@@ -1712,15 +1965,30 @@ const getPaths = items => {
|
|
|
1712
1965
|
};
|
|
1713
1966
|
const collapseAll$1 = async state => {
|
|
1714
1967
|
const {
|
|
1968
|
+
fileIconCache,
|
|
1969
|
+
headerHeight,
|
|
1970
|
+
height,
|
|
1971
|
+
itemHeight,
|
|
1715
1972
|
items
|
|
1716
1973
|
} = state;
|
|
1717
1974
|
if (items.length === 0) {
|
|
1718
1975
|
return state;
|
|
1719
1976
|
}
|
|
1720
1977
|
const paths = getPaths(items);
|
|
1978
|
+
const total = items.length;
|
|
1979
|
+
const listHeight = height - headerHeight;
|
|
1980
|
+
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
1981
|
+
const maxLineY = Math.min(numberOfVisible, total);
|
|
1982
|
+
const visible = items.slice(0, maxLineY);
|
|
1983
|
+
const {
|
|
1984
|
+
icons,
|
|
1985
|
+
newFileIconCache
|
|
1986
|
+
} = await getFileIcons(visible, fileIconCache);
|
|
1721
1987
|
return {
|
|
1722
1988
|
...state,
|
|
1723
|
-
collapsedPaths: paths
|
|
1989
|
+
collapsedPaths: paths,
|
|
1990
|
+
fileIconCache: newFileIconCache,
|
|
1991
|
+
icons
|
|
1724
1992
|
};
|
|
1725
1993
|
};
|
|
1726
1994
|
|
|
@@ -1821,6 +2089,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
1821
2089
|
disposed: false,
|
|
1822
2090
|
fileCount: 0,
|
|
1823
2091
|
height,
|
|
2092
|
+
initial: true,
|
|
1824
2093
|
searchResults: [],
|
|
1825
2094
|
stats: {},
|
|
1826
2095
|
uid,
|
|
@@ -1902,13 +2171,12 @@ const RenderIncludeValue = 5;
|
|
|
1902
2171
|
const RenderExcludeValue = 6;
|
|
1903
2172
|
const RenderFocusContext = 7;
|
|
1904
2173
|
const RenderSelections = 8;
|
|
2174
|
+
const RenderIncremental = 9;
|
|
1905
2175
|
|
|
1906
|
-
const diffType$5 = RenderExcludeValue;
|
|
1907
2176
|
const isEqual$6 = (oldState, newState) => {
|
|
1908
2177
|
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
1909
2178
|
};
|
|
1910
2179
|
|
|
1911
|
-
const diffType$4 = RenderFocus;
|
|
1912
2180
|
const isEqual$5 = (oldState, newState) => {
|
|
1913
2181
|
return oldState.focus === newState.focus || newState.focusSource === User;
|
|
1914
2182
|
};
|
|
@@ -1917,28 +2185,24 @@ const isEqual$4 = (oldState, newState) => {
|
|
|
1917
2185
|
return oldState.focus === newState.focus && oldState.focused === newState.focused;
|
|
1918
2186
|
};
|
|
1919
2187
|
|
|
1920
|
-
const diffType$3 = RenderIncludeValue;
|
|
1921
2188
|
const isEqual$3 = (oldState, newState) => {
|
|
1922
2189
|
return oldState.includeValue === newState.includeValue || newState.inputSource === User;
|
|
1923
2190
|
};
|
|
1924
2191
|
|
|
1925
|
-
const diffType$2 = RenderItems;
|
|
1926
2192
|
const isEqual$2 = (oldState, newState) => {
|
|
1927
2193
|
return oldState.collapsedPaths === newState.collapsedPaths && oldState.deltaY === newState.deltaY && oldState.flags === newState.flags && oldState.focus === newState.focus && oldState.icons === newState.icons && oldState.items === newState.items && oldState.listFocused === newState.listFocused && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.loaded === newState.loaded && oldState.maxLineY === newState.maxLineY && oldState.message === newState.message && oldState.minLineY === newState.minLineY && oldState.replacement === newState.replacement && oldState.searchInputErrorMessage === newState.searchInputErrorMessage;
|
|
1928
2194
|
};
|
|
1929
2195
|
|
|
1930
|
-
const diffType$1 = RenderReplaceValue;
|
|
1931
2196
|
const isEqual$1 = (oldState, newState) => {
|
|
1932
2197
|
return oldState.replacement === newState.replacement || newState.inputSource === User;
|
|
1933
2198
|
};
|
|
1934
2199
|
|
|
1935
|
-
const diffType = RenderValue;
|
|
1936
2200
|
const isEqual = (oldState, newState) => {
|
|
1937
2201
|
return oldState.value === newState.value || newState.inputSource === User;
|
|
1938
2202
|
};
|
|
1939
2203
|
|
|
1940
2204
|
const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4];
|
|
1941
|
-
const numbers = [
|
|
2205
|
+
const numbers = [RenderIncremental, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext];
|
|
1942
2206
|
|
|
1943
2207
|
const diff = (oldState, newState) => {
|
|
1944
2208
|
const diffResult = [];
|
|
@@ -1960,114 +2224,6 @@ const diff2 = uid => {
|
|
|
1960
2224
|
return diffResult;
|
|
1961
2225
|
};
|
|
1962
2226
|
|
|
1963
|
-
const getFilePath = text => {
|
|
1964
|
-
// TODO make api stricter so that results always have the same shape
|
|
1965
|
-
if (text.startsWith('./')) {
|
|
1966
|
-
return text.slice(2);
|
|
1967
|
-
}
|
|
1968
|
-
return text;
|
|
1969
|
-
};
|
|
1970
|
-
|
|
1971
|
-
const getIconsCached = (dirents, fileIconCache) => {
|
|
1972
|
-
return dirents.map(dirent => {
|
|
1973
|
-
if (dirent.type === Match$1) {
|
|
1974
|
-
return '';
|
|
1975
|
-
}
|
|
1976
|
-
const path = getFilePath(dirent.text);
|
|
1977
|
-
return fileIconCache[path];
|
|
1978
|
-
});
|
|
1979
|
-
};
|
|
1980
|
-
|
|
1981
|
-
const getFileName = path => {
|
|
1982
|
-
const slashIndex = path.lastIndexOf('/');
|
|
1983
|
-
if (slashIndex === -1) {
|
|
1984
|
-
return path;
|
|
1985
|
-
}
|
|
1986
|
-
return path.slice(slashIndex + 1);
|
|
1987
|
-
};
|
|
1988
|
-
|
|
1989
|
-
const isFile = match => {
|
|
1990
|
-
return match.type === File;
|
|
1991
|
-
};
|
|
1992
|
-
|
|
1993
|
-
const getMissingDirents = (searchResults, fileIconCache) => {
|
|
1994
|
-
const missingDirents = [];
|
|
1995
|
-
const files = searchResults.filter(isFile);
|
|
1996
|
-
for (const file of files) {
|
|
1997
|
-
const uri = getFilePath(file.text);
|
|
1998
|
-
if (!(uri in fileIconCache)) {
|
|
1999
|
-
missingDirents.push(file);
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
return missingDirents;
|
|
2003
|
-
};
|
|
2004
|
-
const toIconRequest = item => {
|
|
2005
|
-
const filePath = getFilePath(item.text);
|
|
2006
|
-
const fileName = getFileName(filePath);
|
|
2007
|
-
return {
|
|
2008
|
-
name: fileName,
|
|
2009
|
-
path: filePath,
|
|
2010
|
-
type: File$2
|
|
2011
|
-
};
|
|
2012
|
-
};
|
|
2013
|
-
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
2014
|
-
const missingRequests = getMissingDirents(dirents, fileIconCache);
|
|
2015
|
-
const iconRequests = missingRequests.map(toIconRequest);
|
|
2016
|
-
return iconRequests;
|
|
2017
|
-
};
|
|
2018
|
-
|
|
2019
|
-
const Directory = 3;
|
|
2020
|
-
const DirectoryExpanded = 4;
|
|
2021
|
-
|
|
2022
|
-
const getSimpleIconRequestType = direntType => {
|
|
2023
|
-
if (direntType === Directory || direntType === DirectoryExpanded) {
|
|
2024
|
-
return 2;
|
|
2025
|
-
}
|
|
2026
|
-
return 1;
|
|
2027
|
-
};
|
|
2028
|
-
|
|
2029
|
-
const toSimpleIconRequest = request => {
|
|
2030
|
-
return {
|
|
2031
|
-
name: request.name,
|
|
2032
|
-
type: getSimpleIconRequestType(request.type)
|
|
2033
|
-
};
|
|
2034
|
-
};
|
|
2035
|
-
|
|
2036
|
-
const requestFileIcons = async requests => {
|
|
2037
|
-
if (requests.length === 0) {
|
|
2038
|
-
return [];
|
|
2039
|
-
}
|
|
2040
|
-
const simpleRequests = requests.map(toSimpleIconRequest);
|
|
2041
|
-
const icons = await getIcons(simpleRequests);
|
|
2042
|
-
return icons;
|
|
2043
|
-
};
|
|
2044
|
-
|
|
2045
|
-
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
2046
|
-
if (missingRequests.length === 0) {
|
|
2047
|
-
return iconCache;
|
|
2048
|
-
}
|
|
2049
|
-
const newFileIconCache = {
|
|
2050
|
-
...iconCache
|
|
2051
|
-
};
|
|
2052
|
-
for (let i = 0; i < missingRequests.length; i++) {
|
|
2053
|
-
const request = missingRequests[i];
|
|
2054
|
-
const icon = newIcons[i];
|
|
2055
|
-
newFileIconCache[request.path] = icon;
|
|
2056
|
-
}
|
|
2057
|
-
return newFileIconCache;
|
|
2058
|
-
};
|
|
2059
|
-
|
|
2060
|
-
const getFileIcons = async (items, fileIconCache) => {
|
|
2061
|
-
const missingRequests = getMissingIconRequests(items, fileIconCache);
|
|
2062
|
-
const newIcons = await requestFileIcons(missingRequests);
|
|
2063
|
-
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
2064
|
-
const icons = getIconsCached(items, newFileIconCache);
|
|
2065
|
-
return {
|
|
2066
|
-
icons,
|
|
2067
|
-
newFileIconCache
|
|
2068
|
-
};
|
|
2069
|
-
};
|
|
2070
|
-
|
|
2071
2227
|
const getNewMinMax = (newItemsLength, minLineY, maxLineY, deltaY, itemHeight) => {
|
|
2072
2228
|
if (maxLineY > newItemsLength) {
|
|
2073
2229
|
const diff = maxLineY - minLineY;
|
|
@@ -2887,13 +3043,6 @@ const handleUpdateError = async (state, update, error) => {
|
|
|
2887
3043
|
};
|
|
2888
3044
|
};
|
|
2889
3045
|
|
|
2890
|
-
// TODO optimize this function to return the minimum number
|
|
2891
|
-
// of visible items needed, e.g. when not scrolled 5 items with
|
|
2892
|
-
// 20px fill 100px but when scrolled 6 items are needed
|
|
2893
|
-
const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
|
|
2894
|
-
return Math.ceil(listHeight / itemHeight) + 1;
|
|
2895
|
-
};
|
|
2896
|
-
|
|
2897
3046
|
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2898
3047
|
const getProtocol = uri => {
|
|
2899
3048
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
@@ -3050,11 +3199,6 @@ const getRipGrepArgs = ({
|
|
|
3050
3199
|
return ripGrepArgs;
|
|
3051
3200
|
};
|
|
3052
3201
|
|
|
3053
|
-
const {
|
|
3054
|
-
invoke,
|
|
3055
|
-
setFactory
|
|
3056
|
-
} = createLazyRpc(SearchProcess);
|
|
3057
|
-
|
|
3058
3202
|
const waitForNextFrame = async () => {
|
|
3059
3203
|
const {
|
|
3060
3204
|
promise,
|
|
@@ -3801,11 +3945,11 @@ const launchIconThemeWorker = async () => {
|
|
|
3801
3945
|
|
|
3802
3946
|
const initializeIconThemeWorker = async () => {
|
|
3803
3947
|
const rpc = await launchIconThemeWorker();
|
|
3804
|
-
set$
|
|
3948
|
+
set$3(rpc);
|
|
3805
3949
|
};
|
|
3806
3950
|
|
|
3807
3951
|
const launchSearchProcessElectron = async () => {
|
|
3808
|
-
const rpc = await
|
|
3952
|
+
const rpc = await LazyTransferMessagePortRpcParent.create({
|
|
3809
3953
|
commandMap: {},
|
|
3810
3954
|
send: sendMessagePortToSearchProcess
|
|
3811
3955
|
});
|
|
@@ -3813,7 +3957,7 @@ const launchSearchProcessElectron = async () => {
|
|
|
3813
3957
|
};
|
|
3814
3958
|
|
|
3815
3959
|
const launchSearchProcessNode = async () => {
|
|
3816
|
-
const rpc = await
|
|
3960
|
+
const rpc = await LazyWebSocketRpcParent2.create({
|
|
3817
3961
|
commandMap: {},
|
|
3818
3962
|
// @ts-ignore
|
|
3819
3963
|
type: 'search-process'
|
|
@@ -3821,16 +3965,18 @@ const launchSearchProcessNode = async () => {
|
|
|
3821
3965
|
return rpc;
|
|
3822
3966
|
};
|
|
3823
3967
|
|
|
3824
|
-
const
|
|
3968
|
+
const initializeSearchProcess = async platform => {
|
|
3825
3969
|
if (platform === Electron) {
|
|
3826
|
-
|
|
3970
|
+
const rpc = await launchSearchProcessElectron();
|
|
3971
|
+
set$1(rpc);
|
|
3827
3972
|
} else if (platform === Remote) {
|
|
3828
|
-
|
|
3973
|
+
const rpc = await launchSearchProcessNode();
|
|
3974
|
+
set$1(rpc);
|
|
3829
3975
|
}
|
|
3830
3976
|
};
|
|
3977
|
+
|
|
3831
3978
|
const initialize = async platform => {
|
|
3832
|
-
|
|
3833
|
-
await initializeIconThemeWorker();
|
|
3979
|
+
await Promise.all([initializeSearchProcess(platform), initializeIconThemeWorker()]);
|
|
3834
3980
|
};
|
|
3835
3981
|
|
|
3836
3982
|
// TODO optimize this function to return the minimum number
|
|
@@ -4426,6 +4572,7 @@ const loadContent = async (state, savedState) => {
|
|
|
4426
4572
|
const result = await handleUpdate(state, update);
|
|
4427
4573
|
return {
|
|
4428
4574
|
...result,
|
|
4575
|
+
initial: false,
|
|
4429
4576
|
loaded: true
|
|
4430
4577
|
};
|
|
4431
4578
|
}
|
|
@@ -4433,6 +4580,7 @@ const loadContent = async (state, savedState) => {
|
|
|
4433
4580
|
...state,
|
|
4434
4581
|
...update,
|
|
4435
4582
|
flags,
|
|
4583
|
+
initial: false,
|
|
4436
4584
|
loaded: true,
|
|
4437
4585
|
threads
|
|
4438
4586
|
};
|
|
@@ -5293,7 +5441,10 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
|
|
|
5293
5441
|
};
|
|
5294
5442
|
|
|
5295
5443
|
const className = mergeClassNames(Viewlet, Search$2);
|
|
5296
|
-
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0) => {
|
|
5444
|
+
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0, initial = false) => {
|
|
5445
|
+
if (initial) {
|
|
5446
|
+
return [];
|
|
5447
|
+
}
|
|
5297
5448
|
const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
|
|
5298
5449
|
const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
|
|
5299
5450
|
return [{
|
|
@@ -5305,10 +5456,18 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchI
|
|
|
5305
5456
|
|
|
5306
5457
|
const renderItems = (oldState, newState) => {
|
|
5307
5458
|
const viewModel = createViewModel(newState);
|
|
5308
|
-
const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, newState.limitHitWarning, viewModel.focus);
|
|
5459
|
+
const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, newState.limitHitWarning, viewModel.focus, newState.initial);
|
|
5309
5460
|
return [SetDom2, newState.uid, dom];
|
|
5310
5461
|
};
|
|
5311
5462
|
|
|
5463
|
+
// TODO cache rendered dom so that it can be used for dom diffing
|
|
5464
|
+
const renderIncremental = (oldState, newState) => {
|
|
5465
|
+
const oldDom = renderItems(oldState, oldState)[2];
|
|
5466
|
+
const newDom = renderItems(newState, newState)[2];
|
|
5467
|
+
const patches = diffTree(oldDom, newDom);
|
|
5468
|
+
return ['Viewlet.setPatches', newState.uid, patches];
|
|
5469
|
+
};
|
|
5470
|
+
|
|
5312
5471
|
const renderSelections = (oldState, newState) => {
|
|
5313
5472
|
// const { selections, uid } = newState
|
|
5314
5473
|
|
|
@@ -5339,6 +5498,8 @@ const getRenderer = diffType => {
|
|
|
5339
5498
|
return renderFocusContext;
|
|
5340
5499
|
case RenderIncludeValue:
|
|
5341
5500
|
return renderIncludeValue;
|
|
5501
|
+
case RenderIncremental:
|
|
5502
|
+
return renderIncremental;
|
|
5342
5503
|
case RenderItems:
|
|
5343
5504
|
return renderItems;
|
|
5344
5505
|
case RenderReplaceValue:
|
|
@@ -5551,18 +5712,6 @@ const renderEventListeners = () => {
|
|
|
5551
5712
|
}];
|
|
5552
5713
|
};
|
|
5553
5714
|
|
|
5554
|
-
// TODO cache rendered dom so that it can be used for dom diffing
|
|
5555
|
-
const renderIncremental = uid => {
|
|
5556
|
-
const {
|
|
5557
|
-
newState,
|
|
5558
|
-
oldState
|
|
5559
|
-
} = get$1(uid);
|
|
5560
|
-
const oldDom = renderItems(oldState, oldState);
|
|
5561
|
-
const newDom = renderItems(newState, newState);
|
|
5562
|
-
const patches = diff$1(oldDom, newDom);
|
|
5563
|
-
return patches;
|
|
5564
|
-
};
|
|
5565
|
-
|
|
5566
5715
|
const prompt = (text, options) => {
|
|
5567
5716
|
return invoke$1('ConfirmPrompt.prompt', text, options);
|
|
5568
5717
|
};
|
|
@@ -5991,7 +6140,7 @@ const listen = async () => {
|
|
|
5991
6140
|
const rpc = await WebWorkerRpcClient.create({
|
|
5992
6141
|
commandMap: commandMap
|
|
5993
6142
|
});
|
|
5994
|
-
set$
|
|
6143
|
+
set$2(rpc);
|
|
5995
6144
|
};
|
|
5996
6145
|
|
|
5997
6146
|
const main = async () => {
|