@lvce-editor/file-search-worker 6.17.0 → 7.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/fileSearchWorkerMain.js +209 -133
- package/package.json +5 -2
|
@@ -63,7 +63,7 @@ class AssertionError extends Error {
|
|
|
63
63
|
const Object$1 = 1;
|
|
64
64
|
const Number$1 = 2;
|
|
65
65
|
const Array$1 = 3;
|
|
66
|
-
const String = 4;
|
|
66
|
+
const String$1 = 4;
|
|
67
67
|
const Boolean$1 = 5;
|
|
68
68
|
const Function = 6;
|
|
69
69
|
const Null = 7;
|
|
@@ -75,7 +75,7 @@ const getType = value => {
|
|
|
75
75
|
case 'function':
|
|
76
76
|
return Function;
|
|
77
77
|
case 'string':
|
|
78
|
-
return String;
|
|
78
|
+
return String$1;
|
|
79
79
|
case 'object':
|
|
80
80
|
if (value === null) {
|
|
81
81
|
return Null;
|
|
@@ -110,7 +110,7 @@ const array = value => {
|
|
|
110
110
|
};
|
|
111
111
|
const string = value => {
|
|
112
112
|
const type = getType(value);
|
|
113
|
-
if (type !== String) {
|
|
113
|
+
if (type !== String$1) {
|
|
114
114
|
throw new AssertionError('expected value to be of type string');
|
|
115
115
|
}
|
|
116
116
|
};
|
|
@@ -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();
|
|
@@ -445,8 +445,8 @@ const removeListener = (emitter, type, callback) => {
|
|
|
445
445
|
};
|
|
446
446
|
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
447
447
|
const {
|
|
448
|
-
|
|
449
|
-
|
|
448
|
+
promise,
|
|
449
|
+
resolve
|
|
450
450
|
} = Promise.withResolvers();
|
|
451
451
|
const listenerMap = Object.create(null);
|
|
452
452
|
const cleanup = value => {
|
|
@@ -458,8 +458,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
458
458
|
for (const [event, type] of Object.entries(eventMap)) {
|
|
459
459
|
const listener = event => {
|
|
460
460
|
cleanup({
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
event,
|
|
462
|
+
type
|
|
463
463
|
});
|
|
464
464
|
};
|
|
465
465
|
addListener(eventEmitter, event, listener);
|
|
@@ -468,9 +468,9 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
468
468
|
return promise;
|
|
469
469
|
};
|
|
470
470
|
const Message$1 = 3;
|
|
471
|
-
const create$5
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
const create$5 = async ({
|
|
472
|
+
isMessagePortOpen,
|
|
473
|
+
messagePort
|
|
474
474
|
}) => {
|
|
475
475
|
if (!isMessagePort(messagePort)) {
|
|
476
476
|
throw new IpcError('port must be of type MessagePort');
|
|
@@ -483,8 +483,8 @@ const create$5$1 = async ({
|
|
|
483
483
|
});
|
|
484
484
|
messagePort.start();
|
|
485
485
|
const {
|
|
486
|
-
|
|
487
|
-
|
|
486
|
+
event,
|
|
487
|
+
type
|
|
488
488
|
} = await eventPromise;
|
|
489
489
|
if (type !== Message$1) {
|
|
490
490
|
throw new IpcError('Failed to wait for ipc message');
|
|
@@ -519,60 +519,18 @@ const wrap$5 = messagePort => {
|
|
|
519
519
|
};
|
|
520
520
|
const IpcParentWithMessagePort$1 = {
|
|
521
521
|
__proto__: null,
|
|
522
|
-
create: create$5
|
|
522
|
+
create: create$5,
|
|
523
523
|
signal: signal$1,
|
|
524
524
|
wrap: wrap$5
|
|
525
525
|
};
|
|
526
526
|
|
|
527
|
-
const Two = '2.0';
|
|
528
|
-
const
|
|
529
|
-
return {
|
|
530
|
-
jsonrpc: Two,
|
|
531
|
-
method,
|
|
532
|
-
params
|
|
533
|
-
};
|
|
534
|
-
};
|
|
535
|
-
const callbacks = Object.create(null);
|
|
536
|
-
const set$4 = (id, fn) => {
|
|
537
|
-
callbacks[id] = fn;
|
|
538
|
-
};
|
|
527
|
+
const Two$1 = '2.0';
|
|
528
|
+
const callbacks$1 = Object.create(null);
|
|
539
529
|
const get$2 = id => {
|
|
540
|
-
return callbacks[id];
|
|
530
|
+
return callbacks$1[id];
|
|
541
531
|
};
|
|
542
532
|
const remove = id => {
|
|
543
|
-
delete callbacks[id];
|
|
544
|
-
};
|
|
545
|
-
let id = 0;
|
|
546
|
-
const create$3$2 = () => {
|
|
547
|
-
return ++id;
|
|
548
|
-
};
|
|
549
|
-
const registerPromise = () => {
|
|
550
|
-
const id = create$3$2();
|
|
551
|
-
const {
|
|
552
|
-
resolve,
|
|
553
|
-
promise
|
|
554
|
-
} = Promise.withResolvers();
|
|
555
|
-
set$4(id, resolve);
|
|
556
|
-
return {
|
|
557
|
-
id,
|
|
558
|
-
promise
|
|
559
|
-
};
|
|
560
|
-
};
|
|
561
|
-
const create$2$1 = (method, params) => {
|
|
562
|
-
const {
|
|
563
|
-
id,
|
|
564
|
-
promise
|
|
565
|
-
} = registerPromise();
|
|
566
|
-
const message = {
|
|
567
|
-
jsonrpc: Two,
|
|
568
|
-
method,
|
|
569
|
-
params,
|
|
570
|
-
id
|
|
571
|
-
};
|
|
572
|
-
return {
|
|
573
|
-
message,
|
|
574
|
-
promise
|
|
575
|
-
};
|
|
533
|
+
delete callbacks$1[id];
|
|
576
534
|
};
|
|
577
535
|
class JsonRpcError extends Error {
|
|
578
536
|
constructor(message) {
|
|
@@ -769,7 +727,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
769
727
|
};
|
|
770
728
|
const create$1$1 = (id, error) => {
|
|
771
729
|
return {
|
|
772
|
-
jsonrpc: Two,
|
|
730
|
+
jsonrpc: Two$1,
|
|
773
731
|
id,
|
|
774
732
|
error
|
|
775
733
|
};
|
|
@@ -780,20 +738,20 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
780
738
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
781
739
|
return create$1$1(id, errorProperty);
|
|
782
740
|
};
|
|
783
|
-
const create$
|
|
741
|
+
const create$4 = (message, result) => {
|
|
784
742
|
return {
|
|
785
|
-
jsonrpc: Two,
|
|
743
|
+
jsonrpc: Two$1,
|
|
786
744
|
id: message.id,
|
|
787
745
|
result: result ?? null
|
|
788
746
|
};
|
|
789
747
|
};
|
|
790
748
|
const getSuccessResponse = (message, result) => {
|
|
791
749
|
const resultProperty = result ?? null;
|
|
792
|
-
return create$
|
|
750
|
+
return create$4(message, resultProperty);
|
|
793
751
|
};
|
|
794
752
|
const getErrorResponseSimple = (id, error) => {
|
|
795
753
|
return {
|
|
796
|
-
jsonrpc: Two,
|
|
754
|
+
jsonrpc: Two$1,
|
|
797
755
|
id,
|
|
798
756
|
error: {
|
|
799
757
|
code: Custom$2,
|
|
@@ -880,29 +838,6 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
880
838
|
}
|
|
881
839
|
throw new JsonRpcError('unexpected message');
|
|
882
840
|
};
|
|
883
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
884
|
-
const {
|
|
885
|
-
message,
|
|
886
|
-
promise
|
|
887
|
-
} = create$2$1(method, params);
|
|
888
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
889
|
-
ipc.sendAndTransfer(message);
|
|
890
|
-
} else {
|
|
891
|
-
ipc.send(message);
|
|
892
|
-
}
|
|
893
|
-
const responseMessage = await promise;
|
|
894
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
895
|
-
};
|
|
896
|
-
const send = (transport, method, ...params) => {
|
|
897
|
-
const message = create$4$1(method, params);
|
|
898
|
-
transport.send(message);
|
|
899
|
-
};
|
|
900
|
-
const invoke$3 = (ipc, method, ...params) => {
|
|
901
|
-
return invokeHelper(ipc, method, params, false);
|
|
902
|
-
};
|
|
903
|
-
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
904
|
-
return invokeHelper(ipc, method, params, true);
|
|
905
|
-
};
|
|
906
841
|
|
|
907
842
|
class CommandNotFoundError extends Error {
|
|
908
843
|
constructor(command) {
|
|
@@ -925,24 +860,87 @@ const execute = (command, ...args) => {
|
|
|
925
860
|
return fn(...args);
|
|
926
861
|
};
|
|
927
862
|
|
|
863
|
+
const Two = '2.0';
|
|
864
|
+
const create$q = (method, params) => {
|
|
865
|
+
return {
|
|
866
|
+
jsonrpc: Two,
|
|
867
|
+
method,
|
|
868
|
+
params
|
|
869
|
+
};
|
|
870
|
+
};
|
|
871
|
+
const create$p = (id, method, params) => {
|
|
872
|
+
const message = {
|
|
873
|
+
id,
|
|
874
|
+
jsonrpc: Two,
|
|
875
|
+
method,
|
|
876
|
+
params
|
|
877
|
+
};
|
|
878
|
+
return message;
|
|
879
|
+
};
|
|
880
|
+
let id = 0;
|
|
881
|
+
const create$o = () => {
|
|
882
|
+
return ++id;
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
886
|
+
|
|
887
|
+
const registerPromise = map => {
|
|
888
|
+
const id = create$o();
|
|
889
|
+
const {
|
|
890
|
+
promise,
|
|
891
|
+
resolve
|
|
892
|
+
} = Promise.withResolvers();
|
|
893
|
+
map[id] = resolve;
|
|
894
|
+
return {
|
|
895
|
+
id,
|
|
896
|
+
promise
|
|
897
|
+
};
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
// @ts-ignore
|
|
901
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
902
|
+
const {
|
|
903
|
+
id,
|
|
904
|
+
promise
|
|
905
|
+
} = registerPromise(callbacks);
|
|
906
|
+
const message = create$p(id, method, params);
|
|
907
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
908
|
+
ipc.sendAndTransfer(message);
|
|
909
|
+
} else {
|
|
910
|
+
ipc.send(message);
|
|
911
|
+
}
|
|
912
|
+
const responseMessage = await promise;
|
|
913
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
914
|
+
};
|
|
928
915
|
const createRpc = ipc => {
|
|
916
|
+
const callbacks = Object.create(null);
|
|
917
|
+
ipc._resolve = (id, response) => {
|
|
918
|
+
const fn = callbacks[id];
|
|
919
|
+
if (!fn) {
|
|
920
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
fn(response);
|
|
924
|
+
delete callbacks[id];
|
|
925
|
+
};
|
|
929
926
|
const rpc = {
|
|
927
|
+
async dispose() {
|
|
928
|
+
await ipc?.dispose();
|
|
929
|
+
},
|
|
930
|
+
invoke(method, ...params) {
|
|
931
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
932
|
+
},
|
|
933
|
+
invokeAndTransfer(method, ...params) {
|
|
934
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
935
|
+
},
|
|
930
936
|
// @ts-ignore
|
|
931
937
|
ipc,
|
|
932
938
|
/**
|
|
933
939
|
* @deprecated
|
|
934
940
|
*/
|
|
935
941
|
send(method, ...params) {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
invoke(method, ...params) {
|
|
939
|
-
return invoke$3(ipc, method, ...params);
|
|
940
|
-
},
|
|
941
|
-
invokeAndTransfer(method, ...params) {
|
|
942
|
-
return invokeAndTransfer$1(ipc, method, ...params);
|
|
943
|
-
},
|
|
944
|
-
async dispose() {
|
|
945
|
-
await ipc?.dispose();
|
|
942
|
+
const message = create$q(method, params);
|
|
943
|
+
ipc.send(message);
|
|
946
944
|
}
|
|
947
945
|
};
|
|
948
946
|
return rpc;
|
|
@@ -959,7 +957,7 @@ const logError = () => {
|
|
|
959
957
|
const handleMessage = event => {
|
|
960
958
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
961
959
|
const actualExecute = event?.target?.execute || execute;
|
|
962
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
960
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
963
961
|
};
|
|
964
962
|
const handleIpc = ipc => {
|
|
965
963
|
if ('addEventListener' in ipc) {
|
|
@@ -977,15 +975,16 @@ const listen$1 = async (module, options) => {
|
|
|
977
975
|
const ipc = module.wrap(rawIpc);
|
|
978
976
|
return ipc;
|
|
979
977
|
};
|
|
980
|
-
const create$
|
|
978
|
+
const create$8 = async ({
|
|
981
979
|
commandMap,
|
|
980
|
+
isMessagePortOpen = true,
|
|
982
981
|
messagePort
|
|
983
982
|
}) => {
|
|
984
983
|
// TODO create a commandMap per rpc instance
|
|
985
984
|
register$1(commandMap);
|
|
986
985
|
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
987
|
-
|
|
988
|
-
|
|
986
|
+
isMessagePortOpen,
|
|
987
|
+
messagePort
|
|
989
988
|
});
|
|
990
989
|
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
991
990
|
handleIpc(ipc);
|
|
@@ -993,8 +992,13 @@ const create$5 = async ({
|
|
|
993
992
|
messagePort.start();
|
|
994
993
|
return rpc;
|
|
995
994
|
};
|
|
996
|
-
const
|
|
995
|
+
const PlainMessagePortRpc = {
|
|
996
|
+
__proto__: null,
|
|
997
|
+
create: create$8
|
|
998
|
+
};
|
|
999
|
+
const create$6 = async ({
|
|
997
1000
|
commandMap,
|
|
1001
|
+
isMessagePortOpen,
|
|
998
1002
|
send
|
|
999
1003
|
}) => {
|
|
1000
1004
|
const {
|
|
@@ -1002,16 +1006,17 @@ const create$3$1 = async ({
|
|
|
1002
1006
|
port2
|
|
1003
1007
|
} = new MessageChannel();
|
|
1004
1008
|
await send(port1);
|
|
1005
|
-
return create$
|
|
1009
|
+
return create$8({
|
|
1006
1010
|
commandMap,
|
|
1011
|
+
isMessagePortOpen,
|
|
1007
1012
|
messagePort: port2
|
|
1008
1013
|
});
|
|
1009
1014
|
};
|
|
1010
1015
|
const TransferMessagePortRpcParent = {
|
|
1011
1016
|
__proto__: null,
|
|
1012
|
-
create: create$
|
|
1017
|
+
create: create$6
|
|
1013
1018
|
};
|
|
1014
|
-
const create$
|
|
1019
|
+
const create$2$1 = async ({
|
|
1015
1020
|
commandMap
|
|
1016
1021
|
}) => {
|
|
1017
1022
|
// TODO create a commandMap per rpc instance
|
|
@@ -1023,15 +1028,9 @@ const create$4 = async ({
|
|
|
1023
1028
|
};
|
|
1024
1029
|
const WebWorkerRpcClient = {
|
|
1025
1030
|
__proto__: null,
|
|
1026
|
-
create: create$
|
|
1031
|
+
create: create$2$1
|
|
1027
1032
|
};
|
|
1028
1033
|
|
|
1029
|
-
const Div = 4;
|
|
1030
|
-
const Input = 6;
|
|
1031
|
-
const Span = 8;
|
|
1032
|
-
const Text = 12;
|
|
1033
|
-
const Img = 17;
|
|
1034
|
-
|
|
1035
1034
|
const EditorWorker = 99;
|
|
1036
1035
|
const RendererWorker = 1;
|
|
1037
1036
|
|
|
@@ -1047,6 +1046,10 @@ const get$1 = id => {
|
|
|
1047
1046
|
|
|
1048
1047
|
const create$3 = rpcId => {
|
|
1049
1048
|
return {
|
|
1049
|
+
async dispose() {
|
|
1050
|
+
const rpc = get$1(rpcId);
|
|
1051
|
+
await rpc.dispose();
|
|
1052
|
+
},
|
|
1050
1053
|
// @ts-ignore
|
|
1051
1054
|
invoke(method, ...params) {
|
|
1052
1055
|
const rpc = get$1(rpcId);
|
|
@@ -1061,17 +1064,14 @@ const create$3 = rpcId => {
|
|
|
1061
1064
|
},
|
|
1062
1065
|
set(rpc) {
|
|
1063
1066
|
set$3(rpcId, rpc);
|
|
1064
|
-
},
|
|
1065
|
-
async dispose() {
|
|
1066
|
-
const rpc = get$1(rpcId);
|
|
1067
|
-
await rpc.dispose();
|
|
1068
1067
|
}
|
|
1069
1068
|
};
|
|
1070
1069
|
};
|
|
1071
1070
|
|
|
1072
1071
|
const {
|
|
1073
1072
|
invoke: invoke$2,
|
|
1074
|
-
set: set$2
|
|
1073
|
+
set: set$2
|
|
1074
|
+
} = create$3(EditorWorker);
|
|
1075
1075
|
const getLines = async editorUid => {
|
|
1076
1076
|
const lines = await invoke$2('Editor.getLines2', editorUid);
|
|
1077
1077
|
return lines;
|
|
@@ -1080,7 +1080,8 @@ const getLines = async editorUid => {
|
|
|
1080
1080
|
const {
|
|
1081
1081
|
invoke: invoke$1,
|
|
1082
1082
|
invokeAndTransfer,
|
|
1083
|
-
set: set$1
|
|
1083
|
+
set: set$1
|
|
1084
|
+
} = create$3(RendererWorker);
|
|
1084
1085
|
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1085
1086
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1086
1087
|
// @ts-ignore
|
|
@@ -1287,6 +1288,7 @@ const handleWheel = (state, deltaMode, deltaY) => {
|
|
|
1287
1288
|
|
|
1288
1289
|
const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, workspaceUri, assetDir) => {
|
|
1289
1290
|
const state = {
|
|
1291
|
+
allowEmptyResult: false,
|
|
1290
1292
|
cursorOffset: 0,
|
|
1291
1293
|
height: 300,
|
|
1292
1294
|
icons: [],
|
|
@@ -1312,6 +1314,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, w
|
|
|
1312
1314
|
fileIconCache: Object.create(null),
|
|
1313
1315
|
focused: false,
|
|
1314
1316
|
inputSource: User,
|
|
1317
|
+
placeholder: '',
|
|
1315
1318
|
platform,
|
|
1316
1319
|
value: ''
|
|
1317
1320
|
};
|
|
@@ -2935,6 +2938,16 @@ const handleFocus = async state => {
|
|
|
2935
2938
|
return state;
|
|
2936
2939
|
};
|
|
2937
2940
|
|
|
2941
|
+
const commandMapRef = {};
|
|
2942
|
+
|
|
2943
|
+
const handleMessagePort = async port => {
|
|
2944
|
+
await PlainMessagePortRpc.create({
|
|
2945
|
+
commandMap: commandMapRef,
|
|
2946
|
+
isMessagePortOpen: true,
|
|
2947
|
+
messagePort: port
|
|
2948
|
+
});
|
|
2949
|
+
};
|
|
2950
|
+
|
|
2938
2951
|
const initialize = async () => {
|
|
2939
2952
|
// TODO
|
|
2940
2953
|
const rpc = await TransferMessagePortRpcParent.create({
|
|
@@ -2987,6 +3000,27 @@ const getQuickPickProviderId = prefix => {
|
|
|
2987
3000
|
}
|
|
2988
3001
|
};
|
|
2989
3002
|
|
|
3003
|
+
const parseArgs = (subId, args) => {
|
|
3004
|
+
if (subId !== Custom$1) {
|
|
3005
|
+
return {
|
|
3006
|
+
ignoreFocusOut: false,
|
|
3007
|
+
initialValue: ''
|
|
3008
|
+
};
|
|
3009
|
+
}
|
|
3010
|
+
const last = args.at(-1);
|
|
3011
|
+
if (!last || typeof last !== 'object') {
|
|
3012
|
+
return {
|
|
3013
|
+
ignoreFocusOut: false,
|
|
3014
|
+
initialValue: ''
|
|
3015
|
+
};
|
|
3016
|
+
}
|
|
3017
|
+
return {
|
|
3018
|
+
// @ts-ignore
|
|
3019
|
+
ignoreFocusOut: Boolean(last.ignoreFocusOut),
|
|
3020
|
+
// @ts-ignore
|
|
3021
|
+
initialValue: String(last.initialValue)
|
|
3022
|
+
};
|
|
3023
|
+
};
|
|
2990
3024
|
const loadContent = async state => {
|
|
2991
3025
|
const {
|
|
2992
3026
|
args,
|
|
@@ -3017,6 +3051,8 @@ const loadContent = async state => {
|
|
|
3017
3051
|
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
3018
3052
|
const listHeight = getListHeight(items.length, itemHeight, height);
|
|
3019
3053
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
3054
|
+
const parsedArgs = parseArgs(subId, args);
|
|
3055
|
+
const finalValue = parsedArgs.initialValue || value;
|
|
3020
3056
|
return {
|
|
3021
3057
|
...state,
|
|
3022
3058
|
args,
|
|
@@ -3031,12 +3067,20 @@ const loadContent = async state => {
|
|
|
3031
3067
|
maxLineY,
|
|
3032
3068
|
minLineY,
|
|
3033
3069
|
picks: newPicks,
|
|
3070
|
+
placeholder: '',
|
|
3034
3071
|
providerId: id,
|
|
3035
3072
|
state: Finished,
|
|
3036
|
-
value
|
|
3073
|
+
value: finalValue
|
|
3037
3074
|
};
|
|
3038
3075
|
};
|
|
3039
3076
|
|
|
3077
|
+
const callbacks = Object.create(null);
|
|
3078
|
+
const executeCallback = id => {
|
|
3079
|
+
const fn = callbacks[id];
|
|
3080
|
+
delete callbacks[id];
|
|
3081
|
+
fn();
|
|
3082
|
+
};
|
|
3083
|
+
|
|
3040
3084
|
const getVisible$1 = (items, minLineY, maxLineY, icons) => {
|
|
3041
3085
|
const range = items.slice(minLineY, maxLineY);
|
|
3042
3086
|
const protoVisibleItems = range.map((item, index) => {
|
|
@@ -3169,6 +3213,12 @@ const renderHeight = newState => {
|
|
|
3169
3213
|
return ['Viewlet.send', newState.uid, /* method */SetItemsHeight, /* height */newState.height];
|
|
3170
3214
|
};
|
|
3171
3215
|
|
|
3216
|
+
const Div = 4;
|
|
3217
|
+
const Input = 6;
|
|
3218
|
+
const Span = 8;
|
|
3219
|
+
const Text = 12;
|
|
3220
|
+
const Img = 17;
|
|
3221
|
+
|
|
3172
3222
|
const mergeClassNames = (...classNames) => {
|
|
3173
3223
|
return classNames.filter(Boolean).join(' ');
|
|
3174
3224
|
};
|
|
@@ -3490,7 +3540,10 @@ const renderEventListeners = () => {
|
|
|
3490
3540
|
};
|
|
3491
3541
|
|
|
3492
3542
|
const selectCurrentIndex = state => {
|
|
3493
|
-
|
|
3543
|
+
const {
|
|
3544
|
+
focusedIndex
|
|
3545
|
+
} = state;
|
|
3546
|
+
return selectIndex(state, focusedIndex);
|
|
3494
3547
|
};
|
|
3495
3548
|
|
|
3496
3549
|
const findLabelIndex = (items, label) => {
|
|
@@ -3511,12 +3564,32 @@ const selectItem = async (state, label) => {
|
|
|
3511
3564
|
return selectIndex(state, index);
|
|
3512
3565
|
};
|
|
3513
3566
|
|
|
3567
|
+
const showQuickInput = async ({
|
|
3568
|
+
ignoreFocusOut,
|
|
3569
|
+
initialValue,
|
|
3570
|
+
waitUntil
|
|
3571
|
+
}) => {
|
|
3572
|
+
// TODO ask renderer worker to create quickpick instance, with given options
|
|
3573
|
+
const picks = [];
|
|
3574
|
+
// const id=QuickPickCallbacks.registerCallback()
|
|
3575
|
+
await invoke$1('QuickPick.showCustom', picks, {
|
|
3576
|
+
ignoreFocusOut,
|
|
3577
|
+
initialValue,
|
|
3578
|
+
waitUntil
|
|
3579
|
+
});
|
|
3580
|
+
return {
|
|
3581
|
+
canceled: false,
|
|
3582
|
+
inputValue: ''
|
|
3583
|
+
};
|
|
3584
|
+
};
|
|
3585
|
+
|
|
3514
3586
|
const commandMap = {
|
|
3515
3587
|
'QuickPick.addMenuEntries': add,
|
|
3516
3588
|
'QuickPick.close': close,
|
|
3517
3589
|
'QuickPick.create2': create,
|
|
3518
3590
|
'QuickPick.diff2': diff2,
|
|
3519
3591
|
'QuickPick.dispose': dispose,
|
|
3592
|
+
'QuickPick.executeCallback': executeCallback,
|
|
3520
3593
|
'QuickPick.focusFirst': wrapCommand(focusFirst),
|
|
3521
3594
|
'QuickPick.focusIndex': wrapCommand(focusIndex),
|
|
3522
3595
|
'QuickPick.focusLast': wrapCommand(focusLast),
|
|
@@ -3529,6 +3602,7 @@ const commandMap = {
|
|
|
3529
3602
|
'QuickPick.handleClickAt': wrapCommand(handleClickAt),
|
|
3530
3603
|
'QuickPick.handleFocus': wrapCommand(handleFocus),
|
|
3531
3604
|
'QuickPick.handleInput': wrapCommand(handleInput),
|
|
3605
|
+
'QuickPick.handleMessagePort': handleMessagePort,
|
|
3532
3606
|
'QuickPick.handleWheel': wrapCommand(handleWheel),
|
|
3533
3607
|
'QuickPick.initialize': initialize,
|
|
3534
3608
|
'QuickPick.loadContent': wrapCommand(loadContent),
|
|
@@ -3538,7 +3612,8 @@ const commandMap = {
|
|
|
3538
3612
|
'QuickPick.selectIndex': wrapCommand(selectIndex),
|
|
3539
3613
|
'QuickPick.selectItem': wrapCommand(selectItem),
|
|
3540
3614
|
'QuickPick.setDeltaY': wrapCommand(setDeltaY),
|
|
3541
|
-
'QuickPick.setValue': wrapCommand(setValue)
|
|
3615
|
+
'QuickPick.setValue': wrapCommand(setValue),
|
|
3616
|
+
'QuickPick.showQuickInput': showQuickInput
|
|
3542
3617
|
};
|
|
3543
3618
|
|
|
3544
3619
|
const Memfs = 'memfs';
|
|
@@ -3563,7 +3638,7 @@ const searchFile$1 = async uri => {
|
|
|
3563
3638
|
};
|
|
3564
3639
|
|
|
3565
3640
|
const getFileSearchRipGrepArgs = () => {
|
|
3566
|
-
const ripGrepArgs = ['--files', '--sort-files'];
|
|
3641
|
+
const ripGrepArgs = ['--files', '--sort-files', '--hidden'];
|
|
3567
3642
|
return ripGrepArgs;
|
|
3568
3643
|
};
|
|
3569
3644
|
|
|
@@ -3594,6 +3669,7 @@ const searchModules = {
|
|
|
3594
3669
|
};
|
|
3595
3670
|
|
|
3596
3671
|
const listen = async () => {
|
|
3672
|
+
Object.assign(commandMapRef, commandMap);
|
|
3597
3673
|
registerCommands(commandMap);
|
|
3598
3674
|
register(searchModules);
|
|
3599
3675
|
const rpc = await WebWorkerRpcClient.create({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/file-search-worker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"text-search"
|
|
6
6
|
],
|
|
@@ -11,5 +11,8 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Lvce Editor",
|
|
13
13
|
"type": "module",
|
|
14
|
-
"main": "dist/fileSearchWorkerMain.js"
|
|
14
|
+
"main": "dist/fileSearchWorkerMain.js",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@lvce-editor/constants": "^2.8.0"
|
|
17
|
+
}
|
|
15
18
|
}
|