@lvce-editor/extension-search-view 7.3.0 → 7.4.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/extensionSearchViewWorkerMain.js +423 -331
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -456,7 +456,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
456
456
|
return promise;
|
|
457
457
|
};
|
|
458
458
|
const Message$1 = 3;
|
|
459
|
-
const create$5 = async ({
|
|
459
|
+
const create$5$1 = async ({
|
|
460
460
|
isMessagePortOpen,
|
|
461
461
|
messagePort
|
|
462
462
|
}) => {
|
|
@@ -507,11 +507,32 @@ const wrap$5 = messagePort => {
|
|
|
507
507
|
};
|
|
508
508
|
const IpcParentWithMessagePort$1 = {
|
|
509
509
|
__proto__: null,
|
|
510
|
-
create: create$5,
|
|
510
|
+
create: create$5$1,
|
|
511
511
|
signal: signal$1,
|
|
512
512
|
wrap: wrap$5
|
|
513
513
|
};
|
|
514
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 = key => {
|
|
526
|
+
return commands[key];
|
|
527
|
+
};
|
|
528
|
+
const execute = (command, ...args) => {
|
|
529
|
+
const fn = getCommand(command);
|
|
530
|
+
if (!fn) {
|
|
531
|
+
throw new CommandNotFoundError(command);
|
|
532
|
+
}
|
|
533
|
+
return fn(...args);
|
|
534
|
+
};
|
|
535
|
+
|
|
515
536
|
const Two$1 = '2.0';
|
|
516
537
|
const callbacks = Object.create(null);
|
|
517
538
|
const get$2 = id => {
|
|
@@ -536,12 +557,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
536
557
|
switch (type) {
|
|
537
558
|
case DomException:
|
|
538
559
|
return DOMException;
|
|
539
|
-
case TypeError$1:
|
|
540
|
-
return TypeError;
|
|
541
|
-
case SyntaxError$1:
|
|
542
|
-
return SyntaxError;
|
|
543
560
|
case ReferenceError$1:
|
|
544
561
|
return ReferenceError;
|
|
562
|
+
case SyntaxError$1:
|
|
563
|
+
return SyntaxError;
|
|
564
|
+
case TypeError$1:
|
|
565
|
+
return TypeError;
|
|
545
566
|
default:
|
|
546
567
|
return Error;
|
|
547
568
|
}
|
|
@@ -697,56 +718,56 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
697
718
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
698
719
|
return {
|
|
699
720
|
code: MethodNotFound,
|
|
700
|
-
|
|
701
|
-
|
|
721
|
+
data: error.stack,
|
|
722
|
+
message: error.message
|
|
702
723
|
};
|
|
703
724
|
}
|
|
704
725
|
return {
|
|
705
726
|
code: Custom,
|
|
706
|
-
message: prettyError.message,
|
|
707
727
|
data: {
|
|
708
|
-
stack: getStack(prettyError),
|
|
709
|
-
codeFrame: prettyError.codeFrame,
|
|
710
|
-
type: getErrorType(prettyError),
|
|
711
728
|
code: prettyError.code,
|
|
712
|
-
|
|
713
|
-
|
|
729
|
+
codeFrame: prettyError.codeFrame,
|
|
730
|
+
name: prettyError.name,
|
|
731
|
+
stack: getStack(prettyError),
|
|
732
|
+
type: getErrorType(prettyError)
|
|
733
|
+
},
|
|
734
|
+
message: prettyError.message
|
|
714
735
|
};
|
|
715
736
|
};
|
|
716
|
-
const create$1$
|
|
737
|
+
const create$1$1 = (id, error) => {
|
|
717
738
|
return {
|
|
718
|
-
|
|
739
|
+
error,
|
|
719
740
|
id,
|
|
720
|
-
|
|
741
|
+
jsonrpc: Two$1
|
|
721
742
|
};
|
|
722
743
|
};
|
|
723
744
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
724
745
|
const prettyError = preparePrettyError(error);
|
|
725
746
|
logError(error, prettyError);
|
|
726
747
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
727
|
-
return create$1$
|
|
748
|
+
return create$1$1(id, errorProperty);
|
|
728
749
|
};
|
|
729
|
-
const create$
|
|
750
|
+
const create$9 = (message, result) => {
|
|
730
751
|
return {
|
|
731
|
-
jsonrpc: Two$1,
|
|
732
752
|
id: message.id,
|
|
753
|
+
jsonrpc: Two$1,
|
|
733
754
|
result: result ?? null
|
|
734
755
|
};
|
|
735
756
|
};
|
|
736
757
|
const getSuccessResponse = (message, result) => {
|
|
737
758
|
const resultProperty = result ?? null;
|
|
738
|
-
return create$
|
|
759
|
+
return create$9(message, resultProperty);
|
|
739
760
|
};
|
|
740
761
|
const getErrorResponseSimple = (id, error) => {
|
|
741
762
|
return {
|
|
742
|
-
jsonrpc: Two$1,
|
|
743
|
-
id,
|
|
744
763
|
error: {
|
|
745
764
|
code: Custom,
|
|
765
|
+
data: error,
|
|
746
766
|
// @ts-ignore
|
|
747
|
-
message: error.message
|
|
748
|
-
|
|
749
|
-
|
|
767
|
+
message: error.message
|
|
768
|
+
},
|
|
769
|
+
id,
|
|
770
|
+
jsonrpc: Two$1
|
|
750
771
|
};
|
|
751
772
|
};
|
|
752
773
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -776,35 +797,35 @@ const normalizeParams = args => {
|
|
|
776
797
|
if (args.length === 1) {
|
|
777
798
|
const options = args[0];
|
|
778
799
|
return {
|
|
800
|
+
execute: options.execute,
|
|
779
801
|
ipc: options.ipc,
|
|
802
|
+
logError: options.logError || defaultLogError,
|
|
780
803
|
message: options.message,
|
|
781
|
-
execute: options.execute,
|
|
782
|
-
resolve: options.resolve || defaultResolve,
|
|
783
804
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
784
|
-
|
|
785
|
-
|
|
805
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
806
|
+
resolve: options.resolve || defaultResolve
|
|
786
807
|
};
|
|
787
808
|
}
|
|
788
809
|
return {
|
|
810
|
+
execute: args[2],
|
|
789
811
|
ipc: args[0],
|
|
812
|
+
logError: args[5],
|
|
790
813
|
message: args[1],
|
|
791
|
-
execute: args[2],
|
|
792
|
-
resolve: args[3],
|
|
793
814
|
preparePrettyError: args[4],
|
|
794
|
-
|
|
795
|
-
|
|
815
|
+
requiresSocket: args[6],
|
|
816
|
+
resolve: args[3]
|
|
796
817
|
};
|
|
797
818
|
};
|
|
798
819
|
const handleJsonRpcMessage = async (...args) => {
|
|
799
820
|
const options = normalizeParams(args);
|
|
800
821
|
const {
|
|
801
|
-
message,
|
|
802
|
-
ipc,
|
|
803
822
|
execute,
|
|
804
|
-
|
|
805
|
-
preparePrettyError,
|
|
823
|
+
ipc,
|
|
806
824
|
logError,
|
|
807
|
-
|
|
825
|
+
message,
|
|
826
|
+
preparePrettyError,
|
|
827
|
+
requiresSocket,
|
|
828
|
+
resolve
|
|
808
829
|
} = options;
|
|
809
830
|
if ('id' in message) {
|
|
810
831
|
if ('method' in message) {
|
|
@@ -827,36 +848,17 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
827
848
|
throw new JsonRpcError('unexpected message');
|
|
828
849
|
};
|
|
829
850
|
|
|
830
|
-
class CommandNotFoundError extends Error {
|
|
831
|
-
constructor(command) {
|
|
832
|
-
super(`Command not found ${command}`);
|
|
833
|
-
this.name = 'CommandNotFoundError';
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
const commands = Object.create(null);
|
|
837
|
-
const register = commandMap => {
|
|
838
|
-
Object.assign(commands, commandMap);
|
|
839
|
-
};
|
|
840
|
-
const getCommand = key => {
|
|
841
|
-
return commands[key];
|
|
842
|
-
};
|
|
843
|
-
const execute = (command, ...args) => {
|
|
844
|
-
const fn = getCommand(command);
|
|
845
|
-
if (!fn) {
|
|
846
|
-
throw new CommandNotFoundError(command);
|
|
847
|
-
}
|
|
848
|
-
return fn(...args);
|
|
849
|
-
};
|
|
850
|
-
|
|
851
851
|
const Two = '2.0';
|
|
852
|
-
|
|
852
|
+
|
|
853
|
+
const create$8 = (method, params) => {
|
|
853
854
|
return {
|
|
854
855
|
jsonrpc: Two,
|
|
855
856
|
method,
|
|
856
857
|
params
|
|
857
858
|
};
|
|
858
859
|
};
|
|
859
|
-
|
|
860
|
+
|
|
861
|
+
const create$7 = (id, method, params) => {
|
|
860
862
|
const message = {
|
|
861
863
|
id,
|
|
862
864
|
jsonrpc: Two,
|
|
@@ -865,15 +867,14 @@ const create$r = (id, method, params) => {
|
|
|
865
867
|
};
|
|
866
868
|
return message;
|
|
867
869
|
};
|
|
870
|
+
|
|
868
871
|
let id$1 = 0;
|
|
869
|
-
const create$
|
|
872
|
+
const create$6 = () => {
|
|
870
873
|
return ++id$1;
|
|
871
874
|
};
|
|
872
875
|
|
|
873
|
-
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
874
|
-
|
|
875
876
|
const registerPromise = map => {
|
|
876
|
-
const id = create$
|
|
877
|
+
const id = create$6();
|
|
877
878
|
const {
|
|
878
879
|
promise,
|
|
879
880
|
resolve
|
|
@@ -885,13 +886,12 @@ const registerPromise = map => {
|
|
|
885
886
|
};
|
|
886
887
|
};
|
|
887
888
|
|
|
888
|
-
// @ts-ignore
|
|
889
889
|
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
890
890
|
const {
|
|
891
891
|
id,
|
|
892
892
|
promise
|
|
893
893
|
} = registerPromise(callbacks);
|
|
894
|
-
const message = create$
|
|
894
|
+
const message = create$7(id, method, params);
|
|
895
895
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
896
896
|
ipc.sendAndTransfer(message);
|
|
897
897
|
} else {
|
|
@@ -927,12 +927,13 @@ const createRpc = ipc => {
|
|
|
927
927
|
* @deprecated
|
|
928
928
|
*/
|
|
929
929
|
send(method, ...params) {
|
|
930
|
-
const message = create$
|
|
930
|
+
const message = create$8(method, params);
|
|
931
931
|
ipc.send(message);
|
|
932
932
|
}
|
|
933
933
|
};
|
|
934
934
|
return rpc;
|
|
935
935
|
};
|
|
936
|
+
|
|
936
937
|
const requiresSocket = () => {
|
|
937
938
|
return false;
|
|
938
939
|
};
|
|
@@ -947,6 +948,7 @@ const handleMessage = event => {
|
|
|
947
948
|
const actualExecute = event?.target?.execute || execute;
|
|
948
949
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
949
950
|
};
|
|
951
|
+
|
|
950
952
|
const handleIpc = ipc => {
|
|
951
953
|
if ('addEventListener' in ipc) {
|
|
952
954
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -955,6 +957,7 @@ const handleIpc = ipc => {
|
|
|
955
957
|
ipc.on('message', handleMessage);
|
|
956
958
|
}
|
|
957
959
|
};
|
|
960
|
+
|
|
958
961
|
const listen$1 = async (module, options) => {
|
|
959
962
|
const rawIpc = await module.listen(options);
|
|
960
963
|
if (module.signal) {
|
|
@@ -963,7 +966,8 @@ const listen$1 = async (module, options) => {
|
|
|
963
966
|
const ipc = module.wrap(rawIpc);
|
|
964
967
|
return ipc;
|
|
965
968
|
};
|
|
966
|
-
|
|
969
|
+
|
|
970
|
+
const create$5 = async ({
|
|
967
971
|
commandMap,
|
|
968
972
|
isMessagePortOpen = true,
|
|
969
973
|
messagePort
|
|
@@ -980,7 +984,8 @@ const create$4 = async ({
|
|
|
980
984
|
messagePort.start();
|
|
981
985
|
return rpc;
|
|
982
986
|
};
|
|
983
|
-
|
|
987
|
+
|
|
988
|
+
const create$4 = async ({
|
|
984
989
|
commandMap,
|
|
985
990
|
isMessagePortOpen,
|
|
986
991
|
send
|
|
@@ -990,17 +995,14 @@ const create$2$1 = async ({
|
|
|
990
995
|
port2
|
|
991
996
|
} = new MessageChannel();
|
|
992
997
|
await send(port1);
|
|
993
|
-
return create$
|
|
998
|
+
return create$5({
|
|
994
999
|
commandMap,
|
|
995
1000
|
isMessagePortOpen,
|
|
996
1001
|
messagePort: port2
|
|
997
1002
|
});
|
|
998
1003
|
};
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
create: create$2$1
|
|
1002
|
-
};
|
|
1003
|
-
const create$1$1 = async ({
|
|
1004
|
+
|
|
1005
|
+
const create$3 = async ({
|
|
1004
1006
|
commandMap
|
|
1005
1007
|
}) => {
|
|
1006
1008
|
// TODO create a commandMap per rpc instance
|
|
@@ -1010,10 +1012,7 @@ const create$1$1 = async ({
|
|
|
1010
1012
|
const rpc = createRpc(ipc);
|
|
1011
1013
|
return rpc;
|
|
1012
1014
|
};
|
|
1013
|
-
|
|
1014
|
-
__proto__: null,
|
|
1015
|
-
create: create$1$1
|
|
1016
|
-
};
|
|
1015
|
+
|
|
1017
1016
|
const createMockRpc = ({
|
|
1018
1017
|
commandMap
|
|
1019
1018
|
}) => {
|
|
@@ -1034,37 +1033,6 @@ const createMockRpc = ({
|
|
|
1034
1033
|
return mockRpc;
|
|
1035
1034
|
};
|
|
1036
1035
|
|
|
1037
|
-
const None$3 = 'none';
|
|
1038
|
-
|
|
1039
|
-
const Button$2 = 1;
|
|
1040
|
-
const Div = 4;
|
|
1041
|
-
const Input$1 = 6;
|
|
1042
|
-
const Text = 12;
|
|
1043
|
-
const Img = 17;
|
|
1044
|
-
|
|
1045
|
-
const Button$1 = 'event.button';
|
|
1046
|
-
const ClientX = 'event.clientX';
|
|
1047
|
-
const ClientY = 'event.clientY';
|
|
1048
|
-
const DeltaMode = 'event.deltaMode';
|
|
1049
|
-
const DeltaY = 'event.deltaY';
|
|
1050
|
-
const TargetValue = 'event.target.value';
|
|
1051
|
-
|
|
1052
|
-
const Script$1 = 2;
|
|
1053
|
-
|
|
1054
|
-
const ManageExtension = 8;
|
|
1055
|
-
const ExtensionSearchFilter = 95;
|
|
1056
|
-
|
|
1057
|
-
const LeftClick = 0;
|
|
1058
|
-
|
|
1059
|
-
const ExtensionHostWorker = 44;
|
|
1060
|
-
const ExtensionManagementWorker = 9006;
|
|
1061
|
-
const RendererWorker = 1;
|
|
1062
|
-
|
|
1063
|
-
const FocusSelector = 'Viewlet.focusSelector';
|
|
1064
|
-
const SetCss = 'Viewlet.setCss';
|
|
1065
|
-
const SetDom2 = 'Viewlet.setDom2';
|
|
1066
|
-
const SetPatches = 'Viewlet.setPatches';
|
|
1067
|
-
|
|
1068
1036
|
const rpcs = Object.create(null);
|
|
1069
1037
|
const set$5 = (id, rpc) => {
|
|
1070
1038
|
rpcs[id] = rpc;
|
|
@@ -1113,40 +1081,46 @@ const create$2 = rpcId => {
|
|
|
1113
1081
|
};
|
|
1114
1082
|
};
|
|
1115
1083
|
|
|
1084
|
+
const None$3 = 'none';
|
|
1085
|
+
|
|
1086
|
+
const Button$2 = 1;
|
|
1087
|
+
const Div = 4;
|
|
1088
|
+
const Input$1 = 6;
|
|
1089
|
+
const Text = 12;
|
|
1090
|
+
const Img = 17;
|
|
1091
|
+
const Reference = 100;
|
|
1092
|
+
|
|
1093
|
+
const Button$1 = 'event.button';
|
|
1094
|
+
const ClientX = 'event.clientX';
|
|
1095
|
+
const ClientY = 'event.clientY';
|
|
1096
|
+
const DeltaMode = 'event.deltaMode';
|
|
1097
|
+
const DeltaY = 'event.deltaY';
|
|
1098
|
+
const TargetValue = 'event.target.value';
|
|
1099
|
+
|
|
1100
|
+
const Script$1 = 2;
|
|
1101
|
+
|
|
1102
|
+
const ManageExtension = 8;
|
|
1103
|
+
const ExtensionSearchFilter = 95;
|
|
1104
|
+
|
|
1105
|
+
const LeftClick = 0;
|
|
1106
|
+
|
|
1107
|
+
const ExtensionHostWorker = 44;
|
|
1108
|
+
const ExtensionManagementWorker = 9006;
|
|
1109
|
+
const RendererWorker = 1;
|
|
1110
|
+
|
|
1111
|
+
const FocusSelector = 'Viewlet.focusSelector';
|
|
1112
|
+
const SetCss = 'Viewlet.setCss';
|
|
1113
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
1114
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
1115
|
+
|
|
1116
1116
|
const {
|
|
1117
|
-
dispose: dispose$2,
|
|
1118
1117
|
invoke: invoke$2,
|
|
1119
|
-
invokeAndTransfer: invokeAndTransfer$1,
|
|
1120
|
-
registerMockRpc,
|
|
1121
1118
|
set: set$4
|
|
1122
1119
|
} = create$2(ExtensionHostWorker);
|
|
1123
|
-
const executeReferenceProvider = async (id, offset) => {
|
|
1124
|
-
// @ts-ignore
|
|
1125
|
-
return invoke$2('ExtensionHostReference.executeReferenceProvider', id, offset);
|
|
1126
|
-
};
|
|
1127
|
-
const executeFileReferenceProvider = async id => {
|
|
1128
|
-
// @ts-ignore
|
|
1129
|
-
return invoke$2('ExtensionHostReference.executeFileReferenceProvider', id);
|
|
1130
|
-
};
|
|
1131
|
-
const getRuntimeStatus = async extensionId => {
|
|
1132
|
-
// @ts-ignore
|
|
1133
|
-
return invoke$2('ExtensionHost.getRuntimeStatus', extensionId);
|
|
1134
|
-
};
|
|
1135
|
-
const getEnabledOutputProviderIds = async () => {
|
|
1136
|
-
const channels = await invoke$2('Output.getEnabledProviders');
|
|
1137
|
-
return channels;
|
|
1138
|
-
};
|
|
1139
1120
|
|
|
1140
1121
|
const ExtensionHost = {
|
|
1141
1122
|
__proto__: null,
|
|
1142
|
-
dispose: dispose$2,
|
|
1143
|
-
executeFileReferenceProvider,
|
|
1144
|
-
executeReferenceProvider,
|
|
1145
|
-
getEnabledOutputProviderIds,
|
|
1146
|
-
getRuntimeStatus,
|
|
1147
1123
|
invoke: invoke$2,
|
|
1148
|
-
invokeAndTransfer: invokeAndTransfer$1,
|
|
1149
|
-
registerMockRpc,
|
|
1150
1124
|
set: set$4
|
|
1151
1125
|
};
|
|
1152
1126
|
|
|
@@ -1164,13 +1138,16 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1164
1138
|
number(menuId);
|
|
1165
1139
|
number(x);
|
|
1166
1140
|
number(y);
|
|
1167
|
-
// @ts-ignore
|
|
1168
1141
|
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1169
1142
|
};
|
|
1170
1143
|
const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
1171
1144
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1172
1145
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1173
1146
|
};
|
|
1147
|
+
const confirm = async (message, options) => {
|
|
1148
|
+
const result = await invoke$1('ConfirmPrompt.prompt', message, options);
|
|
1149
|
+
return result;
|
|
1150
|
+
};
|
|
1174
1151
|
const writeClipBoardText = async text => {
|
|
1175
1152
|
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
1176
1153
|
};
|
|
@@ -1190,42 +1167,68 @@ const create$1 = () => {
|
|
|
1190
1167
|
const states = Object.create(null);
|
|
1191
1168
|
const commandMapRef = {};
|
|
1192
1169
|
return {
|
|
1193
|
-
|
|
1194
|
-
|
|
1170
|
+
clear() {
|
|
1171
|
+
for (const key of Object.keys(states)) {
|
|
1172
|
+
delete states[key];
|
|
1173
|
+
}
|
|
1195
1174
|
},
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
};
|
|
1175
|
+
diff(uid, modules, numbers) {
|
|
1176
|
+
const {
|
|
1177
|
+
newState,
|
|
1178
|
+
oldState
|
|
1179
|
+
} = states[uid];
|
|
1180
|
+
const diffResult = [];
|
|
1181
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1182
|
+
const fn = modules[i];
|
|
1183
|
+
if (!fn(oldState, newState)) {
|
|
1184
|
+
diffResult.push(numbers[i]);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
return diffResult;
|
|
1201
1188
|
},
|
|
1202
1189
|
dispose(uid) {
|
|
1203
1190
|
delete states[uid];
|
|
1204
1191
|
},
|
|
1192
|
+
get(uid) {
|
|
1193
|
+
return states[uid];
|
|
1194
|
+
},
|
|
1195
|
+
getCommandIds() {
|
|
1196
|
+
const keys = Object.keys(commandMapRef);
|
|
1197
|
+
const ids = keys.map(toCommandId);
|
|
1198
|
+
return ids;
|
|
1199
|
+
},
|
|
1205
1200
|
getKeys() {
|
|
1206
1201
|
return Object.keys(states).map(key => {
|
|
1207
|
-
return Number.
|
|
1202
|
+
return Number.parseFloat(key);
|
|
1208
1203
|
});
|
|
1209
1204
|
},
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1205
|
+
registerCommands(commandMap) {
|
|
1206
|
+
Object.assign(commandMapRef, commandMap);
|
|
1207
|
+
},
|
|
1208
|
+
set(uid, oldState, newState) {
|
|
1209
|
+
states[uid] = {
|
|
1210
|
+
newState,
|
|
1211
|
+
oldState
|
|
1212
|
+
};
|
|
1214
1213
|
},
|
|
1215
1214
|
wrapCommand(fn) {
|
|
1216
1215
|
const wrapped = async (uid, ...args) => {
|
|
1217
1216
|
const {
|
|
1218
|
-
|
|
1219
|
-
|
|
1217
|
+
newState,
|
|
1218
|
+
oldState
|
|
1220
1219
|
} = states[uid];
|
|
1221
1220
|
const newerState = await fn(newState, ...args);
|
|
1222
1221
|
if (oldState === newerState || newState === newerState) {
|
|
1223
1222
|
return;
|
|
1224
1223
|
}
|
|
1225
|
-
const
|
|
1224
|
+
const latestOld = states[uid];
|
|
1225
|
+
const latestNew = {
|
|
1226
|
+
...latestOld.newState,
|
|
1227
|
+
...newerState
|
|
1228
|
+
};
|
|
1226
1229
|
states[uid] = {
|
|
1227
|
-
|
|
1228
|
-
|
|
1230
|
+
newState: latestNew,
|
|
1231
|
+
oldState: latestOld.oldState
|
|
1229
1232
|
};
|
|
1230
1233
|
};
|
|
1231
1234
|
return wrapped;
|
|
@@ -1239,27 +1242,36 @@ const create$1 = () => {
|
|
|
1239
1242
|
};
|
|
1240
1243
|
return wrapped;
|
|
1241
1244
|
},
|
|
1242
|
-
|
|
1243
|
-
const {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
|
|
1245
|
+
wrapLoadContent(fn) {
|
|
1246
|
+
const wrapped = async (uid, ...args) => {
|
|
1247
|
+
const {
|
|
1248
|
+
newState,
|
|
1249
|
+
oldState
|
|
1250
|
+
} = states[uid];
|
|
1251
|
+
const result = await fn(newState, ...args);
|
|
1252
|
+
const {
|
|
1253
|
+
error,
|
|
1254
|
+
state
|
|
1255
|
+
} = result;
|
|
1256
|
+
if (oldState === state || newState === state) {
|
|
1257
|
+
return {
|
|
1258
|
+
error
|
|
1259
|
+
};
|
|
1252
1260
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1261
|
+
const latestOld = states[uid];
|
|
1262
|
+
const latestNew = {
|
|
1263
|
+
...latestOld.newState,
|
|
1264
|
+
...state
|
|
1265
|
+
};
|
|
1266
|
+
states[uid] = {
|
|
1267
|
+
newState: latestNew,
|
|
1268
|
+
oldState: latestOld.oldState
|
|
1269
|
+
};
|
|
1270
|
+
return {
|
|
1271
|
+
error
|
|
1272
|
+
};
|
|
1273
|
+
};
|
|
1274
|
+
return wrapped;
|
|
1263
1275
|
}
|
|
1264
1276
|
};
|
|
1265
1277
|
};
|
|
@@ -1355,19 +1367,19 @@ const extensions = () => {
|
|
|
1355
1367
|
const clearExtensionSearchResults = () => {
|
|
1356
1368
|
return i18nString(ClearExtensionSearchResults);
|
|
1357
1369
|
};
|
|
1358
|
-
const enable = () => {
|
|
1370
|
+
const enable$1 = () => {
|
|
1359
1371
|
return i18nString(Enable);
|
|
1360
1372
|
};
|
|
1361
|
-
const disable = () => {
|
|
1373
|
+
const disable$1 = () => {
|
|
1362
1374
|
return i18nString(Disable);
|
|
1363
1375
|
};
|
|
1364
|
-
const enableWorkspace = () => {
|
|
1376
|
+
const enableWorkspace$1 = () => {
|
|
1365
1377
|
return i18nString(EnableWorkspace);
|
|
1366
1378
|
};
|
|
1367
|
-
const disableWorkspace = () => {
|
|
1379
|
+
const disableWorkspace$1 = () => {
|
|
1368
1380
|
return i18nString(DisableWorkspace);
|
|
1369
1381
|
};
|
|
1370
|
-
const installAnotherVersion = () => {
|
|
1382
|
+
const installAnotherVersion$1 = () => {
|
|
1371
1383
|
return i18nString(InstallAnotherVersion);
|
|
1372
1384
|
};
|
|
1373
1385
|
const copy = () => {
|
|
@@ -1619,12 +1631,31 @@ const matchesParsedValue = (extension, parsedValue) => {
|
|
|
1619
1631
|
return false;
|
|
1620
1632
|
};
|
|
1621
1633
|
|
|
1634
|
+
const compareSize = (extensionA, extensionB) => {
|
|
1635
|
+
// Sort by size descending (larger sizes first)
|
|
1636
|
+
return extensionB.size - extensionA.size;
|
|
1637
|
+
};
|
|
1638
|
+
const compareUpdatedDate = (extensionA, extensionB) => {
|
|
1639
|
+
// Sort by updated date descending (newer first)
|
|
1640
|
+
return extensionB.updatedDate - extensionA.updatedDate;
|
|
1641
|
+
};
|
|
1622
1642
|
const compareExtension = (extensionA, extensionB) => {
|
|
1623
1643
|
return extensionA.name.localeCompare(extensionB.name) || extensionA.id.localeCompare(extensionB.id);
|
|
1624
1644
|
};
|
|
1625
1645
|
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1646
|
+
const getCompareFn = sort => {
|
|
1647
|
+
if (sort === 'size') {
|
|
1648
|
+
return compareSize;
|
|
1649
|
+
}
|
|
1650
|
+
if (sort === 'updatedDate') {
|
|
1651
|
+
return compareUpdatedDate;
|
|
1652
|
+
}
|
|
1653
|
+
// Default to comparing by name and id
|
|
1654
|
+
return compareExtension;
|
|
1655
|
+
};
|
|
1656
|
+
const sortExtensions = (extensions, parsedValue) => {
|
|
1657
|
+
const compareFn = getCompareFn(parsedValue?.sort || '');
|
|
1658
|
+
return extensions.toSorted(compareFn);
|
|
1628
1659
|
};
|
|
1629
1660
|
|
|
1630
1661
|
const getExtensions = async (extensions, parsedValue) => {
|
|
@@ -1634,7 +1665,7 @@ const getExtensions = async (extensions, parsedValue) => {
|
|
|
1634
1665
|
filteredExtensions.push(extension);
|
|
1635
1666
|
}
|
|
1636
1667
|
}
|
|
1637
|
-
const sortedExtensions = sortExtensions(filteredExtensions);
|
|
1668
|
+
const sortedExtensions = sortExtensions(filteredExtensions, parsedValue);
|
|
1638
1669
|
return sortedExtensions;
|
|
1639
1670
|
};
|
|
1640
1671
|
|
|
@@ -1723,7 +1754,7 @@ const handleChange = async (state, update) => {
|
|
|
1723
1754
|
await handleError(error);
|
|
1724
1755
|
return {
|
|
1725
1756
|
...fullNewState,
|
|
1726
|
-
message:
|
|
1757
|
+
message: error instanceof Error ? error.message : String(error)
|
|
1727
1758
|
};
|
|
1728
1759
|
}
|
|
1729
1760
|
};
|
|
@@ -1865,7 +1896,7 @@ const create = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1865
1896
|
};
|
|
1866
1897
|
|
|
1867
1898
|
const isEqual$3 = (oldState, newState) => {
|
|
1868
|
-
return
|
|
1899
|
+
return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarY === newState.scrollBarY && oldState.initial === newState.initial && oldState.deltaY === newState.deltaY;
|
|
1869
1900
|
};
|
|
1870
1901
|
|
|
1871
1902
|
const isEqual$2 = (oldState, newState) => {
|
|
@@ -1903,10 +1934,30 @@ const diff2 = uid => {
|
|
|
1903
1934
|
return diff(uid, modules, numbers);
|
|
1904
1935
|
};
|
|
1905
1936
|
|
|
1937
|
+
const disable = async (state, _id) => {
|
|
1938
|
+
await confirm('not implemented');
|
|
1939
|
+
return state;
|
|
1940
|
+
};
|
|
1941
|
+
|
|
1942
|
+
const disableWorkspace = async (state, _id) => {
|
|
1943
|
+
await confirm('not implemented');
|
|
1944
|
+
return state;
|
|
1945
|
+
};
|
|
1946
|
+
|
|
1906
1947
|
const dispose = uid => {
|
|
1907
1948
|
dispose$1(uid);
|
|
1908
1949
|
};
|
|
1909
1950
|
|
|
1951
|
+
const enable = async (state, _id) => {
|
|
1952
|
+
await confirm('not implemented');
|
|
1953
|
+
return state;
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1956
|
+
const enableWorkspace = async (state, _id) => {
|
|
1957
|
+
await confirm('not implemented');
|
|
1958
|
+
return state;
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1910
1961
|
// TODO optimize this function to return the minimum number
|
|
1911
1962
|
// of visible items needed, e.g. when not scrolled 5 items with
|
|
1912
1963
|
// 20px fill 100px but when scrolled 6 items are needed
|
|
@@ -2153,17 +2204,17 @@ const Separator = 1;
|
|
|
2153
2204
|
const None$1 = 0;
|
|
2154
2205
|
const SubMenu = 4;
|
|
2155
2206
|
|
|
2156
|
-
const
|
|
2207
|
+
const getMenuEntriesList = () => {
|
|
2157
2208
|
return [{
|
|
2158
2209
|
command: 'SearchExtensions.enable',
|
|
2159
2210
|
flags: None$1,
|
|
2160
2211
|
id: 'enable',
|
|
2161
|
-
label: enable()
|
|
2212
|
+
label: enable$1()
|
|
2162
2213
|
}, {
|
|
2163
2214
|
command: 'SearchExtensions.enableWorkspace',
|
|
2164
2215
|
flags: None$1,
|
|
2165
2216
|
id: 'enableWorkspace',
|
|
2166
|
-
label: enableWorkspace()
|
|
2217
|
+
label: enableWorkspace$1()
|
|
2167
2218
|
}, {
|
|
2168
2219
|
command: '',
|
|
2169
2220
|
flags: Separator,
|
|
@@ -2173,12 +2224,12 @@ const getMenuEntries = () => {
|
|
|
2173
2224
|
command: 'SearchExtensions.disable',
|
|
2174
2225
|
flags: None$1,
|
|
2175
2226
|
id: 'disable',
|
|
2176
|
-
label: disable()
|
|
2227
|
+
label: disable$1()
|
|
2177
2228
|
}, {
|
|
2178
2229
|
command: 'SearchExtensions.disableWorkspace',
|
|
2179
2230
|
flags: None$1,
|
|
2180
2231
|
id: 'disableWorkspace',
|
|
2181
|
-
label: disableWorkspace()
|
|
2232
|
+
label: disableWorkspace$1()
|
|
2182
2233
|
}, {
|
|
2183
2234
|
command: '',
|
|
2184
2235
|
flags: Separator,
|
|
@@ -2188,7 +2239,7 @@ const getMenuEntries = () => {
|
|
|
2188
2239
|
command: 'SearchExtensions.installAnotherVersion',
|
|
2189
2240
|
flags: None$1,
|
|
2190
2241
|
id: 'installAnotherVersion',
|
|
2191
|
-
label: installAnotherVersion()
|
|
2242
|
+
label: installAnotherVersion$1()
|
|
2192
2243
|
}, {
|
|
2193
2244
|
command: 'Extensions.copyExtensionInfo',
|
|
2194
2245
|
flags: None$1,
|
|
@@ -2289,7 +2340,7 @@ const getMenuEntries2 = (state, props) => {
|
|
|
2289
2340
|
case ExtensionSearchFilter:
|
|
2290
2341
|
return getMenuEntriesFilter();
|
|
2291
2342
|
default:
|
|
2292
|
-
return
|
|
2343
|
+
return getMenuEntriesList();
|
|
2293
2344
|
}
|
|
2294
2345
|
};
|
|
2295
2346
|
|
|
@@ -2357,6 +2408,7 @@ const NavigateChild = 7;
|
|
|
2357
2408
|
const NavigateParent = 8;
|
|
2358
2409
|
const RemoveChild = 9;
|
|
2359
2410
|
const NavigateSibling = 10;
|
|
2411
|
+
const SetReferenceNodeUid = 11;
|
|
2360
2412
|
|
|
2361
2413
|
const isKey = key => {
|
|
2362
2414
|
return key !== 'type' && key !== 'childCount';
|
|
@@ -2418,12 +2470,22 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
2418
2470
|
};
|
|
2419
2471
|
|
|
2420
2472
|
const compareNodes = (oldNode, newNode) => {
|
|
2421
|
-
const patches = [];
|
|
2422
2473
|
// Check if node type changed - return null to signal incompatible nodes
|
|
2423
2474
|
// (caller should handle this with a Replace operation)
|
|
2424
2475
|
if (oldNode.type !== newNode.type) {
|
|
2425
2476
|
return null;
|
|
2426
2477
|
}
|
|
2478
|
+
const patches = [];
|
|
2479
|
+
// Handle reference nodes - special handling for uid changes
|
|
2480
|
+
if (oldNode.type === Reference) {
|
|
2481
|
+
if (oldNode.uid !== newNode.uid) {
|
|
2482
|
+
patches.push({
|
|
2483
|
+
type: SetReferenceNodeUid,
|
|
2484
|
+
uid: newNode.uid
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
return patches;
|
|
2488
|
+
}
|
|
2427
2489
|
// Handle text nodes
|
|
2428
2490
|
if (oldNode.type === Text && newNode.type === Text) {
|
|
2429
2491
|
if (oldNode.text !== newNode.text) {
|
|
@@ -2449,7 +2511,7 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
2449
2511
|
}
|
|
2450
2512
|
// Check for removed attributes
|
|
2451
2513
|
for (const key of oldKeys) {
|
|
2452
|
-
if (!(key
|
|
2514
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
2453
2515
|
patches.push({
|
|
2454
2516
|
type: RemoveAttribute,
|
|
2455
2517
|
key
|
|
@@ -2467,11 +2529,78 @@ const treeToArray = node => {
|
|
|
2467
2529
|
return result;
|
|
2468
2530
|
};
|
|
2469
2531
|
|
|
2532
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
2533
|
+
if (currentChildIndex === -1) {
|
|
2534
|
+
patches.push({
|
|
2535
|
+
type: NavigateChild,
|
|
2536
|
+
index
|
|
2537
|
+
});
|
|
2538
|
+
return index;
|
|
2539
|
+
}
|
|
2540
|
+
if (currentChildIndex !== index) {
|
|
2541
|
+
patches.push({
|
|
2542
|
+
type: NavigateSibling,
|
|
2543
|
+
index
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
return index;
|
|
2547
|
+
};
|
|
2548
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
2549
|
+
if (currentChildIndex >= 0) {
|
|
2550
|
+
patches.push({
|
|
2551
|
+
type: NavigateParent
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
return -1;
|
|
2555
|
+
};
|
|
2556
|
+
const addTree = (newNode, patches) => {
|
|
2557
|
+
patches.push({
|
|
2558
|
+
type: Add,
|
|
2559
|
+
nodes: treeToArray(newNode)
|
|
2560
|
+
});
|
|
2561
|
+
};
|
|
2562
|
+
const replaceTree = (newNode, patches) => {
|
|
2563
|
+
patches.push({
|
|
2564
|
+
type: Replace,
|
|
2565
|
+
nodes: treeToArray(newNode)
|
|
2566
|
+
});
|
|
2567
|
+
};
|
|
2568
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
2569
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2570
|
+
if (nodePatches === null) {
|
|
2571
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2572
|
+
replaceTree(newNode, patches);
|
|
2573
|
+
return nextChildIndex;
|
|
2574
|
+
}
|
|
2575
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2576
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
2577
|
+
return currentChildIndex;
|
|
2578
|
+
}
|
|
2579
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2580
|
+
if (nodePatches.length > 0) {
|
|
2581
|
+
patches.push(...nodePatches);
|
|
2582
|
+
}
|
|
2583
|
+
if (hasChildrenToCompare) {
|
|
2584
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2585
|
+
}
|
|
2586
|
+
return nextChildIndex;
|
|
2587
|
+
};
|
|
2588
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
2589
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2590
|
+
if (nodePatches === null) {
|
|
2591
|
+
replaceTree(newNode, patches);
|
|
2592
|
+
return;
|
|
2593
|
+
}
|
|
2594
|
+
if (nodePatches.length > 0) {
|
|
2595
|
+
patches.push(...nodePatches);
|
|
2596
|
+
}
|
|
2597
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2598
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2470
2601
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
2471
2602
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
2472
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
2473
2603
|
let currentChildIndex = -1;
|
|
2474
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
2475
2604
|
const indicesToRemove = [];
|
|
2476
2605
|
for (let i = 0; i < maxLength; i++) {
|
|
2477
2606
|
const oldNode = oldChildren[i];
|
|
@@ -2480,89 +2609,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2480
2609
|
continue;
|
|
2481
2610
|
}
|
|
2482
2611
|
if (!oldNode) {
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
});
|
|
2489
|
-
currentChildIndex = -1;
|
|
2490
|
-
}
|
|
2491
|
-
// Flatten the entire subtree so renderInternal can handle it
|
|
2492
|
-
const flatNodes = treeToArray(newNode);
|
|
2493
|
-
patches.push({
|
|
2494
|
-
type: Add,
|
|
2495
|
-
nodes: flatNodes
|
|
2496
|
-
});
|
|
2497
|
-
} else if (newNode) {
|
|
2498
|
-
// Compare nodes to see if we need any patches
|
|
2499
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2500
|
-
// If nodePatches is null, the node types are incompatible - need to replace
|
|
2501
|
-
if (nodePatches === null) {
|
|
2502
|
-
// Navigate to this child
|
|
2503
|
-
if (currentChildIndex === -1) {
|
|
2504
|
-
patches.push({
|
|
2505
|
-
type: NavigateChild,
|
|
2506
|
-
index: i
|
|
2507
|
-
});
|
|
2508
|
-
currentChildIndex = i;
|
|
2509
|
-
} else if (currentChildIndex !== i) {
|
|
2510
|
-
patches.push({
|
|
2511
|
-
type: NavigateSibling,
|
|
2512
|
-
index: i
|
|
2513
|
-
});
|
|
2514
|
-
currentChildIndex = i;
|
|
2515
|
-
}
|
|
2516
|
-
// Replace the entire subtree
|
|
2517
|
-
const flatNodes = treeToArray(newNode);
|
|
2518
|
-
patches.push({
|
|
2519
|
-
type: Replace,
|
|
2520
|
-
nodes: flatNodes
|
|
2521
|
-
});
|
|
2522
|
-
// After replace, we're at the new element (same position)
|
|
2523
|
-
continue;
|
|
2524
|
-
}
|
|
2525
|
-
// Check if we need to recurse into children
|
|
2526
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2527
|
-
// Only navigate to this element if we need to do something
|
|
2528
|
-
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
2529
|
-
// Navigate to this child if not already there
|
|
2530
|
-
if (currentChildIndex === -1) {
|
|
2531
|
-
patches.push({
|
|
2532
|
-
type: NavigateChild,
|
|
2533
|
-
index: i
|
|
2534
|
-
});
|
|
2535
|
-
currentChildIndex = i;
|
|
2536
|
-
} else if (currentChildIndex !== i) {
|
|
2537
|
-
patches.push({
|
|
2538
|
-
type: NavigateSibling,
|
|
2539
|
-
index: i
|
|
2540
|
-
});
|
|
2541
|
-
currentChildIndex = i;
|
|
2542
|
-
}
|
|
2543
|
-
// Apply node patches (these apply to the current element, not children)
|
|
2544
|
-
if (nodePatches.length > 0) {
|
|
2545
|
-
patches.push(...nodePatches);
|
|
2546
|
-
}
|
|
2547
|
-
// Compare children recursively
|
|
2548
|
-
if (hasChildrenToCompare) {
|
|
2549
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
} else {
|
|
2553
|
-
// Remove old node - collect the index for later removal
|
|
2612
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
2613
|
+
addTree(newNode, patches);
|
|
2614
|
+
continue;
|
|
2615
|
+
}
|
|
2616
|
+
if (!newNode) {
|
|
2554
2617
|
indicesToRemove.push(i);
|
|
2618
|
+
continue;
|
|
2555
2619
|
}
|
|
2620
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
2556
2621
|
}
|
|
2557
|
-
|
|
2558
|
-
if (currentChildIndex >= 0) {
|
|
2559
|
-
patches.push({
|
|
2560
|
-
type: NavigateParent
|
|
2561
|
-
});
|
|
2562
|
-
currentChildIndex = -1;
|
|
2563
|
-
}
|
|
2564
|
-
// Add remove patches in reverse order (highest index first)
|
|
2565
|
-
// This ensures indices remain valid as we remove
|
|
2622
|
+
navigateToParent(patches, currentChildIndex);
|
|
2566
2623
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2567
2624
|
patches.push({
|
|
2568
2625
|
type: RemoveChild,
|
|
@@ -2571,33 +2628,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2571
2628
|
}
|
|
2572
2629
|
};
|
|
2573
2630
|
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
2574
|
-
// At the root level (path.length === 0), we're already AT the element
|
|
2575
|
-
// So we compare the root node directly, then compare its children
|
|
2576
2631
|
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
// Compare root nodes
|
|
2580
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2581
|
-
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
2582
|
-
if (nodePatches === null) {
|
|
2583
|
-
const flatNodes = treeToArray(newNode);
|
|
2584
|
-
patches.push({
|
|
2585
|
-
type: Replace,
|
|
2586
|
-
nodes: flatNodes
|
|
2587
|
-
});
|
|
2588
|
-
return;
|
|
2589
|
-
}
|
|
2590
|
-
if (nodePatches.length > 0) {
|
|
2591
|
-
patches.push(...nodePatches);
|
|
2592
|
-
}
|
|
2593
|
-
// Compare children
|
|
2594
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2595
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
2596
|
-
}
|
|
2597
|
-
} else {
|
|
2598
|
-
// Non-root level or multiple root elements - use the regular comparison
|
|
2599
|
-
diffChildren(oldTree, newTree, patches);
|
|
2632
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
2633
|
+
return;
|
|
2600
2634
|
}
|
|
2635
|
+
diffChildren(oldTree, newTree, patches);
|
|
2601
2636
|
};
|
|
2602
2637
|
|
|
2603
2638
|
const removeTrailingNavigationPatches = patches => {
|
|
@@ -2673,8 +2708,9 @@ const handleClickFilter = async state => {
|
|
|
2673
2708
|
x,
|
|
2674
2709
|
y
|
|
2675
2710
|
} = state;
|
|
2676
|
-
const menuX = x + width +
|
|
2677
|
-
const
|
|
2711
|
+
const menuX = x + width + 60;
|
|
2712
|
+
const menuHeight = 370;
|
|
2713
|
+
const menuY = y + headerHeight + menuHeight;
|
|
2678
2714
|
await show2(uid, ExtensionSearchFilter, menuX, menuY, {
|
|
2679
2715
|
menuId: ExtensionSearchFilter
|
|
2680
2716
|
});
|
|
@@ -2874,6 +2910,33 @@ const handleScrollBarMove = (state, eventY) => {
|
|
|
2874
2910
|
return setDeltaY(state, newDeltaY);
|
|
2875
2911
|
};
|
|
2876
2912
|
|
|
2913
|
+
const handleSettingsButtonClick = async (state, index) => {
|
|
2914
|
+
const {
|
|
2915
|
+
deltaY,
|
|
2916
|
+
headerHeight,
|
|
2917
|
+
itemHeight,
|
|
2918
|
+
items,
|
|
2919
|
+
uid,
|
|
2920
|
+
x,
|
|
2921
|
+
y
|
|
2922
|
+
} = state;
|
|
2923
|
+
const actualIndex = index;
|
|
2924
|
+
if (actualIndex < 0 || actualIndex >= items.length) {
|
|
2925
|
+
return state;
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
// Calculate the position for the context menu
|
|
2929
|
+
// The settings button is at the bottom right of the extension list item
|
|
2930
|
+
const itemY = y + headerHeight + actualIndex * itemHeight - deltaY;
|
|
2931
|
+
const menuX = x + 200; // Position near the right side of the extension item
|
|
2932
|
+
const menuY = itemY + itemHeight - 10; // Position at the bottom of the extension item
|
|
2933
|
+
|
|
2934
|
+
await show2(uid, ManageExtension, menuX, menuY, {
|
|
2935
|
+
menuId: ManageExtension
|
|
2936
|
+
});
|
|
2937
|
+
return state;
|
|
2938
|
+
};
|
|
2939
|
+
|
|
2877
2940
|
// TODO show error / warning when installment fails / times out
|
|
2878
2941
|
const handleUninstall = async (state, id) => {
|
|
2879
2942
|
return state;
|
|
@@ -2891,7 +2954,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
|
|
|
2891
2954
|
|
|
2892
2955
|
const createExtensionHostWorkerRpc = async () => {
|
|
2893
2956
|
try {
|
|
2894
|
-
const rpc = await
|
|
2957
|
+
const rpc = await create$4({
|
|
2895
2958
|
commandMap: {},
|
|
2896
2959
|
send: sendMessagePortToExtensionHostWorker
|
|
2897
2960
|
});
|
|
@@ -2913,7 +2976,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
2913
2976
|
|
|
2914
2977
|
const createExtensionManagementWorkerRpc = async () => {
|
|
2915
2978
|
try {
|
|
2916
|
-
const rpc = await
|
|
2979
|
+
const rpc = await create$4({
|
|
2917
2980
|
commandMap: {},
|
|
2918
2981
|
send: port => sendMessagePortToExtensionManagementWorker(port, 0)
|
|
2919
2982
|
});
|
|
@@ -2936,6 +2999,11 @@ const initialize = async () => {
|
|
|
2936
2999
|
await Promise.all([initializeExtensionHostWorker(), initializeExtensionManagementWorker()]);
|
|
2937
3000
|
};
|
|
2938
3001
|
|
|
3002
|
+
const installAnotherVersion = async state => {
|
|
3003
|
+
await confirm('not implemented');
|
|
3004
|
+
return state;
|
|
3005
|
+
};
|
|
3006
|
+
|
|
2939
3007
|
const Web = 1;
|
|
2940
3008
|
const Electron = 2;
|
|
2941
3009
|
const Remote = 3;
|
|
@@ -3040,6 +3108,18 @@ const getId$1 = extension => {
|
|
|
3040
3108
|
}
|
|
3041
3109
|
return extension.id;
|
|
3042
3110
|
};
|
|
3111
|
+
const getSize = extension => {
|
|
3112
|
+
if (!extension || extension.size === 0 || typeof extension.size !== 'number') {
|
|
3113
|
+
return 0;
|
|
3114
|
+
}
|
|
3115
|
+
return extension.size;
|
|
3116
|
+
};
|
|
3117
|
+
const getUpdatedDate = extension => {
|
|
3118
|
+
if (!extension || !extension.updatedDate || typeof extension.updatedDate !== 'number') {
|
|
3119
|
+
return 0;
|
|
3120
|
+
}
|
|
3121
|
+
return extension.updatedDate;
|
|
3122
|
+
};
|
|
3043
3123
|
const isString = item => {
|
|
3044
3124
|
return typeof item === 'string';
|
|
3045
3125
|
};
|
|
@@ -3065,7 +3145,7 @@ const getPublisher = extension => {
|
|
|
3065
3145
|
return match[0];
|
|
3066
3146
|
};
|
|
3067
3147
|
|
|
3068
|
-
const normalizeExtension
|
|
3148
|
+
const normalizeExtension = (extension, platform, assetDir) => {
|
|
3069
3149
|
return {
|
|
3070
3150
|
categories: getCategories(extension),
|
|
3071
3151
|
description: getDescription(extension),
|
|
@@ -3073,16 +3153,14 @@ const normalizeExtension$1 = (extension, platform, assetDir) => {
|
|
|
3073
3153
|
id: getId$1(extension),
|
|
3074
3154
|
name: getName(extension),
|
|
3075
3155
|
publisher: getPublisher(extension),
|
|
3156
|
+
size: getSize(extension),
|
|
3157
|
+
updatedDate: getUpdatedDate(extension),
|
|
3076
3158
|
uri: ''
|
|
3077
3159
|
};
|
|
3078
3160
|
};
|
|
3079
3161
|
|
|
3080
|
-
const
|
|
3081
|
-
|
|
3082
|
-
for (const extension of extensions) {
|
|
3083
|
-
normalized.push(normalizeExtension$1(extension, platform, assetDir));
|
|
3084
|
-
}
|
|
3085
|
-
return normalized;
|
|
3162
|
+
const normalizeExtensions = (extensions, platform, assetDir) => {
|
|
3163
|
+
return Array.from(extensions, extension => normalizeExtension(extension, platform, assetDir));
|
|
3086
3164
|
};
|
|
3087
3165
|
|
|
3088
3166
|
const getSavedValue = savedState => {
|
|
@@ -3120,7 +3198,7 @@ const loadContent = async (state, savedState) => {
|
|
|
3120
3198
|
// TODO just get local extensions on demand (not when query string is already different)
|
|
3121
3199
|
const allExtensions = await getAllExtensions(platform);
|
|
3122
3200
|
const size = getViewletSize(width);
|
|
3123
|
-
const normalized =
|
|
3201
|
+
const normalized = normalizeExtensions(allExtensions, platform, assetDir);
|
|
3124
3202
|
const updatedState = await handleInput({
|
|
3125
3203
|
...state,
|
|
3126
3204
|
allExtensions: normalized,
|
|
@@ -3150,11 +3228,22 @@ const getCss = state => {
|
|
|
3150
3228
|
translate: 0 ${roundedScrollBarY}px;
|
|
3151
3229
|
}
|
|
3152
3230
|
|
|
3153
|
-
|
|
3154
|
-
|
|
3231
|
+
|
|
3232
|
+
/* TODO: avoid using negative margin. find a better way*/
|
|
3233
|
+
.ExtensionListItem:nth-child(1) {
|
|
3234
|
+
margin-top: ${relative}px;
|
|
3235
|
+
}
|
|
3155
3236
|
|
|
3156
3237
|
.ExtensionListItem {
|
|
3157
3238
|
position: relative !important;
|
|
3239
|
+
flex-shrink: 0;
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
.Extensions .ListItems {
|
|
3243
|
+
display: flex;
|
|
3244
|
+
flex-direction: column;
|
|
3245
|
+
gap: 0;
|
|
3246
|
+
overflow-y: hidden;
|
|
3158
3247
|
}
|
|
3159
3248
|
`;
|
|
3160
3249
|
};
|
|
@@ -3433,9 +3522,6 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
3433
3522
|
if (!shouldShowScrollbar) {
|
|
3434
3523
|
return [];
|
|
3435
3524
|
}
|
|
3436
|
-
// TODO move the dynamic css into a css adopted stylesheet
|
|
3437
|
-
// const heightString = Px.px(scrollBarHeight)
|
|
3438
|
-
// const translateString = Px.position(0, scrollBarTop)
|
|
3439
3525
|
return [{
|
|
3440
3526
|
childCount: 1,
|
|
3441
3527
|
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
@@ -3445,8 +3531,6 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
3445
3531
|
}, {
|
|
3446
3532
|
childCount: 0,
|
|
3447
3533
|
className: ScrollBarThumb,
|
|
3448
|
-
// height: heightString,
|
|
3449
|
-
// translate: translateString,
|
|
3450
3534
|
type: Div
|
|
3451
3535
|
}];
|
|
3452
3536
|
};
|
|
@@ -3465,6 +3549,7 @@ const getVisibleItem = (item, setSize, itemHeight, minLineY, relative, i, focuse
|
|
|
3465
3549
|
focused: i === focusedIndex,
|
|
3466
3550
|
icon,
|
|
3467
3551
|
id,
|
|
3552
|
+
index: i,
|
|
3468
3553
|
name,
|
|
3469
3554
|
posInSet: i + 1,
|
|
3470
3555
|
publisher,
|
|
@@ -3722,6 +3807,7 @@ const renderEventListeners = () => {
|
|
|
3722
3807
|
|
|
3723
3808
|
const resize = async (state, dimensions) => {
|
|
3724
3809
|
const {
|
|
3810
|
+
deltaY,
|
|
3725
3811
|
headerHeight,
|
|
3726
3812
|
itemHeight,
|
|
3727
3813
|
items,
|
|
@@ -3738,14 +3824,16 @@ const resize = async (state, dimensions) => {
|
|
|
3738
3824
|
const contentHeight = total * itemHeight;
|
|
3739
3825
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
3740
3826
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
3741
|
-
const
|
|
3827
|
+
const minLineY = Math.floor(deltaY / itemHeight);
|
|
3828
|
+
const maxLineY = Math.min(minLineY + numberOfVisible, total);
|
|
3742
3829
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
3743
|
-
const scrollBarY = getScrollBarY$1(
|
|
3830
|
+
const scrollBarY = getScrollBarY$1(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
3744
3831
|
return {
|
|
3745
3832
|
...state,
|
|
3746
3833
|
finalDeltaY,
|
|
3747
3834
|
height,
|
|
3748
3835
|
maxLineY,
|
|
3836
|
+
minLineY,
|
|
3749
3837
|
scrollBarHeight,
|
|
3750
3838
|
scrollBarY,
|
|
3751
3839
|
width,
|
|
@@ -3789,17 +3877,19 @@ const toggleSuggest = state => {
|
|
|
3789
3877
|
};
|
|
3790
3878
|
|
|
3791
3879
|
const commandMap = {
|
|
3880
|
+
'Extensions.copyExtensionId': wrapCommand(copyExtensionId),
|
|
3881
|
+
'Extensions.copyExtensionInfo': wrapCommand(copyExtensionInfo),
|
|
3792
3882
|
'SearchExtensions.clearSearchResults': wrapCommand(clearSearchResults),
|
|
3793
3883
|
'SearchExtensions.closeSuggest': wrapCommand(closeSuggest),
|
|
3794
3884
|
'SearchExtensions.copyExtensionId': wrapCommand(copyExtensionId),
|
|
3795
3885
|
'SearchExtensions.copyExtensionInfo': wrapCommand(copyExtensionInfo),
|
|
3796
3886
|
'SearchExtensions.create': create,
|
|
3797
3887
|
'SearchExtensions.diff2': diff2,
|
|
3798
|
-
'SearchExtensions.disable': wrapCommand(
|
|
3799
|
-
'SearchExtensions.disableWorkspace': wrapCommand(
|
|
3888
|
+
'SearchExtensions.disable': wrapCommand(disable),
|
|
3889
|
+
'SearchExtensions.disableWorkspace': wrapCommand(disableWorkspace),
|
|
3800
3890
|
'SearchExtensions.dispose': dispose,
|
|
3801
|
-
'SearchExtensions.enable': wrapCommand(
|
|
3802
|
-
'SearchExtensions.enableWorkspace': wrapCommand(
|
|
3891
|
+
'SearchExtensions.enable': wrapCommand(enable),
|
|
3892
|
+
'SearchExtensions.enableWorkspace': wrapCommand(enableWorkspace),
|
|
3803
3893
|
'SearchExtensions.focusFirst': wrapCommand(focusFirst),
|
|
3804
3894
|
'SearchExtensions.focusIndex': wrapCommand(focusIndex),
|
|
3805
3895
|
'SearchExtensions.focusLast': wrapCommand(focusLast),
|
|
@@ -3810,7 +3900,7 @@ const commandMap = {
|
|
|
3810
3900
|
'SearchExtensions.getActions': getActions,
|
|
3811
3901
|
'SearchExtensions.getCommandIds': getCommandIds,
|
|
3812
3902
|
'SearchExtensions.getKeyBindings': getKeyBindings,
|
|
3813
|
-
'SearchExtensions.getMenuEntries':
|
|
3903
|
+
'SearchExtensions.getMenuEntries': getMenuEntriesList,
|
|
3814
3904
|
'SearchExtensions.getMenuEntries2': wrapGetter(getMenuEntries2),
|
|
3815
3905
|
'SearchExtensions.getMenuEntriesFilter': getMenuEntriesFilter,
|
|
3816
3906
|
'SearchExtensions.getMenuIds': getMenuIds,
|
|
@@ -3833,9 +3923,11 @@ const commandMap = {
|
|
|
3833
3923
|
'SearchExtensions.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
3834
3924
|
'SearchExtensions.handleScrollBarMove': wrapCommand(handleScrollBarMove),
|
|
3835
3925
|
'SearchExtensions.handleScrollBarThumbPointerMove': wrapCommand(handleScrollBarMove),
|
|
3926
|
+
'SearchExtensions.handleSettingsButtonClick': wrapCommand(handleSettingsButtonClick),
|
|
3836
3927
|
'SearchExtensions.handleUninstall': wrapCommand(handleUninstall),
|
|
3837
3928
|
'SearchExtensions.handleWheel': wrapCommand(handleWheel),
|
|
3838
3929
|
'SearchExtensions.initialize': initialize,
|
|
3930
|
+
'SearchExtensions.installAnotherVersion': wrapCommand(installAnotherVersion),
|
|
3839
3931
|
'SearchExtensions.loadContent': wrapCommand(loadContent),
|
|
3840
3932
|
'SearchExtensions.openSuggest': wrapCommand(openSuggest),
|
|
3841
3933
|
'SearchExtensions.render3': render3,
|
|
@@ -3854,7 +3946,7 @@ const commandMap = {
|
|
|
3854
3946
|
|
|
3855
3947
|
const listen = async () => {
|
|
3856
3948
|
registerCommands(commandMap);
|
|
3857
|
-
const rpc = await
|
|
3949
|
+
const rpc = await create$3({
|
|
3858
3950
|
commandMap: commandMap
|
|
3859
3951
|
});
|
|
3860
3952
|
set$2(rpc);
|