@lvce-editor/extension-search-view 7.3.0 → 7.5.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 -339
- 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
|
-
|
|
1175
|
+
diff(uid, modules, numbers) {
|
|
1176
|
+
const {
|
|
1198
1177
|
oldState,
|
|
1199
|
-
|
|
1200
|
-
};
|
|
1178
|
+
scheduledState
|
|
1179
|
+
} = states[uid];
|
|
1180
|
+
const diffResult = [];
|
|
1181
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1182
|
+
const fn = modules[i];
|
|
1183
|
+
if (!fn(oldState, scheduledState)) {
|
|
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
|
-
return Object.keys(states).map(
|
|
1207
|
-
return Number.parseInt(key);
|
|
1208
|
-
});
|
|
1201
|
+
return Object.keys(states).map(Number);
|
|
1209
1202
|
},
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1203
|
+
registerCommands(commandMap) {
|
|
1204
|
+
Object.assign(commandMapRef, commandMap);
|
|
1205
|
+
},
|
|
1206
|
+
set(uid, oldState, newState, scheduledState) {
|
|
1207
|
+
states[uid] = {
|
|
1208
|
+
newState,
|
|
1209
|
+
oldState,
|
|
1210
|
+
scheduledState: scheduledState ?? newState
|
|
1211
|
+
};
|
|
1214
1212
|
},
|
|
1215
1213
|
wrapCommand(fn) {
|
|
1216
1214
|
const wrapped = async (uid, ...args) => {
|
|
1217
1215
|
const {
|
|
1218
|
-
|
|
1219
|
-
|
|
1216
|
+
newState,
|
|
1217
|
+
oldState
|
|
1220
1218
|
} = states[uid];
|
|
1221
1219
|
const newerState = await fn(newState, ...args);
|
|
1222
1220
|
if (oldState === newerState || newState === newerState) {
|
|
1223
1221
|
return;
|
|
1224
1222
|
}
|
|
1225
|
-
const
|
|
1223
|
+
const latestOld = states[uid];
|
|
1224
|
+
const latestNew = {
|
|
1225
|
+
...latestOld.newState,
|
|
1226
|
+
...newerState
|
|
1227
|
+
};
|
|
1226
1228
|
states[uid] = {
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
+
newState: latestNew,
|
|
1230
|
+
oldState: latestOld.oldState,
|
|
1231
|
+
scheduledState: latestNew
|
|
1229
1232
|
};
|
|
1230
1233
|
};
|
|
1231
1234
|
return wrapped;
|
|
@@ -1239,27 +1242,37 @@ 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
|
+
scheduledState: latestNew
|
|
1270
|
+
};
|
|
1271
|
+
return {
|
|
1272
|
+
error
|
|
1273
|
+
};
|
|
1274
|
+
};
|
|
1275
|
+
return wrapped;
|
|
1263
1276
|
}
|
|
1264
1277
|
};
|
|
1265
1278
|
};
|
|
@@ -1355,19 +1368,19 @@ const extensions = () => {
|
|
|
1355
1368
|
const clearExtensionSearchResults = () => {
|
|
1356
1369
|
return i18nString(ClearExtensionSearchResults);
|
|
1357
1370
|
};
|
|
1358
|
-
const enable = () => {
|
|
1371
|
+
const enable$1 = () => {
|
|
1359
1372
|
return i18nString(Enable);
|
|
1360
1373
|
};
|
|
1361
|
-
const disable = () => {
|
|
1374
|
+
const disable$1 = () => {
|
|
1362
1375
|
return i18nString(Disable);
|
|
1363
1376
|
};
|
|
1364
|
-
const enableWorkspace = () => {
|
|
1377
|
+
const enableWorkspace$1 = () => {
|
|
1365
1378
|
return i18nString(EnableWorkspace);
|
|
1366
1379
|
};
|
|
1367
|
-
const disableWorkspace = () => {
|
|
1380
|
+
const disableWorkspace$1 = () => {
|
|
1368
1381
|
return i18nString(DisableWorkspace);
|
|
1369
1382
|
};
|
|
1370
|
-
const installAnotherVersion = () => {
|
|
1383
|
+
const installAnotherVersion$1 = () => {
|
|
1371
1384
|
return i18nString(InstallAnotherVersion);
|
|
1372
1385
|
};
|
|
1373
1386
|
const copy = () => {
|
|
@@ -1619,12 +1632,31 @@ const matchesParsedValue = (extension, parsedValue) => {
|
|
|
1619
1632
|
return false;
|
|
1620
1633
|
};
|
|
1621
1634
|
|
|
1635
|
+
const compareSize = (extensionA, extensionB) => {
|
|
1636
|
+
// Sort by size descending (larger sizes first)
|
|
1637
|
+
return extensionB.size - extensionA.size;
|
|
1638
|
+
};
|
|
1639
|
+
const compareUpdatedDate = (extensionA, extensionB) => {
|
|
1640
|
+
// Sort by updated date descending (newer first)
|
|
1641
|
+
return extensionB.updatedDate - extensionA.updatedDate;
|
|
1642
|
+
};
|
|
1622
1643
|
const compareExtension = (extensionA, extensionB) => {
|
|
1623
1644
|
return extensionA.name.localeCompare(extensionB.name) || extensionA.id.localeCompare(extensionB.id);
|
|
1624
1645
|
};
|
|
1625
1646
|
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1647
|
+
const getCompareFn = sort => {
|
|
1648
|
+
if (sort === 'size') {
|
|
1649
|
+
return compareSize;
|
|
1650
|
+
}
|
|
1651
|
+
if (sort === 'updatedDate') {
|
|
1652
|
+
return compareUpdatedDate;
|
|
1653
|
+
}
|
|
1654
|
+
// Default to comparing by name and id
|
|
1655
|
+
return compareExtension;
|
|
1656
|
+
};
|
|
1657
|
+
const sortExtensions = (extensions, parsedValue) => {
|
|
1658
|
+
const compareFn = getCompareFn(parsedValue?.sort || '');
|
|
1659
|
+
return extensions.toSorted(compareFn);
|
|
1628
1660
|
};
|
|
1629
1661
|
|
|
1630
1662
|
const getExtensions = async (extensions, parsedValue) => {
|
|
@@ -1634,7 +1666,7 @@ const getExtensions = async (extensions, parsedValue) => {
|
|
|
1634
1666
|
filteredExtensions.push(extension);
|
|
1635
1667
|
}
|
|
1636
1668
|
}
|
|
1637
|
-
const sortedExtensions = sortExtensions(filteredExtensions);
|
|
1669
|
+
const sortedExtensions = sortExtensions(filteredExtensions, parsedValue);
|
|
1638
1670
|
return sortedExtensions;
|
|
1639
1671
|
};
|
|
1640
1672
|
|
|
@@ -1692,13 +1724,14 @@ const handleChange = async (state, update) => {
|
|
|
1692
1724
|
};
|
|
1693
1725
|
}
|
|
1694
1726
|
const total = items.length;
|
|
1695
|
-
const
|
|
1727
|
+
const availableHeight = height - headerHeight;
|
|
1728
|
+
const listHeight = getListHeight(total, itemHeight, availableHeight);
|
|
1696
1729
|
const contentHeight = total * itemHeight;
|
|
1697
|
-
const scrollBarHeight = getScrollBarSize(
|
|
1730
|
+
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
1698
1731
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
1699
1732
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
1700
1733
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
1701
|
-
const scrollBarY = getScrollBarY$1(0, finalDeltaY,
|
|
1734
|
+
const scrollBarY = getScrollBarY$1(0, finalDeltaY, listHeight, scrollBarHeight);
|
|
1702
1735
|
return {
|
|
1703
1736
|
...state,
|
|
1704
1737
|
allExtensions,
|
|
@@ -1723,7 +1756,7 @@ const handleChange = async (state, update) => {
|
|
|
1723
1756
|
await handleError(error);
|
|
1724
1757
|
return {
|
|
1725
1758
|
...fullNewState,
|
|
1726
|
-
message:
|
|
1759
|
+
message: error instanceof Error ? error.message : String(error)
|
|
1727
1760
|
};
|
|
1728
1761
|
}
|
|
1729
1762
|
};
|
|
@@ -1865,7 +1898,7 @@ const create = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1865
1898
|
};
|
|
1866
1899
|
|
|
1867
1900
|
const isEqual$3 = (oldState, newState) => {
|
|
1868
|
-
return
|
|
1901
|
+
return oldState.scrollBarHeight === newState.scrollBarHeight && oldState.scrollBarY === newState.scrollBarY && oldState.initial === newState.initial && oldState.deltaY === newState.deltaY;
|
|
1869
1902
|
};
|
|
1870
1903
|
|
|
1871
1904
|
const isEqual$2 = (oldState, newState) => {
|
|
@@ -1903,10 +1936,30 @@ const diff2 = uid => {
|
|
|
1903
1936
|
return diff(uid, modules, numbers);
|
|
1904
1937
|
};
|
|
1905
1938
|
|
|
1939
|
+
const disable = async (state, _id) => {
|
|
1940
|
+
await confirm('not implemented');
|
|
1941
|
+
return state;
|
|
1942
|
+
};
|
|
1943
|
+
|
|
1944
|
+
const disableWorkspace = async (state, _id) => {
|
|
1945
|
+
await confirm('not implemented');
|
|
1946
|
+
return state;
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1906
1949
|
const dispose = uid => {
|
|
1907
1950
|
dispose$1(uid);
|
|
1908
1951
|
};
|
|
1909
1952
|
|
|
1953
|
+
const enable = async (state, _id) => {
|
|
1954
|
+
await confirm('not implemented');
|
|
1955
|
+
return state;
|
|
1956
|
+
};
|
|
1957
|
+
|
|
1958
|
+
const enableWorkspace = async (state, _id) => {
|
|
1959
|
+
await confirm('not implemented');
|
|
1960
|
+
return state;
|
|
1961
|
+
};
|
|
1962
|
+
|
|
1910
1963
|
// TODO optimize this function to return the minimum number
|
|
1911
1964
|
// of visible items needed, e.g. when not scrolled 5 items with
|
|
1912
1965
|
// 20px fill 100px but when scrolled 6 items are needed
|
|
@@ -2153,17 +2206,17 @@ const Separator = 1;
|
|
|
2153
2206
|
const None$1 = 0;
|
|
2154
2207
|
const SubMenu = 4;
|
|
2155
2208
|
|
|
2156
|
-
const
|
|
2209
|
+
const getMenuEntriesList = () => {
|
|
2157
2210
|
return [{
|
|
2158
2211
|
command: 'SearchExtensions.enable',
|
|
2159
2212
|
flags: None$1,
|
|
2160
2213
|
id: 'enable',
|
|
2161
|
-
label: enable()
|
|
2214
|
+
label: enable$1()
|
|
2162
2215
|
}, {
|
|
2163
2216
|
command: 'SearchExtensions.enableWorkspace',
|
|
2164
2217
|
flags: None$1,
|
|
2165
2218
|
id: 'enableWorkspace',
|
|
2166
|
-
label: enableWorkspace()
|
|
2219
|
+
label: enableWorkspace$1()
|
|
2167
2220
|
}, {
|
|
2168
2221
|
command: '',
|
|
2169
2222
|
flags: Separator,
|
|
@@ -2173,12 +2226,12 @@ const getMenuEntries = () => {
|
|
|
2173
2226
|
command: 'SearchExtensions.disable',
|
|
2174
2227
|
flags: None$1,
|
|
2175
2228
|
id: 'disable',
|
|
2176
|
-
label: disable()
|
|
2229
|
+
label: disable$1()
|
|
2177
2230
|
}, {
|
|
2178
2231
|
command: 'SearchExtensions.disableWorkspace',
|
|
2179
2232
|
flags: None$1,
|
|
2180
2233
|
id: 'disableWorkspace',
|
|
2181
|
-
label: disableWorkspace()
|
|
2234
|
+
label: disableWorkspace$1()
|
|
2182
2235
|
}, {
|
|
2183
2236
|
command: '',
|
|
2184
2237
|
flags: Separator,
|
|
@@ -2188,7 +2241,7 @@ const getMenuEntries = () => {
|
|
|
2188
2241
|
command: 'SearchExtensions.installAnotherVersion',
|
|
2189
2242
|
flags: None$1,
|
|
2190
2243
|
id: 'installAnotherVersion',
|
|
2191
|
-
label: installAnotherVersion()
|
|
2244
|
+
label: installAnotherVersion$1()
|
|
2192
2245
|
}, {
|
|
2193
2246
|
command: 'Extensions.copyExtensionInfo',
|
|
2194
2247
|
flags: None$1,
|
|
@@ -2289,7 +2342,7 @@ const getMenuEntries2 = (state, props) => {
|
|
|
2289
2342
|
case ExtensionSearchFilter:
|
|
2290
2343
|
return getMenuEntriesFilter();
|
|
2291
2344
|
default:
|
|
2292
|
-
return
|
|
2345
|
+
return getMenuEntriesList();
|
|
2293
2346
|
}
|
|
2294
2347
|
};
|
|
2295
2348
|
|
|
@@ -2357,6 +2410,7 @@ const NavigateChild = 7;
|
|
|
2357
2410
|
const NavigateParent = 8;
|
|
2358
2411
|
const RemoveChild = 9;
|
|
2359
2412
|
const NavigateSibling = 10;
|
|
2413
|
+
const SetReferenceNodeUid = 11;
|
|
2360
2414
|
|
|
2361
2415
|
const isKey = key => {
|
|
2362
2416
|
return key !== 'type' && key !== 'childCount';
|
|
@@ -2418,12 +2472,22 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
2418
2472
|
};
|
|
2419
2473
|
|
|
2420
2474
|
const compareNodes = (oldNode, newNode) => {
|
|
2421
|
-
const patches = [];
|
|
2422
2475
|
// Check if node type changed - return null to signal incompatible nodes
|
|
2423
2476
|
// (caller should handle this with a Replace operation)
|
|
2424
2477
|
if (oldNode.type !== newNode.type) {
|
|
2425
2478
|
return null;
|
|
2426
2479
|
}
|
|
2480
|
+
const patches = [];
|
|
2481
|
+
// Handle reference nodes - special handling for uid changes
|
|
2482
|
+
if (oldNode.type === Reference) {
|
|
2483
|
+
if (oldNode.uid !== newNode.uid) {
|
|
2484
|
+
patches.push({
|
|
2485
|
+
type: SetReferenceNodeUid,
|
|
2486
|
+
uid: newNode.uid
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
return patches;
|
|
2490
|
+
}
|
|
2427
2491
|
// Handle text nodes
|
|
2428
2492
|
if (oldNode.type === Text && newNode.type === Text) {
|
|
2429
2493
|
if (oldNode.text !== newNode.text) {
|
|
@@ -2449,7 +2513,7 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
2449
2513
|
}
|
|
2450
2514
|
// Check for removed attributes
|
|
2451
2515
|
for (const key of oldKeys) {
|
|
2452
|
-
if (!(key
|
|
2516
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
2453
2517
|
patches.push({
|
|
2454
2518
|
type: RemoveAttribute,
|
|
2455
2519
|
key
|
|
@@ -2467,11 +2531,78 @@ const treeToArray = node => {
|
|
|
2467
2531
|
return result;
|
|
2468
2532
|
};
|
|
2469
2533
|
|
|
2534
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
2535
|
+
if (currentChildIndex === -1) {
|
|
2536
|
+
patches.push({
|
|
2537
|
+
type: NavigateChild,
|
|
2538
|
+
index
|
|
2539
|
+
});
|
|
2540
|
+
return index;
|
|
2541
|
+
}
|
|
2542
|
+
if (currentChildIndex !== index) {
|
|
2543
|
+
patches.push({
|
|
2544
|
+
type: NavigateSibling,
|
|
2545
|
+
index
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2548
|
+
return index;
|
|
2549
|
+
};
|
|
2550
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
2551
|
+
if (currentChildIndex >= 0) {
|
|
2552
|
+
patches.push({
|
|
2553
|
+
type: NavigateParent
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2556
|
+
return -1;
|
|
2557
|
+
};
|
|
2558
|
+
const addTree = (newNode, patches) => {
|
|
2559
|
+
patches.push({
|
|
2560
|
+
type: Add,
|
|
2561
|
+
nodes: treeToArray(newNode)
|
|
2562
|
+
});
|
|
2563
|
+
};
|
|
2564
|
+
const replaceTree = (newNode, patches) => {
|
|
2565
|
+
patches.push({
|
|
2566
|
+
type: Replace,
|
|
2567
|
+
nodes: treeToArray(newNode)
|
|
2568
|
+
});
|
|
2569
|
+
};
|
|
2570
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
2571
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2572
|
+
if (nodePatches === null) {
|
|
2573
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2574
|
+
replaceTree(newNode, patches);
|
|
2575
|
+
return nextChildIndex;
|
|
2576
|
+
}
|
|
2577
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2578
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
2579
|
+
return currentChildIndex;
|
|
2580
|
+
}
|
|
2581
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2582
|
+
if (nodePatches.length > 0) {
|
|
2583
|
+
patches.push(...nodePatches);
|
|
2584
|
+
}
|
|
2585
|
+
if (hasChildrenToCompare) {
|
|
2586
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2587
|
+
}
|
|
2588
|
+
return nextChildIndex;
|
|
2589
|
+
};
|
|
2590
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
2591
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2592
|
+
if (nodePatches === null) {
|
|
2593
|
+
replaceTree(newNode, patches);
|
|
2594
|
+
return;
|
|
2595
|
+
}
|
|
2596
|
+
if (nodePatches.length > 0) {
|
|
2597
|
+
patches.push(...nodePatches);
|
|
2598
|
+
}
|
|
2599
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2600
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2601
|
+
}
|
|
2602
|
+
};
|
|
2470
2603
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
2471
2604
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
2472
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
2473
2605
|
let currentChildIndex = -1;
|
|
2474
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
2475
2606
|
const indicesToRemove = [];
|
|
2476
2607
|
for (let i = 0; i < maxLength; i++) {
|
|
2477
2608
|
const oldNode = oldChildren[i];
|
|
@@ -2480,89 +2611,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2480
2611
|
continue;
|
|
2481
2612
|
}
|
|
2482
2613
|
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
|
|
2614
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
2615
|
+
addTree(newNode, patches);
|
|
2616
|
+
continue;
|
|
2617
|
+
}
|
|
2618
|
+
if (!newNode) {
|
|
2554
2619
|
indicesToRemove.push(i);
|
|
2620
|
+
continue;
|
|
2555
2621
|
}
|
|
2622
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
2556
2623
|
}
|
|
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
|
|
2624
|
+
navigateToParent(patches, currentChildIndex);
|
|
2566
2625
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2567
2626
|
patches.push({
|
|
2568
2627
|
type: RemoveChild,
|
|
@@ -2571,33 +2630,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2571
2630
|
}
|
|
2572
2631
|
};
|
|
2573
2632
|
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
2633
|
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);
|
|
2634
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
2635
|
+
return;
|
|
2600
2636
|
}
|
|
2637
|
+
diffChildren(oldTree, newTree, patches);
|
|
2601
2638
|
};
|
|
2602
2639
|
|
|
2603
2640
|
const removeTrailingNavigationPatches = patches => {
|
|
@@ -2673,8 +2710,9 @@ const handleClickFilter = async state => {
|
|
|
2673
2710
|
x,
|
|
2674
2711
|
y
|
|
2675
2712
|
} = state;
|
|
2676
|
-
const menuX = x + width +
|
|
2677
|
-
const
|
|
2713
|
+
const menuX = x + width + 60;
|
|
2714
|
+
const menuHeight = 370;
|
|
2715
|
+
const menuY = y + headerHeight + menuHeight;
|
|
2678
2716
|
await show2(uid, ExtensionSearchFilter, menuX, menuY, {
|
|
2679
2717
|
menuId: ExtensionSearchFilter
|
|
2680
2718
|
});
|
|
@@ -2874,6 +2912,33 @@ const handleScrollBarMove = (state, eventY) => {
|
|
|
2874
2912
|
return setDeltaY(state, newDeltaY);
|
|
2875
2913
|
};
|
|
2876
2914
|
|
|
2915
|
+
const handleSettingsButtonClick = async (state, index) => {
|
|
2916
|
+
const {
|
|
2917
|
+
deltaY,
|
|
2918
|
+
headerHeight,
|
|
2919
|
+
itemHeight,
|
|
2920
|
+
items,
|
|
2921
|
+
uid,
|
|
2922
|
+
x,
|
|
2923
|
+
y
|
|
2924
|
+
} = state;
|
|
2925
|
+
const actualIndex = index;
|
|
2926
|
+
if (actualIndex < 0 || actualIndex >= items.length) {
|
|
2927
|
+
return state;
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
// Calculate the position for the context menu
|
|
2931
|
+
// The settings button is at the bottom right of the extension list item
|
|
2932
|
+
const itemY = y + headerHeight + actualIndex * itemHeight - deltaY;
|
|
2933
|
+
const menuX = x + 200; // Position near the right side of the extension item
|
|
2934
|
+
const menuY = itemY + itemHeight - 10; // Position at the bottom of the extension item
|
|
2935
|
+
|
|
2936
|
+
await show2(uid, ManageExtension, menuX, menuY, {
|
|
2937
|
+
menuId: ManageExtension
|
|
2938
|
+
});
|
|
2939
|
+
return state;
|
|
2940
|
+
};
|
|
2941
|
+
|
|
2877
2942
|
// TODO show error / warning when installment fails / times out
|
|
2878
2943
|
const handleUninstall = async (state, id) => {
|
|
2879
2944
|
return state;
|
|
@@ -2891,7 +2956,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
|
|
|
2891
2956
|
|
|
2892
2957
|
const createExtensionHostWorkerRpc = async () => {
|
|
2893
2958
|
try {
|
|
2894
|
-
const rpc = await
|
|
2959
|
+
const rpc = await create$4({
|
|
2895
2960
|
commandMap: {},
|
|
2896
2961
|
send: sendMessagePortToExtensionHostWorker
|
|
2897
2962
|
});
|
|
@@ -2913,7 +2978,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
2913
2978
|
|
|
2914
2979
|
const createExtensionManagementWorkerRpc = async () => {
|
|
2915
2980
|
try {
|
|
2916
|
-
const rpc = await
|
|
2981
|
+
const rpc = await create$4({
|
|
2917
2982
|
commandMap: {},
|
|
2918
2983
|
send: port => sendMessagePortToExtensionManagementWorker(port, 0)
|
|
2919
2984
|
});
|
|
@@ -2936,6 +3001,11 @@ const initialize = async () => {
|
|
|
2936
3001
|
await Promise.all([initializeExtensionHostWorker(), initializeExtensionManagementWorker()]);
|
|
2937
3002
|
};
|
|
2938
3003
|
|
|
3004
|
+
const installAnotherVersion = async state => {
|
|
3005
|
+
await confirm('not implemented');
|
|
3006
|
+
return state;
|
|
3007
|
+
};
|
|
3008
|
+
|
|
2939
3009
|
const Web = 1;
|
|
2940
3010
|
const Electron = 2;
|
|
2941
3011
|
const Remote = 3;
|
|
@@ -3040,6 +3110,18 @@ const getId$1 = extension => {
|
|
|
3040
3110
|
}
|
|
3041
3111
|
return extension.id;
|
|
3042
3112
|
};
|
|
3113
|
+
const getSize = extension => {
|
|
3114
|
+
if (!extension || extension.size === 0 || typeof extension.size !== 'number') {
|
|
3115
|
+
return 0;
|
|
3116
|
+
}
|
|
3117
|
+
return extension.size;
|
|
3118
|
+
};
|
|
3119
|
+
const getUpdatedDate = extension => {
|
|
3120
|
+
if (!extension || !extension.updatedDate || typeof extension.updatedDate !== 'number') {
|
|
3121
|
+
return 0;
|
|
3122
|
+
}
|
|
3123
|
+
return extension.updatedDate;
|
|
3124
|
+
};
|
|
3043
3125
|
const isString = item => {
|
|
3044
3126
|
return typeof item === 'string';
|
|
3045
3127
|
};
|
|
@@ -3065,7 +3147,7 @@ const getPublisher = extension => {
|
|
|
3065
3147
|
return match[0];
|
|
3066
3148
|
};
|
|
3067
3149
|
|
|
3068
|
-
const normalizeExtension
|
|
3150
|
+
const normalizeExtension = (extension, platform, assetDir) => {
|
|
3069
3151
|
return {
|
|
3070
3152
|
categories: getCategories(extension),
|
|
3071
3153
|
description: getDescription(extension),
|
|
@@ -3073,16 +3155,14 @@ const normalizeExtension$1 = (extension, platform, assetDir) => {
|
|
|
3073
3155
|
id: getId$1(extension),
|
|
3074
3156
|
name: getName(extension),
|
|
3075
3157
|
publisher: getPublisher(extension),
|
|
3158
|
+
size: getSize(extension),
|
|
3159
|
+
updatedDate: getUpdatedDate(extension),
|
|
3076
3160
|
uri: ''
|
|
3077
3161
|
};
|
|
3078
3162
|
};
|
|
3079
3163
|
|
|
3080
|
-
const
|
|
3081
|
-
|
|
3082
|
-
for (const extension of extensions) {
|
|
3083
|
-
normalized.push(normalizeExtension$1(extension, platform, assetDir));
|
|
3084
|
-
}
|
|
3085
|
-
return normalized;
|
|
3164
|
+
const normalizeExtensions = (extensions, platform, assetDir) => {
|
|
3165
|
+
return Array.from(extensions, extension => normalizeExtension(extension, platform, assetDir));
|
|
3086
3166
|
};
|
|
3087
3167
|
|
|
3088
3168
|
const getSavedValue = savedState => {
|
|
@@ -3120,7 +3200,7 @@ const loadContent = async (state, savedState) => {
|
|
|
3120
3200
|
// TODO just get local extensions on demand (not when query string is already different)
|
|
3121
3201
|
const allExtensions = await getAllExtensions(platform);
|
|
3122
3202
|
const size = getViewletSize(width);
|
|
3123
|
-
const normalized =
|
|
3203
|
+
const normalized = normalizeExtensions(allExtensions, platform, assetDir);
|
|
3124
3204
|
const updatedState = await handleInput({
|
|
3125
3205
|
...state,
|
|
3126
3206
|
allExtensions: normalized,
|
|
@@ -3150,11 +3230,22 @@ const getCss = state => {
|
|
|
3150
3230
|
translate: 0 ${roundedScrollBarY}px;
|
|
3151
3231
|
}
|
|
3152
3232
|
|
|
3153
|
-
|
|
3154
|
-
|
|
3233
|
+
|
|
3234
|
+
/* TODO: avoid using negative margin. find a better way*/
|
|
3235
|
+
.ExtensionListItem:nth-child(1) {
|
|
3236
|
+
margin-top: ${relative}px;
|
|
3237
|
+
}
|
|
3155
3238
|
|
|
3156
3239
|
.ExtensionListItem {
|
|
3157
3240
|
position: relative !important;
|
|
3241
|
+
flex-shrink: 0;
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3244
|
+
.Extensions .ListItems {
|
|
3245
|
+
display: flex;
|
|
3246
|
+
flex-direction: column;
|
|
3247
|
+
gap: 0;
|
|
3248
|
+
overflow-y: hidden;
|
|
3158
3249
|
}
|
|
3159
3250
|
`;
|
|
3160
3251
|
};
|
|
@@ -3433,9 +3524,6 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
3433
3524
|
if (!shouldShowScrollbar) {
|
|
3434
3525
|
return [];
|
|
3435
3526
|
}
|
|
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
3527
|
return [{
|
|
3440
3528
|
childCount: 1,
|
|
3441
3529
|
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
@@ -3445,8 +3533,6 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
3445
3533
|
}, {
|
|
3446
3534
|
childCount: 0,
|
|
3447
3535
|
className: ScrollBarThumb,
|
|
3448
|
-
// height: heightString,
|
|
3449
|
-
// translate: translateString,
|
|
3450
3536
|
type: Div
|
|
3451
3537
|
}];
|
|
3452
3538
|
};
|
|
@@ -3465,6 +3551,7 @@ const getVisibleItem = (item, setSize, itemHeight, minLineY, relative, i, focuse
|
|
|
3465
3551
|
focused: i === focusedIndex,
|
|
3466
3552
|
icon,
|
|
3467
3553
|
id,
|
|
3554
|
+
index: i,
|
|
3468
3555
|
name,
|
|
3469
3556
|
posInSet: i + 1,
|
|
3470
3557
|
publisher,
|
|
@@ -3558,11 +3645,12 @@ const position = (x, y) => {
|
|
|
3558
3645
|
};
|
|
3559
3646
|
|
|
3560
3647
|
const renderScrollBar = newState => {
|
|
3561
|
-
const
|
|
3648
|
+
const availableHeight = newState.height - newState.headerHeight;
|
|
3649
|
+
const listHeight = getListHeight(newState.items.length, newState.itemHeight, availableHeight);
|
|
3562
3650
|
const total = newState.items.length;
|
|
3563
3651
|
const contentHeight = total * newState.itemHeight;
|
|
3564
3652
|
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, newState.minimumSliderSize);
|
|
3565
|
-
const scrollBarY = getScrollBarY$1(newState.deltaY, newState.finalDeltaY,
|
|
3653
|
+
const scrollBarY = getScrollBarY$1(newState.deltaY, newState.finalDeltaY, listHeight, scrollBarHeight);
|
|
3566
3654
|
const roundedScrollBarY = Math.round(scrollBarY);
|
|
3567
3655
|
const heightString = px(scrollBarHeight);
|
|
3568
3656
|
const translateString = position(0, roundedScrollBarY);
|
|
@@ -3722,6 +3810,7 @@ const renderEventListeners = () => {
|
|
|
3722
3810
|
|
|
3723
3811
|
const resize = async (state, dimensions) => {
|
|
3724
3812
|
const {
|
|
3813
|
+
deltaY,
|
|
3725
3814
|
headerHeight,
|
|
3726
3815
|
itemHeight,
|
|
3727
3816
|
items,
|
|
@@ -3734,18 +3823,21 @@ const resize = async (state, dimensions) => {
|
|
|
3734
3823
|
y
|
|
3735
3824
|
} = dimensions;
|
|
3736
3825
|
const total = items.length;
|
|
3737
|
-
const
|
|
3826
|
+
const availableHeight = height - headerHeight;
|
|
3827
|
+
const listHeight = getListHeight(total, itemHeight, availableHeight);
|
|
3738
3828
|
const contentHeight = total * itemHeight;
|
|
3739
|
-
const scrollBarHeight = getScrollBarSize(
|
|
3829
|
+
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
3740
3830
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
3741
|
-
const
|
|
3831
|
+
const minLineY = Math.floor(deltaY / itemHeight);
|
|
3832
|
+
const maxLineY = Math.min(minLineY + numberOfVisible, total);
|
|
3742
3833
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
3743
|
-
const scrollBarY = getScrollBarY$1(
|
|
3834
|
+
const scrollBarY = getScrollBarY$1(deltaY, finalDeltaY, listHeight, scrollBarHeight);
|
|
3744
3835
|
return {
|
|
3745
3836
|
...state,
|
|
3746
3837
|
finalDeltaY,
|
|
3747
3838
|
height,
|
|
3748
3839
|
maxLineY,
|
|
3840
|
+
minLineY,
|
|
3749
3841
|
scrollBarHeight,
|
|
3750
3842
|
scrollBarY,
|
|
3751
3843
|
width,
|
|
@@ -3789,17 +3881,19 @@ const toggleSuggest = state => {
|
|
|
3789
3881
|
};
|
|
3790
3882
|
|
|
3791
3883
|
const commandMap = {
|
|
3884
|
+
'Extensions.copyExtensionId': wrapCommand(copyExtensionId),
|
|
3885
|
+
'Extensions.copyExtensionInfo': wrapCommand(copyExtensionInfo),
|
|
3792
3886
|
'SearchExtensions.clearSearchResults': wrapCommand(clearSearchResults),
|
|
3793
3887
|
'SearchExtensions.closeSuggest': wrapCommand(closeSuggest),
|
|
3794
3888
|
'SearchExtensions.copyExtensionId': wrapCommand(copyExtensionId),
|
|
3795
3889
|
'SearchExtensions.copyExtensionInfo': wrapCommand(copyExtensionInfo),
|
|
3796
3890
|
'SearchExtensions.create': create,
|
|
3797
3891
|
'SearchExtensions.diff2': diff2,
|
|
3798
|
-
'SearchExtensions.disable': wrapCommand(
|
|
3799
|
-
'SearchExtensions.disableWorkspace': wrapCommand(
|
|
3892
|
+
'SearchExtensions.disable': wrapCommand(disable),
|
|
3893
|
+
'SearchExtensions.disableWorkspace': wrapCommand(disableWorkspace),
|
|
3800
3894
|
'SearchExtensions.dispose': dispose,
|
|
3801
|
-
'SearchExtensions.enable': wrapCommand(
|
|
3802
|
-
'SearchExtensions.enableWorkspace': wrapCommand(
|
|
3895
|
+
'SearchExtensions.enable': wrapCommand(enable),
|
|
3896
|
+
'SearchExtensions.enableWorkspace': wrapCommand(enableWorkspace),
|
|
3803
3897
|
'SearchExtensions.focusFirst': wrapCommand(focusFirst),
|
|
3804
3898
|
'SearchExtensions.focusIndex': wrapCommand(focusIndex),
|
|
3805
3899
|
'SearchExtensions.focusLast': wrapCommand(focusLast),
|
|
@@ -3810,7 +3904,7 @@ const commandMap = {
|
|
|
3810
3904
|
'SearchExtensions.getActions': getActions,
|
|
3811
3905
|
'SearchExtensions.getCommandIds': getCommandIds,
|
|
3812
3906
|
'SearchExtensions.getKeyBindings': getKeyBindings,
|
|
3813
|
-
'SearchExtensions.getMenuEntries':
|
|
3907
|
+
'SearchExtensions.getMenuEntries': getMenuEntriesList,
|
|
3814
3908
|
'SearchExtensions.getMenuEntries2': wrapGetter(getMenuEntries2),
|
|
3815
3909
|
'SearchExtensions.getMenuEntriesFilter': getMenuEntriesFilter,
|
|
3816
3910
|
'SearchExtensions.getMenuIds': getMenuIds,
|
|
@@ -3833,9 +3927,11 @@ const commandMap = {
|
|
|
3833
3927
|
'SearchExtensions.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
3834
3928
|
'SearchExtensions.handleScrollBarMove': wrapCommand(handleScrollBarMove),
|
|
3835
3929
|
'SearchExtensions.handleScrollBarThumbPointerMove': wrapCommand(handleScrollBarMove),
|
|
3930
|
+
'SearchExtensions.handleSettingsButtonClick': wrapCommand(handleSettingsButtonClick),
|
|
3836
3931
|
'SearchExtensions.handleUninstall': wrapCommand(handleUninstall),
|
|
3837
3932
|
'SearchExtensions.handleWheel': wrapCommand(handleWheel),
|
|
3838
3933
|
'SearchExtensions.initialize': initialize,
|
|
3934
|
+
'SearchExtensions.installAnotherVersion': wrapCommand(installAnotherVersion),
|
|
3839
3935
|
'SearchExtensions.loadContent': wrapCommand(loadContent),
|
|
3840
3936
|
'SearchExtensions.openSuggest': wrapCommand(openSuggest),
|
|
3841
3937
|
'SearchExtensions.render3': render3,
|
|
@@ -3854,7 +3950,7 @@ const commandMap = {
|
|
|
3854
3950
|
|
|
3855
3951
|
const listen = async () => {
|
|
3856
3952
|
registerCommands(commandMap);
|
|
3857
|
-
const rpc = await
|
|
3953
|
+
const rpc = await create$3({
|
|
3858
3954
|
commandMap: commandMap
|
|
3859
3955
|
});
|
|
3860
3956
|
set$2(rpc);
|