@lvce-editor/extension-search-view 7.2.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 +435 -334
- 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 = () => {
|
|
@@ -1511,7 +1523,7 @@ const Id = '@id';
|
|
|
1511
1523
|
const Category = '@category';
|
|
1512
1524
|
const Outdated = '@outdated';
|
|
1513
1525
|
|
|
1514
|
-
const RE_PARAM = /@\w
|
|
1526
|
+
const RE_PARAM = /@\w+(?::\w+)?/g;
|
|
1515
1527
|
const deserializeCategory = value => {
|
|
1516
1528
|
if (value.startsWith(':"') && value.endsWith('"')) {
|
|
1517
1529
|
return value.slice(2, -1);
|
|
@@ -1550,8 +1562,17 @@ const parseValue = value => {
|
|
|
1550
1562
|
builtin = true;
|
|
1551
1563
|
}
|
|
1552
1564
|
if (match.startsWith(Sort)) {
|
|
1553
|
-
//
|
|
1554
|
-
|
|
1565
|
+
// Parse sort value after @sort:
|
|
1566
|
+
const sortValue = match.slice(Sort.length);
|
|
1567
|
+
if (sortValue.startsWith(':')) {
|
|
1568
|
+
sort = sortValue.slice(1);
|
|
1569
|
+
} else if (sortValue === '') {
|
|
1570
|
+
// Default sort if no value specified
|
|
1571
|
+
sort = 'installs';
|
|
1572
|
+
} else {
|
|
1573
|
+
// Handle cases like @sort:installs or @sortsize (without colon)
|
|
1574
|
+
sort = sortValue.replace(/^:/, '');
|
|
1575
|
+
}
|
|
1555
1576
|
}
|
|
1556
1577
|
if (match.startsWith(Id)) {
|
|
1557
1578
|
// TODO improve parsing
|
|
@@ -1610,12 +1631,31 @@ const matchesParsedValue = (extension, parsedValue) => {
|
|
|
1610
1631
|
return false;
|
|
1611
1632
|
};
|
|
1612
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
|
+
};
|
|
1613
1642
|
const compareExtension = (extensionA, extensionB) => {
|
|
1614
1643
|
return extensionA.name.localeCompare(extensionB.name) || extensionA.id.localeCompare(extensionB.id);
|
|
1615
1644
|
};
|
|
1616
1645
|
|
|
1617
|
-
const
|
|
1618
|
-
|
|
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);
|
|
1619
1659
|
};
|
|
1620
1660
|
|
|
1621
1661
|
const getExtensions = async (extensions, parsedValue) => {
|
|
@@ -1625,7 +1665,7 @@ const getExtensions = async (extensions, parsedValue) => {
|
|
|
1625
1665
|
filteredExtensions.push(extension);
|
|
1626
1666
|
}
|
|
1627
1667
|
}
|
|
1628
|
-
const sortedExtensions = sortExtensions(filteredExtensions);
|
|
1668
|
+
const sortedExtensions = sortExtensions(filteredExtensions, parsedValue);
|
|
1629
1669
|
return sortedExtensions;
|
|
1630
1670
|
};
|
|
1631
1671
|
|
|
@@ -1714,7 +1754,7 @@ const handleChange = async (state, update) => {
|
|
|
1714
1754
|
await handleError(error);
|
|
1715
1755
|
return {
|
|
1716
1756
|
...fullNewState,
|
|
1717
|
-
message:
|
|
1757
|
+
message: error instanceof Error ? error.message : String(error)
|
|
1718
1758
|
};
|
|
1719
1759
|
}
|
|
1720
1760
|
};
|
|
@@ -1856,7 +1896,7 @@ const create = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1856
1896
|
};
|
|
1857
1897
|
|
|
1858
1898
|
const isEqual$3 = (oldState, newState) => {
|
|
1859
|
-
return
|
|
1899
|
+
return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarY === newState.scrollBarY && oldState.initial === newState.initial && oldState.deltaY === newState.deltaY;
|
|
1860
1900
|
};
|
|
1861
1901
|
|
|
1862
1902
|
const isEqual$2 = (oldState, newState) => {
|
|
@@ -1894,10 +1934,30 @@ const diff2 = uid => {
|
|
|
1894
1934
|
return diff(uid, modules, numbers);
|
|
1895
1935
|
};
|
|
1896
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
|
+
|
|
1897
1947
|
const dispose = uid => {
|
|
1898
1948
|
dispose$1(uid);
|
|
1899
1949
|
};
|
|
1900
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
|
+
|
|
1901
1961
|
// TODO optimize this function to return the minimum number
|
|
1902
1962
|
// of visible items needed, e.g. when not scrolled 5 items with
|
|
1903
1963
|
// 20px fill 100px but when scrolled 6 items are needed
|
|
@@ -2144,17 +2204,17 @@ const Separator = 1;
|
|
|
2144
2204
|
const None$1 = 0;
|
|
2145
2205
|
const SubMenu = 4;
|
|
2146
2206
|
|
|
2147
|
-
const
|
|
2207
|
+
const getMenuEntriesList = () => {
|
|
2148
2208
|
return [{
|
|
2149
2209
|
command: 'SearchExtensions.enable',
|
|
2150
2210
|
flags: None$1,
|
|
2151
2211
|
id: 'enable',
|
|
2152
|
-
label: enable()
|
|
2212
|
+
label: enable$1()
|
|
2153
2213
|
}, {
|
|
2154
2214
|
command: 'SearchExtensions.enableWorkspace',
|
|
2155
2215
|
flags: None$1,
|
|
2156
2216
|
id: 'enableWorkspace',
|
|
2157
|
-
label: enableWorkspace()
|
|
2217
|
+
label: enableWorkspace$1()
|
|
2158
2218
|
}, {
|
|
2159
2219
|
command: '',
|
|
2160
2220
|
flags: Separator,
|
|
@@ -2164,12 +2224,12 @@ const getMenuEntries = () => {
|
|
|
2164
2224
|
command: 'SearchExtensions.disable',
|
|
2165
2225
|
flags: None$1,
|
|
2166
2226
|
id: 'disable',
|
|
2167
|
-
label: disable()
|
|
2227
|
+
label: disable$1()
|
|
2168
2228
|
}, {
|
|
2169
2229
|
command: 'SearchExtensions.disableWorkspace',
|
|
2170
2230
|
flags: None$1,
|
|
2171
2231
|
id: 'disableWorkspace',
|
|
2172
|
-
label: disableWorkspace()
|
|
2232
|
+
label: disableWorkspace$1()
|
|
2173
2233
|
}, {
|
|
2174
2234
|
command: '',
|
|
2175
2235
|
flags: Separator,
|
|
@@ -2179,7 +2239,7 @@ const getMenuEntries = () => {
|
|
|
2179
2239
|
command: 'SearchExtensions.installAnotherVersion',
|
|
2180
2240
|
flags: None$1,
|
|
2181
2241
|
id: 'installAnotherVersion',
|
|
2182
|
-
label: installAnotherVersion()
|
|
2242
|
+
label: installAnotherVersion$1()
|
|
2183
2243
|
}, {
|
|
2184
2244
|
command: 'Extensions.copyExtensionInfo',
|
|
2185
2245
|
flags: None$1,
|
|
@@ -2280,7 +2340,7 @@ const getMenuEntries2 = (state, props) => {
|
|
|
2280
2340
|
case ExtensionSearchFilter:
|
|
2281
2341
|
return getMenuEntriesFilter();
|
|
2282
2342
|
default:
|
|
2283
|
-
return
|
|
2343
|
+
return getMenuEntriesList();
|
|
2284
2344
|
}
|
|
2285
2345
|
};
|
|
2286
2346
|
|
|
@@ -2348,6 +2408,7 @@ const NavigateChild = 7;
|
|
|
2348
2408
|
const NavigateParent = 8;
|
|
2349
2409
|
const RemoveChild = 9;
|
|
2350
2410
|
const NavigateSibling = 10;
|
|
2411
|
+
const SetReferenceNodeUid = 11;
|
|
2351
2412
|
|
|
2352
2413
|
const isKey = key => {
|
|
2353
2414
|
return key !== 'type' && key !== 'childCount';
|
|
@@ -2409,12 +2470,22 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
2409
2470
|
};
|
|
2410
2471
|
|
|
2411
2472
|
const compareNodes = (oldNode, newNode) => {
|
|
2412
|
-
const patches = [];
|
|
2413
2473
|
// Check if node type changed - return null to signal incompatible nodes
|
|
2414
2474
|
// (caller should handle this with a Replace operation)
|
|
2415
2475
|
if (oldNode.type !== newNode.type) {
|
|
2416
2476
|
return null;
|
|
2417
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
|
+
}
|
|
2418
2489
|
// Handle text nodes
|
|
2419
2490
|
if (oldNode.type === Text && newNode.type === Text) {
|
|
2420
2491
|
if (oldNode.text !== newNode.text) {
|
|
@@ -2440,7 +2511,7 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
2440
2511
|
}
|
|
2441
2512
|
// Check for removed attributes
|
|
2442
2513
|
for (const key of oldKeys) {
|
|
2443
|
-
if (!(key
|
|
2514
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
2444
2515
|
patches.push({
|
|
2445
2516
|
type: RemoveAttribute,
|
|
2446
2517
|
key
|
|
@@ -2458,11 +2529,78 @@ const treeToArray = node => {
|
|
|
2458
2529
|
return result;
|
|
2459
2530
|
};
|
|
2460
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
|
+
};
|
|
2461
2601
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
2462
2602
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
2463
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
2464
2603
|
let currentChildIndex = -1;
|
|
2465
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
2466
2604
|
const indicesToRemove = [];
|
|
2467
2605
|
for (let i = 0; i < maxLength; i++) {
|
|
2468
2606
|
const oldNode = oldChildren[i];
|
|
@@ -2471,89 +2609,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2471
2609
|
continue;
|
|
2472
2610
|
}
|
|
2473
2611
|
if (!oldNode) {
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
});
|
|
2480
|
-
currentChildIndex = -1;
|
|
2481
|
-
}
|
|
2482
|
-
// Flatten the entire subtree so renderInternal can handle it
|
|
2483
|
-
const flatNodes = treeToArray(newNode);
|
|
2484
|
-
patches.push({
|
|
2485
|
-
type: Add,
|
|
2486
|
-
nodes: flatNodes
|
|
2487
|
-
});
|
|
2488
|
-
} else if (newNode) {
|
|
2489
|
-
// Compare nodes to see if we need any patches
|
|
2490
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2491
|
-
// If nodePatches is null, the node types are incompatible - need to replace
|
|
2492
|
-
if (nodePatches === null) {
|
|
2493
|
-
// Navigate to this child
|
|
2494
|
-
if (currentChildIndex === -1) {
|
|
2495
|
-
patches.push({
|
|
2496
|
-
type: NavigateChild,
|
|
2497
|
-
index: i
|
|
2498
|
-
});
|
|
2499
|
-
currentChildIndex = i;
|
|
2500
|
-
} else if (currentChildIndex !== i) {
|
|
2501
|
-
patches.push({
|
|
2502
|
-
type: NavigateSibling,
|
|
2503
|
-
index: i
|
|
2504
|
-
});
|
|
2505
|
-
currentChildIndex = i;
|
|
2506
|
-
}
|
|
2507
|
-
// Replace the entire subtree
|
|
2508
|
-
const flatNodes = treeToArray(newNode);
|
|
2509
|
-
patches.push({
|
|
2510
|
-
type: Replace,
|
|
2511
|
-
nodes: flatNodes
|
|
2512
|
-
});
|
|
2513
|
-
// After replace, we're at the new element (same position)
|
|
2514
|
-
continue;
|
|
2515
|
-
}
|
|
2516
|
-
// Check if we need to recurse into children
|
|
2517
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2518
|
-
// Only navigate to this element if we need to do something
|
|
2519
|
-
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
2520
|
-
// Navigate to this child if not already there
|
|
2521
|
-
if (currentChildIndex === -1) {
|
|
2522
|
-
patches.push({
|
|
2523
|
-
type: NavigateChild,
|
|
2524
|
-
index: i
|
|
2525
|
-
});
|
|
2526
|
-
currentChildIndex = i;
|
|
2527
|
-
} else if (currentChildIndex !== i) {
|
|
2528
|
-
patches.push({
|
|
2529
|
-
type: NavigateSibling,
|
|
2530
|
-
index: i
|
|
2531
|
-
});
|
|
2532
|
-
currentChildIndex = i;
|
|
2533
|
-
}
|
|
2534
|
-
// Apply node patches (these apply to the current element, not children)
|
|
2535
|
-
if (nodePatches.length > 0) {
|
|
2536
|
-
patches.push(...nodePatches);
|
|
2537
|
-
}
|
|
2538
|
-
// Compare children recursively
|
|
2539
|
-
if (hasChildrenToCompare) {
|
|
2540
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
} else {
|
|
2544
|
-
// Remove old node - collect the index for later removal
|
|
2612
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
2613
|
+
addTree(newNode, patches);
|
|
2614
|
+
continue;
|
|
2615
|
+
}
|
|
2616
|
+
if (!newNode) {
|
|
2545
2617
|
indicesToRemove.push(i);
|
|
2618
|
+
continue;
|
|
2546
2619
|
}
|
|
2620
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
2547
2621
|
}
|
|
2548
|
-
|
|
2549
|
-
if (currentChildIndex >= 0) {
|
|
2550
|
-
patches.push({
|
|
2551
|
-
type: NavigateParent
|
|
2552
|
-
});
|
|
2553
|
-
currentChildIndex = -1;
|
|
2554
|
-
}
|
|
2555
|
-
// Add remove patches in reverse order (highest index first)
|
|
2556
|
-
// This ensures indices remain valid as we remove
|
|
2622
|
+
navigateToParent(patches, currentChildIndex);
|
|
2557
2623
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2558
2624
|
patches.push({
|
|
2559
2625
|
type: RemoveChild,
|
|
@@ -2562,33 +2628,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2562
2628
|
}
|
|
2563
2629
|
};
|
|
2564
2630
|
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
2565
|
-
// At the root level (path.length === 0), we're already AT the element
|
|
2566
|
-
// So we compare the root node directly, then compare its children
|
|
2567
2631
|
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
// Compare root nodes
|
|
2571
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2572
|
-
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
2573
|
-
if (nodePatches === null) {
|
|
2574
|
-
const flatNodes = treeToArray(newNode);
|
|
2575
|
-
patches.push({
|
|
2576
|
-
type: Replace,
|
|
2577
|
-
nodes: flatNodes
|
|
2578
|
-
});
|
|
2579
|
-
return;
|
|
2580
|
-
}
|
|
2581
|
-
if (nodePatches.length > 0) {
|
|
2582
|
-
patches.push(...nodePatches);
|
|
2583
|
-
}
|
|
2584
|
-
// Compare children
|
|
2585
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2586
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
2587
|
-
}
|
|
2588
|
-
} else {
|
|
2589
|
-
// Non-root level or multiple root elements - use the regular comparison
|
|
2590
|
-
diffChildren(oldTree, newTree, patches);
|
|
2632
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
2633
|
+
return;
|
|
2591
2634
|
}
|
|
2635
|
+
diffChildren(oldTree, newTree, patches);
|
|
2592
2636
|
};
|
|
2593
2637
|
|
|
2594
2638
|
const removeTrailingNavigationPatches = patches => {
|
|
@@ -2664,8 +2708,9 @@ const handleClickFilter = async state => {
|
|
|
2664
2708
|
x,
|
|
2665
2709
|
y
|
|
2666
2710
|
} = state;
|
|
2667
|
-
const menuX = x + width +
|
|
2668
|
-
const
|
|
2711
|
+
const menuX = x + width + 60;
|
|
2712
|
+
const menuHeight = 370;
|
|
2713
|
+
const menuY = y + headerHeight + menuHeight;
|
|
2669
2714
|
await show2(uid, ExtensionSearchFilter, menuX, menuY, {
|
|
2670
2715
|
menuId: ExtensionSearchFilter
|
|
2671
2716
|
});
|
|
@@ -2865,6 +2910,33 @@ const handleScrollBarMove = (state, eventY) => {
|
|
|
2865
2910
|
return setDeltaY(state, newDeltaY);
|
|
2866
2911
|
};
|
|
2867
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
|
+
|
|
2868
2940
|
// TODO show error / warning when installment fails / times out
|
|
2869
2941
|
const handleUninstall = async (state, id) => {
|
|
2870
2942
|
return state;
|
|
@@ -2882,7 +2954,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
|
|
|
2882
2954
|
|
|
2883
2955
|
const createExtensionHostWorkerRpc = async () => {
|
|
2884
2956
|
try {
|
|
2885
|
-
const rpc = await
|
|
2957
|
+
const rpc = await create$4({
|
|
2886
2958
|
commandMap: {},
|
|
2887
2959
|
send: sendMessagePortToExtensionHostWorker
|
|
2888
2960
|
});
|
|
@@ -2904,7 +2976,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
2904
2976
|
|
|
2905
2977
|
const createExtensionManagementWorkerRpc = async () => {
|
|
2906
2978
|
try {
|
|
2907
|
-
const rpc = await
|
|
2979
|
+
const rpc = await create$4({
|
|
2908
2980
|
commandMap: {},
|
|
2909
2981
|
send: port => sendMessagePortToExtensionManagementWorker(port, 0)
|
|
2910
2982
|
});
|
|
@@ -2927,6 +2999,11 @@ const initialize = async () => {
|
|
|
2927
2999
|
await Promise.all([initializeExtensionHostWorker(), initializeExtensionManagementWorker()]);
|
|
2928
3000
|
};
|
|
2929
3001
|
|
|
3002
|
+
const installAnotherVersion = async state => {
|
|
3003
|
+
await confirm('not implemented');
|
|
3004
|
+
return state;
|
|
3005
|
+
};
|
|
3006
|
+
|
|
2930
3007
|
const Web = 1;
|
|
2931
3008
|
const Electron = 2;
|
|
2932
3009
|
const Remote = 3;
|
|
@@ -3031,6 +3108,18 @@ const getId$1 = extension => {
|
|
|
3031
3108
|
}
|
|
3032
3109
|
return extension.id;
|
|
3033
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
|
+
};
|
|
3034
3123
|
const isString = item => {
|
|
3035
3124
|
return typeof item === 'string';
|
|
3036
3125
|
};
|
|
@@ -3056,7 +3145,7 @@ const getPublisher = extension => {
|
|
|
3056
3145
|
return match[0];
|
|
3057
3146
|
};
|
|
3058
3147
|
|
|
3059
|
-
const normalizeExtension
|
|
3148
|
+
const normalizeExtension = (extension, platform, assetDir) => {
|
|
3060
3149
|
return {
|
|
3061
3150
|
categories: getCategories(extension),
|
|
3062
3151
|
description: getDescription(extension),
|
|
@@ -3064,16 +3153,14 @@ const normalizeExtension$1 = (extension, platform, assetDir) => {
|
|
|
3064
3153
|
id: getId$1(extension),
|
|
3065
3154
|
name: getName(extension),
|
|
3066
3155
|
publisher: getPublisher(extension),
|
|
3156
|
+
size: getSize(extension),
|
|
3157
|
+
updatedDate: getUpdatedDate(extension),
|
|
3067
3158
|
uri: ''
|
|
3068
3159
|
};
|
|
3069
3160
|
};
|
|
3070
3161
|
|
|
3071
|
-
const
|
|
3072
|
-
|
|
3073
|
-
for (const extension of extensions) {
|
|
3074
|
-
normalized.push(normalizeExtension$1(extension, platform, assetDir));
|
|
3075
|
-
}
|
|
3076
|
-
return normalized;
|
|
3162
|
+
const normalizeExtensions = (extensions, platform, assetDir) => {
|
|
3163
|
+
return Array.from(extensions, extension => normalizeExtension(extension, platform, assetDir));
|
|
3077
3164
|
};
|
|
3078
3165
|
|
|
3079
3166
|
const getSavedValue = savedState => {
|
|
@@ -3111,7 +3198,7 @@ const loadContent = async (state, savedState) => {
|
|
|
3111
3198
|
// TODO just get local extensions on demand (not when query string is already different)
|
|
3112
3199
|
const allExtensions = await getAllExtensions(platform);
|
|
3113
3200
|
const size = getViewletSize(width);
|
|
3114
|
-
const normalized =
|
|
3201
|
+
const normalized = normalizeExtensions(allExtensions, platform, assetDir);
|
|
3115
3202
|
const updatedState = await handleInput({
|
|
3116
3203
|
...state,
|
|
3117
3204
|
allExtensions: normalized,
|
|
@@ -3141,11 +3228,22 @@ const getCss = state => {
|
|
|
3141
3228
|
translate: 0 ${roundedScrollBarY}px;
|
|
3142
3229
|
}
|
|
3143
3230
|
|
|
3144
|
-
|
|
3145
|
-
|
|
3231
|
+
|
|
3232
|
+
/* TODO: avoid using negative margin. find a better way*/
|
|
3233
|
+
.ExtensionListItem:nth-child(1) {
|
|
3234
|
+
margin-top: ${relative}px;
|
|
3235
|
+
}
|
|
3146
3236
|
|
|
3147
3237
|
.ExtensionListItem {
|
|
3148
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;
|
|
3149
3247
|
}
|
|
3150
3248
|
`;
|
|
3151
3249
|
};
|
|
@@ -3424,9 +3522,6 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
3424
3522
|
if (!shouldShowScrollbar) {
|
|
3425
3523
|
return [];
|
|
3426
3524
|
}
|
|
3427
|
-
// TODO move the dynamic css into a css adopted stylesheet
|
|
3428
|
-
// const heightString = Px.px(scrollBarHeight)
|
|
3429
|
-
// const translateString = Px.position(0, scrollBarTop)
|
|
3430
3525
|
return [{
|
|
3431
3526
|
childCount: 1,
|
|
3432
3527
|
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
@@ -3436,8 +3531,6 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
3436
3531
|
}, {
|
|
3437
3532
|
childCount: 0,
|
|
3438
3533
|
className: ScrollBarThumb,
|
|
3439
|
-
// height: heightString,
|
|
3440
|
-
// translate: translateString,
|
|
3441
3534
|
type: Div
|
|
3442
3535
|
}];
|
|
3443
3536
|
};
|
|
@@ -3456,6 +3549,7 @@ const getVisibleItem = (item, setSize, itemHeight, minLineY, relative, i, focuse
|
|
|
3456
3549
|
focused: i === focusedIndex,
|
|
3457
3550
|
icon,
|
|
3458
3551
|
id,
|
|
3552
|
+
index: i,
|
|
3459
3553
|
name,
|
|
3460
3554
|
posInSet: i + 1,
|
|
3461
3555
|
publisher,
|
|
@@ -3713,6 +3807,7 @@ const renderEventListeners = () => {
|
|
|
3713
3807
|
|
|
3714
3808
|
const resize = async (state, dimensions) => {
|
|
3715
3809
|
const {
|
|
3810
|
+
deltaY,
|
|
3716
3811
|
headerHeight,
|
|
3717
3812
|
itemHeight,
|
|
3718
3813
|
items,
|
|
@@ -3729,14 +3824,16 @@ const resize = async (state, dimensions) => {
|
|
|
3729
3824
|
const contentHeight = total * itemHeight;
|
|
3730
3825
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
3731
3826
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
3732
|
-
const
|
|
3827
|
+
const minLineY = Math.floor(deltaY / itemHeight);
|
|
3828
|
+
const maxLineY = Math.min(minLineY + numberOfVisible, total);
|
|
3733
3829
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
3734
|
-
const scrollBarY = getScrollBarY$1(
|
|
3830
|
+
const scrollBarY = getScrollBarY$1(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
3735
3831
|
return {
|
|
3736
3832
|
...state,
|
|
3737
3833
|
finalDeltaY,
|
|
3738
3834
|
height,
|
|
3739
3835
|
maxLineY,
|
|
3836
|
+
minLineY,
|
|
3740
3837
|
scrollBarHeight,
|
|
3741
3838
|
scrollBarY,
|
|
3742
3839
|
width,
|
|
@@ -3780,17 +3877,19 @@ const toggleSuggest = state => {
|
|
|
3780
3877
|
};
|
|
3781
3878
|
|
|
3782
3879
|
const commandMap = {
|
|
3880
|
+
'Extensions.copyExtensionId': wrapCommand(copyExtensionId),
|
|
3881
|
+
'Extensions.copyExtensionInfo': wrapCommand(copyExtensionInfo),
|
|
3783
3882
|
'SearchExtensions.clearSearchResults': wrapCommand(clearSearchResults),
|
|
3784
3883
|
'SearchExtensions.closeSuggest': wrapCommand(closeSuggest),
|
|
3785
3884
|
'SearchExtensions.copyExtensionId': wrapCommand(copyExtensionId),
|
|
3786
3885
|
'SearchExtensions.copyExtensionInfo': wrapCommand(copyExtensionInfo),
|
|
3787
3886
|
'SearchExtensions.create': create,
|
|
3788
3887
|
'SearchExtensions.diff2': diff2,
|
|
3789
|
-
'SearchExtensions.disable': wrapCommand(
|
|
3790
|
-
'SearchExtensions.disableWorkspace': wrapCommand(
|
|
3888
|
+
'SearchExtensions.disable': wrapCommand(disable),
|
|
3889
|
+
'SearchExtensions.disableWorkspace': wrapCommand(disableWorkspace),
|
|
3791
3890
|
'SearchExtensions.dispose': dispose,
|
|
3792
|
-
'SearchExtensions.enable': wrapCommand(
|
|
3793
|
-
'SearchExtensions.enableWorkspace': wrapCommand(
|
|
3891
|
+
'SearchExtensions.enable': wrapCommand(enable),
|
|
3892
|
+
'SearchExtensions.enableWorkspace': wrapCommand(enableWorkspace),
|
|
3794
3893
|
'SearchExtensions.focusFirst': wrapCommand(focusFirst),
|
|
3795
3894
|
'SearchExtensions.focusIndex': wrapCommand(focusIndex),
|
|
3796
3895
|
'SearchExtensions.focusLast': wrapCommand(focusLast),
|
|
@@ -3801,7 +3900,7 @@ const commandMap = {
|
|
|
3801
3900
|
'SearchExtensions.getActions': getActions,
|
|
3802
3901
|
'SearchExtensions.getCommandIds': getCommandIds,
|
|
3803
3902
|
'SearchExtensions.getKeyBindings': getKeyBindings,
|
|
3804
|
-
'SearchExtensions.getMenuEntries':
|
|
3903
|
+
'SearchExtensions.getMenuEntries': getMenuEntriesList,
|
|
3805
3904
|
'SearchExtensions.getMenuEntries2': wrapGetter(getMenuEntries2),
|
|
3806
3905
|
'SearchExtensions.getMenuEntriesFilter': getMenuEntriesFilter,
|
|
3807
3906
|
'SearchExtensions.getMenuIds': getMenuIds,
|
|
@@ -3824,9 +3923,11 @@ const commandMap = {
|
|
|
3824
3923
|
'SearchExtensions.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
3825
3924
|
'SearchExtensions.handleScrollBarMove': wrapCommand(handleScrollBarMove),
|
|
3826
3925
|
'SearchExtensions.handleScrollBarThumbPointerMove': wrapCommand(handleScrollBarMove),
|
|
3926
|
+
'SearchExtensions.handleSettingsButtonClick': wrapCommand(handleSettingsButtonClick),
|
|
3827
3927
|
'SearchExtensions.handleUninstall': wrapCommand(handleUninstall),
|
|
3828
3928
|
'SearchExtensions.handleWheel': wrapCommand(handleWheel),
|
|
3829
3929
|
'SearchExtensions.initialize': initialize,
|
|
3930
|
+
'SearchExtensions.installAnotherVersion': wrapCommand(installAnotherVersion),
|
|
3830
3931
|
'SearchExtensions.loadContent': wrapCommand(loadContent),
|
|
3831
3932
|
'SearchExtensions.openSuggest': wrapCommand(openSuggest),
|
|
3832
3933
|
'SearchExtensions.render3': render3,
|
|
@@ -3845,7 +3946,7 @@ const commandMap = {
|
|
|
3845
3946
|
|
|
3846
3947
|
const listen = async () => {
|
|
3847
3948
|
registerCommands(commandMap);
|
|
3848
|
-
const rpc = await
|
|
3949
|
+
const rpc = await create$3({
|
|
3849
3950
|
commandMap: commandMap
|
|
3850
3951
|
});
|
|
3851
3952
|
set$2(rpc);
|