@lvce-editor/hover-worker 2.13.0 → 2.15.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/hoverWorkerMain.js +281 -310
- package/package.json +1 -1
package/dist/hoverWorkerMain.js
CHANGED
|
@@ -139,7 +139,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
139
139
|
for (const property of Object.values(value)) {
|
|
140
140
|
walkValue(property, transferrables, isTransferrable);
|
|
141
141
|
}
|
|
142
|
-
return;
|
|
143
142
|
}
|
|
144
143
|
};
|
|
145
144
|
const getTransferrables = value => {
|
|
@@ -293,7 +292,14 @@ class IpcError extends VError {
|
|
|
293
292
|
const cause = new Error(message);
|
|
294
293
|
// @ts-ignore
|
|
295
294
|
cause.code = code;
|
|
296
|
-
|
|
295
|
+
if (stack) {
|
|
296
|
+
Object.defineProperty(cause, 'stack', {
|
|
297
|
+
configurable: true,
|
|
298
|
+
enumerable: false,
|
|
299
|
+
value: stack,
|
|
300
|
+
writable: true
|
|
301
|
+
});
|
|
302
|
+
}
|
|
297
303
|
super(cause, betterMessage);
|
|
298
304
|
} else {
|
|
299
305
|
super(betterMessage);
|
|
@@ -450,7 +456,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
450
456
|
return promise;
|
|
451
457
|
};
|
|
452
458
|
const Message$1 = 3;
|
|
453
|
-
const create$5 = async ({
|
|
459
|
+
const create$5$1 = async ({
|
|
454
460
|
isMessagePortOpen,
|
|
455
461
|
messagePort
|
|
456
462
|
}) => {
|
|
@@ -501,11 +507,32 @@ const wrap$5 = messagePort => {
|
|
|
501
507
|
};
|
|
502
508
|
const IpcParentWithMessagePort$1 = {
|
|
503
509
|
__proto__: null,
|
|
504
|
-
create: create$5,
|
|
510
|
+
create: create$5$1,
|
|
505
511
|
signal: signal$1,
|
|
506
512
|
wrap: wrap$5
|
|
507
513
|
};
|
|
508
514
|
|
|
515
|
+
class CommandNotFoundError extends Error {
|
|
516
|
+
constructor(command) {
|
|
517
|
+
super(`Command not found ${command}`);
|
|
518
|
+
this.name = 'CommandNotFoundError';
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const commands = Object.create(null);
|
|
522
|
+
const register = commandMap => {
|
|
523
|
+
Object.assign(commands, commandMap);
|
|
524
|
+
};
|
|
525
|
+
const getCommand$1 = key => {
|
|
526
|
+
return commands[key];
|
|
527
|
+
};
|
|
528
|
+
const execute$1 = (command, ...args) => {
|
|
529
|
+
const fn = getCommand$1(command);
|
|
530
|
+
if (!fn) {
|
|
531
|
+
throw new CommandNotFoundError(command);
|
|
532
|
+
}
|
|
533
|
+
return fn(...args);
|
|
534
|
+
};
|
|
535
|
+
|
|
509
536
|
const Two$1 = '2.0';
|
|
510
537
|
const callbacks = Object.create(null);
|
|
511
538
|
const get$2 = id => {
|
|
@@ -530,12 +557,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
530
557
|
switch (type) {
|
|
531
558
|
case DomException:
|
|
532
559
|
return DOMException;
|
|
533
|
-
case TypeError$1:
|
|
534
|
-
return TypeError;
|
|
535
|
-
case SyntaxError$1:
|
|
536
|
-
return SyntaxError;
|
|
537
560
|
case ReferenceError$1:
|
|
538
561
|
return ReferenceError;
|
|
562
|
+
case SyntaxError$1:
|
|
563
|
+
return SyntaxError;
|
|
564
|
+
case TypeError$1:
|
|
565
|
+
return TypeError;
|
|
539
566
|
default:
|
|
540
567
|
return Error;
|
|
541
568
|
}
|
|
@@ -559,7 +586,10 @@ const constructError = (message, type, name) => {
|
|
|
559
586
|
if (ErrorConstructor === Error) {
|
|
560
587
|
const error = new Error(message);
|
|
561
588
|
if (name && name !== 'VError') {
|
|
562
|
-
error
|
|
589
|
+
Object.defineProperty(error, 'name', {
|
|
590
|
+
configurable: true,
|
|
591
|
+
value: name
|
|
592
|
+
});
|
|
563
593
|
}
|
|
564
594
|
return error;
|
|
565
595
|
}
|
|
@@ -576,8 +606,10 @@ const getCurrentStack = () => {
|
|
|
576
606
|
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
577
607
|
return currentStack;
|
|
578
608
|
};
|
|
579
|
-
const getNewLineIndex = (string, startIndex
|
|
580
|
-
|
|
609
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
610
|
+
{
|
|
611
|
+
return string.indexOf(NewLine);
|
|
612
|
+
}
|
|
581
613
|
};
|
|
582
614
|
const getParentStack = error => {
|
|
583
615
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -588,55 +620,91 @@ const getParentStack = error => {
|
|
|
588
620
|
};
|
|
589
621
|
const MethodNotFound = -32601;
|
|
590
622
|
const Custom = -32001;
|
|
623
|
+
const setStack = (error, stack) => {
|
|
624
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
625
|
+
if (descriptor) {
|
|
626
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
630
|
+
error.stack = stack;
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
Object.defineProperty(error, 'stack', {
|
|
635
|
+
configurable: true,
|
|
636
|
+
value: stack,
|
|
637
|
+
writable: true
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
const restoreExistingError = (error, currentStack) => {
|
|
641
|
+
if (typeof error.stack === 'string') {
|
|
642
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
643
|
+
}
|
|
644
|
+
return error;
|
|
645
|
+
};
|
|
646
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
647
|
+
const restoredError = new JsonRpcError(error.message);
|
|
648
|
+
const parentStack = getParentStack(error);
|
|
649
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
650
|
+
return restoredError;
|
|
651
|
+
};
|
|
652
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
653
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
654
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (error.data.stack) {
|
|
658
|
+
setStack(restoredError, error.data.stack);
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
const applyDataProperties = (restoredError, error) => {
|
|
662
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
663
|
+
if (error.data.codeFrame) {
|
|
664
|
+
// @ts-ignore
|
|
665
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
666
|
+
}
|
|
667
|
+
if (error.data.code) {
|
|
668
|
+
// @ts-ignore
|
|
669
|
+
restoredError.code = error.data.code;
|
|
670
|
+
}
|
|
671
|
+
if (error.data.type) {
|
|
672
|
+
// @ts-ignore
|
|
673
|
+
restoredError.name = error.data.type;
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
677
|
+
if (error.stack) {
|
|
678
|
+
const lowerStack = restoredError.stack || '';
|
|
679
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
680
|
+
const parentStack = getParentStack(error);
|
|
681
|
+
// @ts-ignore
|
|
682
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
683
|
+
}
|
|
684
|
+
if (error.codeFrame) {
|
|
685
|
+
// @ts-ignore
|
|
686
|
+
restoredError.codeFrame = error.codeFrame;
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
690
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
691
|
+
if (error.data) {
|
|
692
|
+
applyDataProperties(restoredError, error);
|
|
693
|
+
} else {
|
|
694
|
+
applyDirectProperties(restoredError, error);
|
|
695
|
+
}
|
|
696
|
+
return restoredError;
|
|
697
|
+
};
|
|
591
698
|
const restoreJsonRpcError = error => {
|
|
592
699
|
const currentStack = getCurrentStack();
|
|
593
700
|
if (error && error instanceof Error) {
|
|
594
|
-
|
|
595
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
596
|
-
}
|
|
597
|
-
return error;
|
|
701
|
+
return restoreExistingError(error, currentStack);
|
|
598
702
|
}
|
|
599
703
|
if (error && error.code && error.code === MethodNotFound) {
|
|
600
|
-
|
|
601
|
-
const parentStack = getParentStack(error);
|
|
602
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
603
|
-
return restoredError;
|
|
704
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
604
705
|
}
|
|
605
706
|
if (error && error.message) {
|
|
606
|
-
|
|
607
|
-
if (error.data) {
|
|
608
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
609
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
610
|
-
} else if (error.data.stack) {
|
|
611
|
-
restoredError.stack = error.data.stack;
|
|
612
|
-
}
|
|
613
|
-
if (error.data.codeFrame) {
|
|
614
|
-
// @ts-ignore
|
|
615
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
616
|
-
}
|
|
617
|
-
if (error.data.code) {
|
|
618
|
-
// @ts-ignore
|
|
619
|
-
restoredError.code = error.data.code;
|
|
620
|
-
}
|
|
621
|
-
if (error.data.type) {
|
|
622
|
-
// @ts-ignore
|
|
623
|
-
restoredError.name = error.data.type;
|
|
624
|
-
}
|
|
625
|
-
} else {
|
|
626
|
-
if (error.stack) {
|
|
627
|
-
const lowerStack = restoredError.stack || '';
|
|
628
|
-
// @ts-ignore
|
|
629
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
630
|
-
const parentStack = getParentStack(error);
|
|
631
|
-
// @ts-ignore
|
|
632
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
633
|
-
}
|
|
634
|
-
if (error.codeFrame) {
|
|
635
|
-
// @ts-ignore
|
|
636
|
-
restoredError.codeFrame = error.codeFrame;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
return restoredError;
|
|
707
|
+
return restoreMessageError(error);
|
|
640
708
|
}
|
|
641
709
|
if (typeof error === 'string') {
|
|
642
710
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -691,56 +759,56 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
691
759
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
692
760
|
return {
|
|
693
761
|
code: MethodNotFound,
|
|
694
|
-
|
|
695
|
-
|
|
762
|
+
data: error.stack,
|
|
763
|
+
message: error.message
|
|
696
764
|
};
|
|
697
765
|
}
|
|
698
766
|
return {
|
|
699
767
|
code: Custom,
|
|
700
|
-
message: prettyError.message,
|
|
701
768
|
data: {
|
|
702
|
-
stack: getStack(prettyError),
|
|
703
|
-
codeFrame: prettyError.codeFrame,
|
|
704
|
-
type: getErrorType(prettyError),
|
|
705
769
|
code: prettyError.code,
|
|
706
|
-
|
|
707
|
-
|
|
770
|
+
codeFrame: prettyError.codeFrame,
|
|
771
|
+
name: prettyError.name,
|
|
772
|
+
stack: getStack(prettyError),
|
|
773
|
+
type: getErrorType(prettyError)
|
|
774
|
+
},
|
|
775
|
+
message: prettyError.message
|
|
708
776
|
};
|
|
709
777
|
};
|
|
710
|
-
const create$1$
|
|
778
|
+
const create$1$1 = (id, error) => {
|
|
711
779
|
return {
|
|
712
|
-
|
|
780
|
+
error,
|
|
713
781
|
id,
|
|
714
|
-
|
|
782
|
+
jsonrpc: Two$1
|
|
715
783
|
};
|
|
716
784
|
};
|
|
717
785
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
718
786
|
const prettyError = preparePrettyError(error);
|
|
719
787
|
logError(error, prettyError);
|
|
720
788
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
721
|
-
return create$1$
|
|
789
|
+
return create$1$1(id, errorProperty);
|
|
722
790
|
};
|
|
723
|
-
const create$
|
|
791
|
+
const create$9 = (message, result) => {
|
|
724
792
|
return {
|
|
725
|
-
jsonrpc: Two$1,
|
|
726
793
|
id: message.id,
|
|
794
|
+
jsonrpc: Two$1,
|
|
727
795
|
result: result ?? null
|
|
728
796
|
};
|
|
729
797
|
};
|
|
730
798
|
const getSuccessResponse = (message, result) => {
|
|
731
799
|
const resultProperty = result ?? null;
|
|
732
|
-
return create$
|
|
800
|
+
return create$9(message, resultProperty);
|
|
733
801
|
};
|
|
734
802
|
const getErrorResponseSimple = (id, error) => {
|
|
735
803
|
return {
|
|
736
|
-
jsonrpc: Two$1,
|
|
737
|
-
id,
|
|
738
804
|
error: {
|
|
739
805
|
code: Custom,
|
|
806
|
+
data: error,
|
|
740
807
|
// @ts-ignore
|
|
741
|
-
message: error.message
|
|
742
|
-
|
|
743
|
-
|
|
808
|
+
message: error.message
|
|
809
|
+
},
|
|
810
|
+
id,
|
|
811
|
+
jsonrpc: Two$1
|
|
744
812
|
};
|
|
745
813
|
};
|
|
746
814
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -770,35 +838,35 @@ const normalizeParams = args => {
|
|
|
770
838
|
if (args.length === 1) {
|
|
771
839
|
const options = args[0];
|
|
772
840
|
return {
|
|
841
|
+
execute: options.execute,
|
|
773
842
|
ipc: options.ipc,
|
|
843
|
+
logError: options.logError || defaultLogError,
|
|
774
844
|
message: options.message,
|
|
775
|
-
execute: options.execute,
|
|
776
|
-
resolve: options.resolve || defaultResolve,
|
|
777
845
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
778
|
-
|
|
779
|
-
|
|
846
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
847
|
+
resolve: options.resolve || defaultResolve
|
|
780
848
|
};
|
|
781
849
|
}
|
|
782
850
|
return {
|
|
851
|
+
execute: args[2],
|
|
783
852
|
ipc: args[0],
|
|
853
|
+
logError: args[5],
|
|
784
854
|
message: args[1],
|
|
785
|
-
execute: args[2],
|
|
786
|
-
resolve: args[3],
|
|
787
855
|
preparePrettyError: args[4],
|
|
788
|
-
|
|
789
|
-
|
|
856
|
+
requiresSocket: args[6],
|
|
857
|
+
resolve: args[3]
|
|
790
858
|
};
|
|
791
859
|
};
|
|
792
860
|
const handleJsonRpcMessage = async (...args) => {
|
|
793
861
|
const options = normalizeParams(args);
|
|
794
862
|
const {
|
|
795
|
-
message,
|
|
796
|
-
ipc,
|
|
797
863
|
execute,
|
|
798
|
-
|
|
799
|
-
preparePrettyError,
|
|
864
|
+
ipc,
|
|
800
865
|
logError,
|
|
801
|
-
|
|
866
|
+
message,
|
|
867
|
+
preparePrettyError,
|
|
868
|
+
requiresSocket,
|
|
869
|
+
resolve
|
|
802
870
|
} = options;
|
|
803
871
|
if ('id' in message) {
|
|
804
872
|
if ('method' in message) {
|
|
@@ -821,36 +889,17 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
821
889
|
throw new JsonRpcError('unexpected message');
|
|
822
890
|
};
|
|
823
891
|
|
|
824
|
-
class CommandNotFoundError extends Error {
|
|
825
|
-
constructor(command) {
|
|
826
|
-
super(`Command not found ${command}`);
|
|
827
|
-
this.name = 'CommandNotFoundError';
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
const commands = Object.create(null);
|
|
831
|
-
const register = commandMap => {
|
|
832
|
-
Object.assign(commands, commandMap);
|
|
833
|
-
};
|
|
834
|
-
const getCommand$1 = key => {
|
|
835
|
-
return commands[key];
|
|
836
|
-
};
|
|
837
|
-
const execute$1 = (command, ...args) => {
|
|
838
|
-
const fn = getCommand$1(command);
|
|
839
|
-
if (!fn) {
|
|
840
|
-
throw new CommandNotFoundError(command);
|
|
841
|
-
}
|
|
842
|
-
return fn(...args);
|
|
843
|
-
};
|
|
844
|
-
|
|
845
892
|
const Two = '2.0';
|
|
846
|
-
|
|
893
|
+
|
|
894
|
+
const create$8 = (method, params) => {
|
|
847
895
|
return {
|
|
848
896
|
jsonrpc: Two,
|
|
849
897
|
method,
|
|
850
898
|
params
|
|
851
899
|
};
|
|
852
900
|
};
|
|
853
|
-
|
|
901
|
+
|
|
902
|
+
const create$7 = (id, method, params) => {
|
|
854
903
|
const message = {
|
|
855
904
|
id,
|
|
856
905
|
jsonrpc: Two,
|
|
@@ -859,15 +908,14 @@ const create$r = (id, method, params) => {
|
|
|
859
908
|
};
|
|
860
909
|
return message;
|
|
861
910
|
};
|
|
911
|
+
|
|
862
912
|
let id = 0;
|
|
863
|
-
const create$
|
|
913
|
+
const create$6 = () => {
|
|
864
914
|
return ++id;
|
|
865
915
|
};
|
|
866
916
|
|
|
867
|
-
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
868
|
-
|
|
869
917
|
const registerPromise = map => {
|
|
870
|
-
const id = create$
|
|
918
|
+
const id = create$6();
|
|
871
919
|
const {
|
|
872
920
|
promise,
|
|
873
921
|
resolve
|
|
@@ -879,13 +927,12 @@ const registerPromise = map => {
|
|
|
879
927
|
};
|
|
880
928
|
};
|
|
881
929
|
|
|
882
|
-
// @ts-ignore
|
|
883
930
|
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
884
931
|
const {
|
|
885
932
|
id,
|
|
886
933
|
promise
|
|
887
934
|
} = registerPromise(callbacks);
|
|
888
|
-
const message = create$
|
|
935
|
+
const message = create$7(id, method, params);
|
|
889
936
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
890
937
|
ipc.sendAndTransfer(message);
|
|
891
938
|
} else {
|
|
@@ -921,12 +968,13 @@ const createRpc = ipc => {
|
|
|
921
968
|
* @deprecated
|
|
922
969
|
*/
|
|
923
970
|
send(method, ...params) {
|
|
924
|
-
const message = create$
|
|
971
|
+
const message = create$8(method, params);
|
|
925
972
|
ipc.send(message);
|
|
926
973
|
}
|
|
927
974
|
};
|
|
928
975
|
return rpc;
|
|
929
976
|
};
|
|
977
|
+
|
|
930
978
|
const requiresSocket = () => {
|
|
931
979
|
return false;
|
|
932
980
|
};
|
|
@@ -941,6 +989,7 @@ const handleMessage = event => {
|
|
|
941
989
|
const actualExecute = event?.target?.execute || execute$1;
|
|
942
990
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
943
991
|
};
|
|
992
|
+
|
|
944
993
|
const handleIpc = ipc => {
|
|
945
994
|
if ('addEventListener' in ipc) {
|
|
946
995
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -949,6 +998,7 @@ const handleIpc = ipc => {
|
|
|
949
998
|
ipc.on('message', handleMessage);
|
|
950
999
|
}
|
|
951
1000
|
};
|
|
1001
|
+
|
|
952
1002
|
const listen$1 = async (module, options) => {
|
|
953
1003
|
const rawIpc = await module.listen(options);
|
|
954
1004
|
if (module.signal) {
|
|
@@ -957,7 +1007,8 @@ const listen$1 = async (module, options) => {
|
|
|
957
1007
|
const ipc = module.wrap(rawIpc);
|
|
958
1008
|
return ipc;
|
|
959
1009
|
};
|
|
960
|
-
|
|
1010
|
+
|
|
1011
|
+
const create$5 = async ({
|
|
961
1012
|
commandMap,
|
|
962
1013
|
isMessagePortOpen = true,
|
|
963
1014
|
messagePort
|
|
@@ -974,7 +1025,8 @@ const create$4 = async ({
|
|
|
974
1025
|
messagePort.start();
|
|
975
1026
|
return rpc;
|
|
976
1027
|
};
|
|
977
|
-
|
|
1028
|
+
|
|
1029
|
+
const create$4 = async ({
|
|
978
1030
|
commandMap,
|
|
979
1031
|
isMessagePortOpen,
|
|
980
1032
|
send
|
|
@@ -984,17 +1036,14 @@ const create$2$1 = async ({
|
|
|
984
1036
|
port2
|
|
985
1037
|
} = new MessageChannel();
|
|
986
1038
|
await send(port1);
|
|
987
|
-
return create$
|
|
1039
|
+
return create$5({
|
|
988
1040
|
commandMap,
|
|
989
1041
|
isMessagePortOpen,
|
|
990
1042
|
messagePort: port2
|
|
991
1043
|
});
|
|
992
1044
|
};
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
create: create$2$1
|
|
996
|
-
};
|
|
997
|
-
const create$1$1 = async ({
|
|
1045
|
+
|
|
1046
|
+
const create$3 = async ({
|
|
998
1047
|
commandMap
|
|
999
1048
|
}) => {
|
|
1000
1049
|
// TODO create a commandMap per rpc instance
|
|
@@ -1004,9 +1053,25 @@ const create$1$1 = async ({
|
|
|
1004
1053
|
const rpc = createRpc(ipc);
|
|
1005
1054
|
return rpc;
|
|
1006
1055
|
};
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1056
|
+
|
|
1057
|
+
const createMockRpc = ({
|
|
1058
|
+
commandMap
|
|
1059
|
+
}) => {
|
|
1060
|
+
const invocations = [];
|
|
1061
|
+
const invoke = (method, ...params) => {
|
|
1062
|
+
invocations.push([method, ...params]);
|
|
1063
|
+
const command = commandMap[method];
|
|
1064
|
+
if (!command) {
|
|
1065
|
+
throw new Error(`command ${method} not found`);
|
|
1066
|
+
}
|
|
1067
|
+
return command(...params);
|
|
1068
|
+
};
|
|
1069
|
+
const mockRpc = {
|
|
1070
|
+
invocations,
|
|
1071
|
+
invoke,
|
|
1072
|
+
invokeAndTransfer: invoke
|
|
1073
|
+
};
|
|
1074
|
+
return mockRpc;
|
|
1010
1075
|
};
|
|
1011
1076
|
|
|
1012
1077
|
const toCommandId = key => {
|
|
@@ -1017,42 +1082,68 @@ const create$2 = () => {
|
|
|
1017
1082
|
const states = Object.create(null);
|
|
1018
1083
|
const commandMapRef = {};
|
|
1019
1084
|
return {
|
|
1020
|
-
|
|
1021
|
-
|
|
1085
|
+
clear() {
|
|
1086
|
+
for (const key of Object.keys(states)) {
|
|
1087
|
+
delete states[key];
|
|
1088
|
+
}
|
|
1022
1089
|
},
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
};
|
|
1090
|
+
diff(uid, modules, numbers) {
|
|
1091
|
+
const {
|
|
1092
|
+
newState,
|
|
1093
|
+
oldState
|
|
1094
|
+
} = states[uid];
|
|
1095
|
+
const diffResult = [];
|
|
1096
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1097
|
+
const fn = modules[i];
|
|
1098
|
+
if (!fn(oldState, newState)) {
|
|
1099
|
+
diffResult.push(numbers[i]);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
return diffResult;
|
|
1028
1103
|
},
|
|
1029
1104
|
dispose(uid) {
|
|
1030
1105
|
delete states[uid];
|
|
1031
1106
|
},
|
|
1107
|
+
get(uid) {
|
|
1108
|
+
return states[uid];
|
|
1109
|
+
},
|
|
1110
|
+
getCommandIds() {
|
|
1111
|
+
const keys = Object.keys(commandMapRef);
|
|
1112
|
+
const ids = keys.map(toCommandId);
|
|
1113
|
+
return ids;
|
|
1114
|
+
},
|
|
1032
1115
|
getKeys() {
|
|
1033
1116
|
return Object.keys(states).map(key => {
|
|
1034
|
-
return Number.
|
|
1117
|
+
return Number.parseFloat(key);
|
|
1035
1118
|
});
|
|
1036
1119
|
},
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1120
|
+
registerCommands(commandMap) {
|
|
1121
|
+
Object.assign(commandMapRef, commandMap);
|
|
1122
|
+
},
|
|
1123
|
+
set(uid, oldState, newState) {
|
|
1124
|
+
states[uid] = {
|
|
1125
|
+
newState,
|
|
1126
|
+
oldState
|
|
1127
|
+
};
|
|
1041
1128
|
},
|
|
1042
1129
|
wrapCommand(fn) {
|
|
1043
1130
|
const wrapped = async (uid, ...args) => {
|
|
1044
1131
|
const {
|
|
1045
|
-
|
|
1046
|
-
|
|
1132
|
+
newState,
|
|
1133
|
+
oldState
|
|
1047
1134
|
} = states[uid];
|
|
1048
1135
|
const newerState = await fn(newState, ...args);
|
|
1049
1136
|
if (oldState === newerState || newState === newerState) {
|
|
1050
1137
|
return;
|
|
1051
1138
|
}
|
|
1052
|
-
const
|
|
1139
|
+
const latestOld = states[uid];
|
|
1140
|
+
const latestNew = {
|
|
1141
|
+
...latestOld.newState,
|
|
1142
|
+
...newerState
|
|
1143
|
+
};
|
|
1053
1144
|
states[uid] = {
|
|
1054
|
-
|
|
1055
|
-
|
|
1145
|
+
newState: latestNew,
|
|
1146
|
+
oldState: latestOld.oldState
|
|
1056
1147
|
};
|
|
1057
1148
|
};
|
|
1058
1149
|
return wrapped;
|
|
@@ -1066,27 +1157,36 @@ const create$2 = () => {
|
|
|
1066
1157
|
};
|
|
1067
1158
|
return wrapped;
|
|
1068
1159
|
},
|
|
1069
|
-
|
|
1070
|
-
const {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
|
|
1160
|
+
wrapLoadContent(fn) {
|
|
1161
|
+
const wrapped = async (uid, ...args) => {
|
|
1162
|
+
const {
|
|
1163
|
+
newState,
|
|
1164
|
+
oldState
|
|
1165
|
+
} = states[uid];
|
|
1166
|
+
const result = await fn(newState, ...args);
|
|
1167
|
+
const {
|
|
1168
|
+
error,
|
|
1169
|
+
state
|
|
1170
|
+
} = result;
|
|
1171
|
+
if (oldState === state || newState === state) {
|
|
1172
|
+
return {
|
|
1173
|
+
error
|
|
1174
|
+
};
|
|
1079
1175
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1176
|
+
const latestOld = states[uid];
|
|
1177
|
+
const latestNew = {
|
|
1178
|
+
...latestOld.newState,
|
|
1179
|
+
...state
|
|
1180
|
+
};
|
|
1181
|
+
states[uid] = {
|
|
1182
|
+
newState: latestNew,
|
|
1183
|
+
oldState: latestOld.oldState
|
|
1184
|
+
};
|
|
1185
|
+
return {
|
|
1186
|
+
error
|
|
1187
|
+
};
|
|
1188
|
+
};
|
|
1189
|
+
return wrapped;
|
|
1090
1190
|
}
|
|
1091
1191
|
};
|
|
1092
1192
|
};
|
|
@@ -1094,29 +1194,6 @@ const terminate = () => {
|
|
|
1094
1194
|
globalThis.close();
|
|
1095
1195
|
};
|
|
1096
1196
|
|
|
1097
|
-
const EditorWorker$1 = 99;
|
|
1098
|
-
const ExtensionHostWorker = 44;
|
|
1099
|
-
|
|
1100
|
-
const createMockRpc = ({
|
|
1101
|
-
commandMap
|
|
1102
|
-
}) => {
|
|
1103
|
-
const invocations = [];
|
|
1104
|
-
const invoke = (method, ...params) => {
|
|
1105
|
-
invocations.push([method, ...params]);
|
|
1106
|
-
const command = commandMap[method];
|
|
1107
|
-
if (!command) {
|
|
1108
|
-
throw new Error(`command ${method} not found`);
|
|
1109
|
-
}
|
|
1110
|
-
return command(...params);
|
|
1111
|
-
};
|
|
1112
|
-
const mockRpc = {
|
|
1113
|
-
invocations,
|
|
1114
|
-
invoke,
|
|
1115
|
-
invokeAndTransfer: invoke
|
|
1116
|
-
};
|
|
1117
|
-
return mockRpc;
|
|
1118
|
-
};
|
|
1119
|
-
|
|
1120
1197
|
const rpcs = Object.create(null);
|
|
1121
1198
|
const set$5 = (id, rpc) => {
|
|
1122
1199
|
rpcs[id] = rpc;
|
|
@@ -1165,147 +1242,46 @@ const create$1 = rpcId => {
|
|
|
1165
1242
|
};
|
|
1166
1243
|
};
|
|
1167
1244
|
|
|
1245
|
+
const Text = 12;
|
|
1246
|
+
|
|
1247
|
+
const EditorWorker$1 = 99;
|
|
1248
|
+
const ExtensionHostWorker = 44;
|
|
1249
|
+
|
|
1250
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1251
|
+
|
|
1168
1252
|
const {
|
|
1169
|
-
dispose: dispose$3,
|
|
1170
1253
|
invoke: invoke$3,
|
|
1171
|
-
invokeAndTransfer
|
|
1172
|
-
registerMockRpc: registerMockRpc$1,
|
|
1254
|
+
invokeAndTransfer,
|
|
1173
1255
|
set: set$4
|
|
1174
1256
|
} = create$1(EditorWorker$1);
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
await invokeAndTransfer$1(
|
|
1178
|
-
// @ts-ignore
|
|
1179
|
-
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, 0);
|
|
1180
|
-
};
|
|
1181
|
-
// TODO add tests for this
|
|
1182
|
-
const activateByEvent$1 = async event => {
|
|
1183
|
-
// @ts-ignore
|
|
1184
|
-
await invoke$3('ActivateByEvent.activateByEvent', event);
|
|
1185
|
-
};
|
|
1186
|
-
const applyEdit = async (editorUid, changes) => {
|
|
1187
|
-
// @ts-ignore
|
|
1188
|
-
await invoke$3('Editor.applyEdit2', editorUid, changes);
|
|
1189
|
-
};
|
|
1190
|
-
const applyDocumentEdits = async (editorUid, changes) => {
|
|
1191
|
-
// @ts-ignore
|
|
1192
|
-
await invoke$3('Editor.applyDocumentEdits', editorUid, changes);
|
|
1193
|
-
};
|
|
1194
|
-
const applyWorkspaceEdit = async (editorUid, changes) => {
|
|
1195
|
-
// @ts-ignore
|
|
1196
|
-
await invoke$3('Editor.applyWorkspaceEdit', editorUid, changes);
|
|
1197
|
-
};
|
|
1198
|
-
const closeWidget = async (editorUid, widgetId, widgetName, focusId) => {
|
|
1199
|
-
// @ts-ignore
|
|
1200
|
-
await invoke$3('Editor.closeWidget2', editorUid, widgetId, widgetName, focusId);
|
|
1201
|
-
};
|
|
1202
|
-
const getWordAt = async (uid, rowIndex, columnIndex) => {
|
|
1203
|
-
// @ts-ignore
|
|
1204
|
-
const word = await invoke$3('Editor.getWordAt2', uid, rowIndex, columnIndex);
|
|
1205
|
-
return word;
|
|
1206
|
-
};
|
|
1207
|
-
const getLines = async editorUid => {
|
|
1208
|
-
const lines = await invoke$3('Editor.getLines2', editorUid);
|
|
1209
|
-
return lines;
|
|
1210
|
-
};
|
|
1211
|
-
const getPositionAtCursor$1 = async parentUid => {
|
|
1212
|
-
const position = await invoke$3('Editor.getPositionAtCursor', parentUid);
|
|
1213
|
-
return position;
|
|
1214
|
-
};
|
|
1215
|
-
const getOffsetAtCursor$1 = async editorId => {
|
|
1216
|
-
// @ts-ignore
|
|
1217
|
-
return await invoke$3('Editor.getOffsetAtCursor', editorId);
|
|
1218
|
-
};
|
|
1219
|
-
const getSelections = async editorUid => {
|
|
1220
|
-
const selections = await invoke$3('Editor.getSelections2', editorUid);
|
|
1221
|
-
return selections;
|
|
1257
|
+
const sendMessagePortToExtensionManagementWorker$1 = async port => {
|
|
1258
|
+
await invokeAndTransfer('SendMessagePortToExtensionManagementWorker.sendMessagePortToExtensionManagementWorker', port, 0);
|
|
1222
1259
|
};
|
|
1223
1260
|
const getWordAtOffset2$1 = async editorUid => {
|
|
1224
1261
|
return invoke$3('Editor.getWordAtOffset2', editorUid);
|
|
1225
1262
|
};
|
|
1226
|
-
const closeFind2 = async editorUid => {
|
|
1227
|
-
return invoke$3('Editor.closeFind2', editorUid);
|
|
1228
|
-
};
|
|
1229
1263
|
const getWordBefore$1 = async (editorUid, rowIndex, columnIndex) => {
|
|
1230
1264
|
return invoke$3('Editor.getWordBefore2', editorUid, rowIndex, columnIndex);
|
|
1231
1265
|
};
|
|
1232
|
-
const updateDebugInfo = async info => {
|
|
1233
|
-
await invoke$3('Editor.updateDebugInfo', info);
|
|
1234
|
-
};
|
|
1235
|
-
const getUri = async editorUid => {
|
|
1236
|
-
// @ts-ignore
|
|
1237
|
-
return invoke$3('Editor.getUri', editorUid);
|
|
1238
|
-
};
|
|
1239
|
-
const getLanguageId = async editorUid => {
|
|
1240
|
-
// @ts-ignore
|
|
1241
|
-
return invoke$3('Editor.getLanguageId', editorUid);
|
|
1242
|
-
};
|
|
1243
|
-
const getProblems = async () => {
|
|
1244
|
-
// @ts-ignore
|
|
1245
|
-
return invoke$3('Editor.getProblems');
|
|
1246
|
-
};
|
|
1247
1266
|
|
|
1248
1267
|
const EditorWorker = {
|
|
1249
1268
|
__proto__: null,
|
|
1250
|
-
activateByEvent: activateByEvent$1,
|
|
1251
|
-
applyDocumentEdits,
|
|
1252
|
-
applyEdit,
|
|
1253
|
-
applyWorkspaceEdit,
|
|
1254
|
-
closeFind2,
|
|
1255
|
-
closeWidget,
|
|
1256
|
-
dispose: dispose$3,
|
|
1257
|
-
getLanguageId,
|
|
1258
|
-
getLines,
|
|
1259
|
-
getOffsetAtCursor: getOffsetAtCursor$1,
|
|
1260
|
-
getPositionAtCursor: getPositionAtCursor$1,
|
|
1261
|
-
getProblems,
|
|
1262
|
-
getSelections,
|
|
1263
|
-
getUri,
|
|
1264
|
-
getWordAt,
|
|
1265
1269
|
getWordAtOffset2: getWordAtOffset2$1,
|
|
1266
1270
|
getWordBefore: getWordBefore$1,
|
|
1267
1271
|
invoke: invoke$3,
|
|
1268
|
-
invokeAndTransfer
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
set: set$4,
|
|
1272
|
-
updateDebugInfo
|
|
1272
|
+
invokeAndTransfer,
|
|
1273
|
+
sendMessagePortToExtensionManagementWorker: sendMessagePortToExtensionManagementWorker$1,
|
|
1274
|
+
set: set$4
|
|
1273
1275
|
};
|
|
1274
1276
|
|
|
1275
1277
|
const {
|
|
1276
|
-
dispose: dispose$2,
|
|
1277
1278
|
invoke: invoke$2,
|
|
1278
|
-
invokeAndTransfer,
|
|
1279
|
-
registerMockRpc,
|
|
1280
1279
|
set: set$3
|
|
1281
1280
|
} = create$1(ExtensionHostWorker);
|
|
1282
|
-
const executeReferenceProvider = async (id, offset) => {
|
|
1283
|
-
// @ts-ignore
|
|
1284
|
-
return invoke$2('ExtensionHostReference.executeReferenceProvider', id, offset);
|
|
1285
|
-
};
|
|
1286
|
-
const executeFileReferenceProvider = async id => {
|
|
1287
|
-
// @ts-ignore
|
|
1288
|
-
return invoke$2('ExtensionHostReference.executeFileReferenceProvider', id);
|
|
1289
|
-
};
|
|
1290
|
-
const getRuntimeStatus = async extensionId => {
|
|
1291
|
-
// @ts-ignore
|
|
1292
|
-
return invoke$2('ExtensionHost.getRuntimeStatus', extensionId);
|
|
1293
|
-
};
|
|
1294
|
-
const getEnabledOutputProviderIds = async () => {
|
|
1295
|
-
const channels = await invoke$2('Output.getEnabledProviders');
|
|
1296
|
-
return channels;
|
|
1297
|
-
};
|
|
1298
1281
|
|
|
1299
1282
|
const ExtensionHost = {
|
|
1300
1283
|
__proto__: null,
|
|
1301
|
-
dispose: dispose$2,
|
|
1302
|
-
executeFileReferenceProvider,
|
|
1303
|
-
executeReferenceProvider,
|
|
1304
|
-
getEnabledOutputProviderIds,
|
|
1305
|
-
getRuntimeStatus,
|
|
1306
1284
|
invoke: invoke$2,
|
|
1307
|
-
invokeAndTransfer,
|
|
1308
|
-
registerMockRpc,
|
|
1309
1285
|
set: set$3
|
|
1310
1286
|
};
|
|
1311
1287
|
|
|
@@ -1313,7 +1289,7 @@ const {
|
|
|
1313
1289
|
getWordAtOffset2,
|
|
1314
1290
|
getWordBefore,
|
|
1315
1291
|
invoke: invoke$1,
|
|
1316
|
-
|
|
1292
|
+
sendMessagePortToExtensionManagementWorker,
|
|
1317
1293
|
set: set$2
|
|
1318
1294
|
} = EditorWorker;
|
|
1319
1295
|
|
|
@@ -1489,13 +1465,12 @@ const handleSashPointerUp = (state, eventX, eventY) => {
|
|
|
1489
1465
|
};
|
|
1490
1466
|
|
|
1491
1467
|
const sendMessagePortToExtensionHostWorker = async port => {
|
|
1492
|
-
|
|
1493
|
-
await sendMessagePortToExtensionHostWorker$1(port);
|
|
1468
|
+
await sendMessagePortToExtensionManagementWorker(port);
|
|
1494
1469
|
};
|
|
1495
1470
|
|
|
1496
1471
|
const createExtensionHostRpc = async () => {
|
|
1497
1472
|
try {
|
|
1498
|
-
const rpc = await
|
|
1473
|
+
const rpc = await create$4({
|
|
1499
1474
|
commandMap: {},
|
|
1500
1475
|
send: sendMessagePortToExtensionHostWorker
|
|
1501
1476
|
});
|
|
@@ -1778,10 +1753,6 @@ const renderEventListeners = state => {
|
|
|
1778
1753
|
return [SetEventListeners, uid, eventListeners];
|
|
1779
1754
|
};
|
|
1780
1755
|
|
|
1781
|
-
const Text = 12;
|
|
1782
|
-
|
|
1783
|
-
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1784
|
-
|
|
1785
1756
|
const renderFocusContext = (oldState, newState) => {
|
|
1786
1757
|
return [SetFocusContext, FocusEditorRename];
|
|
1787
1758
|
};
|
|
@@ -1965,7 +1936,7 @@ const commandMap = {
|
|
|
1965
1936
|
};
|
|
1966
1937
|
|
|
1967
1938
|
const listen = async () => {
|
|
1968
|
-
const rpc = await
|
|
1939
|
+
const rpc = await create$3({
|
|
1969
1940
|
commandMap: commandMap
|
|
1970
1941
|
});
|
|
1971
1942
|
set$2(rpc);
|