@lvce-editor/file-search-worker 5.14.0 → 5.16.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 +94 -51
- package/package.json +1 -1
|
@@ -356,22 +356,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
356
356
|
const wrap$f = global => {
|
|
357
357
|
return new IpcChildWithModuleWorker(global);
|
|
358
358
|
};
|
|
359
|
-
const withResolvers = () => {
|
|
360
|
-
let _resolve;
|
|
361
|
-
const promise = new Promise(resolve => {
|
|
362
|
-
_resolve = resolve;
|
|
363
|
-
});
|
|
364
|
-
return {
|
|
365
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
366
|
-
resolve: _resolve,
|
|
367
|
-
promise
|
|
368
|
-
};
|
|
369
|
-
};
|
|
370
359
|
const waitForFirstMessage = async port => {
|
|
371
360
|
const {
|
|
372
361
|
resolve,
|
|
373
362
|
promise
|
|
374
|
-
} = withResolvers();
|
|
363
|
+
} = Promise.withResolvers();
|
|
375
364
|
port.addEventListener('message', resolve, {
|
|
376
365
|
once: true
|
|
377
366
|
});
|
|
@@ -434,7 +423,7 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
434
423
|
};
|
|
435
424
|
|
|
436
425
|
const Two = '2.0';
|
|
437
|
-
const create$4 = (method, params) => {
|
|
426
|
+
const create$4$1 = (method, params) => {
|
|
438
427
|
return {
|
|
439
428
|
jsonrpc: Two,
|
|
440
429
|
method,
|
|
@@ -442,7 +431,7 @@ const create$4 = (method, params) => {
|
|
|
442
431
|
};
|
|
443
432
|
};
|
|
444
433
|
const callbacks = Object.create(null);
|
|
445
|
-
const set$
|
|
434
|
+
const set$2 = (id, fn) => {
|
|
446
435
|
callbacks[id] = fn;
|
|
447
436
|
};
|
|
448
437
|
const get$2 = id => {
|
|
@@ -461,7 +450,7 @@ const registerPromise = () => {
|
|
|
461
450
|
resolve,
|
|
462
451
|
promise
|
|
463
452
|
} = Promise.withResolvers();
|
|
464
|
-
set$
|
|
453
|
+
set$2(id, resolve);
|
|
465
454
|
return {
|
|
466
455
|
id,
|
|
467
456
|
promise
|
|
@@ -534,6 +523,16 @@ const constructError = (message, type, name) => {
|
|
|
534
523
|
}
|
|
535
524
|
return new ErrorConstructor(message);
|
|
536
525
|
};
|
|
526
|
+
const joinLines = lines => {
|
|
527
|
+
return lines.join(NewLine);
|
|
528
|
+
};
|
|
529
|
+
const splitLines$1 = lines => {
|
|
530
|
+
return lines.split(NewLine);
|
|
531
|
+
};
|
|
532
|
+
const getCurrentStack = () => {
|
|
533
|
+
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(2));
|
|
534
|
+
return currentStack;
|
|
535
|
+
};
|
|
537
536
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
538
537
|
return string.indexOf(NewLine, startIndex);
|
|
539
538
|
};
|
|
@@ -544,19 +543,16 @@ const getParentStack = error => {
|
|
|
544
543
|
}
|
|
545
544
|
return parentStack;
|
|
546
545
|
};
|
|
547
|
-
const joinLines = lines => {
|
|
548
|
-
return lines.join(NewLine);
|
|
549
|
-
};
|
|
550
546
|
const MethodNotFound = -32601;
|
|
551
547
|
const Custom$1 = -32001;
|
|
552
|
-
const splitLines$1 = lines => {
|
|
553
|
-
return lines.split(NewLine);
|
|
554
|
-
};
|
|
555
548
|
const restoreJsonRpcError = error => {
|
|
549
|
+
const currentStack = getCurrentStack();
|
|
556
550
|
if (error && error instanceof Error) {
|
|
551
|
+
if (typeof error.stack === 'string') {
|
|
552
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
553
|
+
}
|
|
557
554
|
return error;
|
|
558
555
|
}
|
|
559
|
-
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(1));
|
|
560
556
|
if (error && error.code && error.code === MethodNotFound) {
|
|
561
557
|
const restoredError = new JsonRpcError(error.message);
|
|
562
558
|
const parentStack = getParentStack(error);
|
|
@@ -637,6 +633,17 @@ const getErrorType = prettyError => {
|
|
|
637
633
|
}
|
|
638
634
|
return undefined;
|
|
639
635
|
};
|
|
636
|
+
const isAlreadyStack = line => {
|
|
637
|
+
return line.trim().startsWith('at ');
|
|
638
|
+
};
|
|
639
|
+
const getStack = prettyError => {
|
|
640
|
+
const stackString = prettyError.stack || '';
|
|
641
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
642
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
643
|
+
return stackString.slice(newLineIndex + 1);
|
|
644
|
+
}
|
|
645
|
+
return stackString;
|
|
646
|
+
};
|
|
640
647
|
const getErrorProperty = (error, prettyError) => {
|
|
641
648
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
642
649
|
return {
|
|
@@ -649,7 +656,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
649
656
|
code: Custom$1,
|
|
650
657
|
message: prettyError.message,
|
|
651
658
|
data: {
|
|
652
|
-
stack: prettyError
|
|
659
|
+
stack: getStack(prettyError),
|
|
653
660
|
codeFrame: prettyError.codeFrame,
|
|
654
661
|
type: getErrorType(prettyError),
|
|
655
662
|
code: prettyError.code,
|
|
@@ -657,18 +664,18 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
657
664
|
}
|
|
658
665
|
};
|
|
659
666
|
};
|
|
660
|
-
const create$1$1 = (
|
|
667
|
+
const create$1$1 = (id, error) => {
|
|
661
668
|
return {
|
|
662
669
|
jsonrpc: Two,
|
|
663
|
-
id
|
|
670
|
+
id,
|
|
664
671
|
error
|
|
665
672
|
};
|
|
666
673
|
};
|
|
667
|
-
const getErrorResponse = (
|
|
674
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
668
675
|
const prettyError = preparePrettyError(error);
|
|
669
676
|
logError(error, prettyError);
|
|
670
677
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
671
|
-
return create$1$1(
|
|
678
|
+
return create$1$1(id, errorProperty);
|
|
672
679
|
};
|
|
673
680
|
const create$5 = (message, result) => {
|
|
674
681
|
return {
|
|
@@ -681,12 +688,27 @@ const getSuccessResponse = (message, result) => {
|
|
|
681
688
|
const resultProperty = result ?? null;
|
|
682
689
|
return create$5(message, resultProperty);
|
|
683
690
|
};
|
|
691
|
+
const getErrorResponseSimple = (id, error) => {
|
|
692
|
+
return {
|
|
693
|
+
jsonrpc: Two,
|
|
694
|
+
id,
|
|
695
|
+
error: {
|
|
696
|
+
code: Custom$1,
|
|
697
|
+
// @ts-ignore
|
|
698
|
+
message: error.message,
|
|
699
|
+
data: error
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
};
|
|
684
703
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
685
704
|
try {
|
|
686
705
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
687
706
|
return getSuccessResponse(message, result);
|
|
688
707
|
} catch (error) {
|
|
689
|
-
|
|
708
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
709
|
+
return getErrorResponseSimple(message.id, error);
|
|
710
|
+
}
|
|
711
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
690
712
|
}
|
|
691
713
|
};
|
|
692
714
|
const defaultPreparePrettyError = error => {
|
|
@@ -741,7 +763,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
741
763
|
try {
|
|
742
764
|
ipc.send(response);
|
|
743
765
|
} catch (error) {
|
|
744
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
766
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
745
767
|
ipc.send(errorResponse);
|
|
746
768
|
}
|
|
747
769
|
return;
|
|
@@ -769,10 +791,10 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
769
791
|
return unwrapJsonRpcResult(responseMessage);
|
|
770
792
|
};
|
|
771
793
|
const send = (transport, method, ...params) => {
|
|
772
|
-
const message = create$4(method, params);
|
|
794
|
+
const message = create$4$1(method, params);
|
|
773
795
|
transport.send(message);
|
|
774
796
|
};
|
|
775
|
-
const invoke$
|
|
797
|
+
const invoke$2 = (ipc, method, ...params) => {
|
|
776
798
|
return invokeHelper(ipc, method, params, false);
|
|
777
799
|
};
|
|
778
800
|
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
@@ -805,7 +827,7 @@ const createRpc = ipc => {
|
|
|
805
827
|
send(ipc, method, ...params);
|
|
806
828
|
},
|
|
807
829
|
invoke(method, ...params) {
|
|
808
|
-
return invoke$
|
|
830
|
+
return invoke$2(ipc, method, ...params);
|
|
809
831
|
},
|
|
810
832
|
invokeAndTransfer(method, ...params) {
|
|
811
833
|
return invokeAndTransfer(ipc, method, ...params);
|
|
@@ -846,7 +868,7 @@ const listen$1 = async (module, options) => {
|
|
|
846
868
|
const ipc = module.wrap(rawIpc);
|
|
847
869
|
return ipc;
|
|
848
870
|
};
|
|
849
|
-
const create$
|
|
871
|
+
const create$4 = async ({
|
|
850
872
|
commandMap
|
|
851
873
|
}) => {
|
|
852
874
|
// TODO create a commandMap per rpc instance
|
|
@@ -858,29 +880,50 @@ const create$3 = async ({
|
|
|
858
880
|
};
|
|
859
881
|
const WebWorkerRpcClient = {
|
|
860
882
|
__proto__: null,
|
|
861
|
-
create: create$
|
|
883
|
+
create: create$4
|
|
862
884
|
};
|
|
863
885
|
|
|
864
886
|
const rpcs = Object.create(null);
|
|
865
|
-
const set$
|
|
887
|
+
const set$g = (id, rpc) => {
|
|
866
888
|
rpcs[id] = rpc;
|
|
867
889
|
};
|
|
868
890
|
const get$1 = id => {
|
|
869
891
|
return rpcs[id];
|
|
870
892
|
};
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
return
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
893
|
+
|
|
894
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
895
|
+
|
|
896
|
+
const create$3 = rpcId => {
|
|
897
|
+
return {
|
|
898
|
+
// @ts-ignore
|
|
899
|
+
invoke(method, ...params) {
|
|
900
|
+
const rpc = get$1(rpcId);
|
|
901
|
+
// @ts-ignore
|
|
902
|
+
return rpc.invoke(method, ...params);
|
|
903
|
+
},
|
|
904
|
+
// @ts-ignore
|
|
905
|
+
invokeAndTransfer(method, ...params) {
|
|
906
|
+
const rpc = get$1(rpcId);
|
|
907
|
+
// @ts-ignore
|
|
908
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
909
|
+
},
|
|
910
|
+
set(rpc) {
|
|
911
|
+
set$g(rpcId, rpc);
|
|
912
|
+
},
|
|
913
|
+
async dispose() {
|
|
914
|
+
const rpc = get$1(rpcId);
|
|
915
|
+
await rpc.dispose();
|
|
916
|
+
}
|
|
917
|
+
};
|
|
879
918
|
};
|
|
919
|
+
const RendererWorker$1 = 1;
|
|
920
|
+
const {
|
|
921
|
+
invoke: invoke$4,
|
|
922
|
+
set: set$3} = create$3(RendererWorker$1);
|
|
880
923
|
const RendererWorker = {
|
|
881
924
|
__proto__: null,
|
|
882
|
-
invoke: invoke$
|
|
883
|
-
set: set$
|
|
925
|
+
invoke: invoke$4,
|
|
926
|
+
set: set$3
|
|
884
927
|
};
|
|
885
928
|
|
|
886
929
|
const {
|
|
@@ -2817,6 +2860,12 @@ const getFileIconVirtualDom = icon => {
|
|
|
2817
2860
|
const mergeClassNames = (...classNames) => {
|
|
2818
2861
|
return classNames.filter(Boolean).join(' ');
|
|
2819
2862
|
};
|
|
2863
|
+
const px = value => {
|
|
2864
|
+
return `${value}px`;
|
|
2865
|
+
};
|
|
2866
|
+
const position = (x, y) => {
|
|
2867
|
+
return `${x}px ${y}px`;
|
|
2868
|
+
};
|
|
2820
2869
|
const Text = 12;
|
|
2821
2870
|
const text = data => {
|
|
2822
2871
|
return {
|
|
@@ -2825,12 +2874,6 @@ const text = data => {
|
|
|
2825
2874
|
childCount: 0
|
|
2826
2875
|
};
|
|
2827
2876
|
};
|
|
2828
|
-
const px = value => {
|
|
2829
|
-
return `${value}px`;
|
|
2830
|
-
};
|
|
2831
|
-
const position = (x, y) => {
|
|
2832
|
-
return `${x}px ${y}px`;
|
|
2833
|
-
};
|
|
2834
2877
|
|
|
2835
2878
|
const quickPickHighlight = {
|
|
2836
2879
|
type: Span,
|