@lvce-editor/source-control-worker 3.0.0 → 3.2.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/sourceControlWorkerMain.js +597 -327
- 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;
|
|
@@ -98,7 +98,7 @@ const number = value => {
|
|
|
98
98
|
};
|
|
99
99
|
const string = value => {
|
|
100
100
|
const type = getType(value);
|
|
101
|
-
if (type !== String) {
|
|
101
|
+
if (type !== String$1) {
|
|
102
102
|
throw new AssertionError('expected value to be of type string');
|
|
103
103
|
}
|
|
104
104
|
};
|
|
@@ -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$3 = 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$8 = (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$8(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$7 = (method, params) => {
|
|
853
854
|
return {
|
|
854
855
|
jsonrpc: Two,
|
|
855
856
|
method,
|
|
856
857
|
params
|
|
857
858
|
};
|
|
858
859
|
};
|
|
859
|
-
|
|
860
|
+
|
|
861
|
+
const create$6 = (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 = 0;
|
|
869
|
-
const create$
|
|
872
|
+
const create$5 = () => {
|
|
870
873
|
return ++id;
|
|
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$5();
|
|
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$6(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$7(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,6 +966,7 @@ const listen$1 = async (module, options) => {
|
|
|
963
966
|
const ipc = module.wrap(rawIpc);
|
|
964
967
|
return ipc;
|
|
965
968
|
};
|
|
969
|
+
|
|
966
970
|
const create$4 = async ({
|
|
967
971
|
commandMap,
|
|
968
972
|
isMessagePortOpen = true,
|
|
@@ -980,11 +984,8 @@ const create$4 = async ({
|
|
|
980
984
|
messagePort.start();
|
|
981
985
|
return rpc;
|
|
982
986
|
};
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
create: create$4
|
|
986
|
-
};
|
|
987
|
-
const create$2 = async ({
|
|
987
|
+
|
|
988
|
+
const create$3 = async ({
|
|
988
989
|
commandMap,
|
|
989
990
|
isMessagePortOpen,
|
|
990
991
|
send
|
|
@@ -1000,11 +1001,8 @@ const create$2 = async ({
|
|
|
1000
1001
|
messagePort: port2
|
|
1001
1002
|
});
|
|
1002
1003
|
};
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
create: create$2
|
|
1006
|
-
};
|
|
1007
|
-
const create$1$1 = async ({
|
|
1004
|
+
|
|
1005
|
+
const create$2 = async ({
|
|
1008
1006
|
commandMap
|
|
1009
1007
|
}) => {
|
|
1010
1008
|
// TODO create a commandMap per rpc instance
|
|
@@ -1014,10 +1012,7 @@ const create$1$1 = async ({
|
|
|
1014
1012
|
const rpc = createRpc(ipc);
|
|
1015
1013
|
return rpc;
|
|
1016
1014
|
};
|
|
1017
|
-
|
|
1018
|
-
__proto__: null,
|
|
1019
|
-
create: create$1$1
|
|
1020
|
-
};
|
|
1015
|
+
|
|
1021
1016
|
const createMockRpc = ({
|
|
1022
1017
|
commandMap
|
|
1023
1018
|
}) => {
|
|
@@ -1038,6 +1033,54 @@ const createMockRpc = ({
|
|
|
1038
1033
|
return mockRpc;
|
|
1039
1034
|
};
|
|
1040
1035
|
|
|
1036
|
+
const rpcs = Object.create(null);
|
|
1037
|
+
const set$5 = (id, rpc) => {
|
|
1038
|
+
rpcs[id] = rpc;
|
|
1039
|
+
};
|
|
1040
|
+
const get$2 = id => {
|
|
1041
|
+
return rpcs[id];
|
|
1042
|
+
};
|
|
1043
|
+
const remove = id => {
|
|
1044
|
+
delete rpcs[id];
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1048
|
+
const create$1 = rpcId => {
|
|
1049
|
+
return {
|
|
1050
|
+
async dispose() {
|
|
1051
|
+
const rpc = get$2(rpcId);
|
|
1052
|
+
await rpc.dispose();
|
|
1053
|
+
},
|
|
1054
|
+
// @ts-ignore
|
|
1055
|
+
invoke(method, ...params) {
|
|
1056
|
+
const rpc = get$2(rpcId);
|
|
1057
|
+
// @ts-ignore
|
|
1058
|
+
return rpc.invoke(method, ...params);
|
|
1059
|
+
},
|
|
1060
|
+
// @ts-ignore
|
|
1061
|
+
invokeAndTransfer(method, ...params) {
|
|
1062
|
+
const rpc = get$2(rpcId);
|
|
1063
|
+
// @ts-ignore
|
|
1064
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1065
|
+
},
|
|
1066
|
+
registerMockRpc(commandMap) {
|
|
1067
|
+
const mockRpc = createMockRpc({
|
|
1068
|
+
commandMap
|
|
1069
|
+
});
|
|
1070
|
+
set$5(rpcId, mockRpc);
|
|
1071
|
+
// @ts-ignore
|
|
1072
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1073
|
+
remove(rpcId);
|
|
1074
|
+
};
|
|
1075
|
+
// @ts-ignore
|
|
1076
|
+
return mockRpc;
|
|
1077
|
+
},
|
|
1078
|
+
set(rpc) {
|
|
1079
|
+
set$5(rpcId, rpc);
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1041
1084
|
const None$1 = 'none';
|
|
1042
1085
|
const ToolBar = 'toolbar';
|
|
1043
1086
|
const Tree$1 = 'tree';
|
|
@@ -1056,6 +1099,7 @@ const Span = 8;
|
|
|
1056
1099
|
const Text = 12;
|
|
1057
1100
|
const Img = 17;
|
|
1058
1101
|
const TextArea = 62;
|
|
1102
|
+
const Reference = 100;
|
|
1059
1103
|
|
|
1060
1104
|
const Button$1 = 'event.button';
|
|
1061
1105
|
const ClientX = 'event.clientX';
|
|
@@ -1076,6 +1120,8 @@ const SourceControl$1 = 22;
|
|
|
1076
1120
|
|
|
1077
1121
|
const None = 0;
|
|
1078
1122
|
|
|
1123
|
+
const Web = 1;
|
|
1124
|
+
|
|
1079
1125
|
const ExtensionHostWorker = 44;
|
|
1080
1126
|
const ExtensionManagementWorker = 9006;
|
|
1081
1127
|
const IconThemeWorker = 7009;
|
|
@@ -1092,54 +1138,6 @@ const Tree = 2;
|
|
|
1092
1138
|
|
|
1093
1139
|
const FocusSourceControlInput = 24;
|
|
1094
1140
|
|
|
1095
|
-
const rpcs = Object.create(null);
|
|
1096
|
-
const set$5 = (id, rpc) => {
|
|
1097
|
-
rpcs[id] = rpc;
|
|
1098
|
-
};
|
|
1099
|
-
const get$2 = id => {
|
|
1100
|
-
return rpcs[id];
|
|
1101
|
-
};
|
|
1102
|
-
const remove = id => {
|
|
1103
|
-
delete rpcs[id];
|
|
1104
|
-
};
|
|
1105
|
-
|
|
1106
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1107
|
-
const create$1 = rpcId => {
|
|
1108
|
-
return {
|
|
1109
|
-
async dispose() {
|
|
1110
|
-
const rpc = get$2(rpcId);
|
|
1111
|
-
await rpc.dispose();
|
|
1112
|
-
},
|
|
1113
|
-
// @ts-ignore
|
|
1114
|
-
invoke(method, ...params) {
|
|
1115
|
-
const rpc = get$2(rpcId);
|
|
1116
|
-
// @ts-ignore
|
|
1117
|
-
return rpc.invoke(method, ...params);
|
|
1118
|
-
},
|
|
1119
|
-
// @ts-ignore
|
|
1120
|
-
invokeAndTransfer(method, ...params) {
|
|
1121
|
-
const rpc = get$2(rpcId);
|
|
1122
|
-
// @ts-ignore
|
|
1123
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1124
|
-
},
|
|
1125
|
-
registerMockRpc(commandMap) {
|
|
1126
|
-
const mockRpc = createMockRpc({
|
|
1127
|
-
commandMap
|
|
1128
|
-
});
|
|
1129
|
-
set$5(rpcId, mockRpc);
|
|
1130
|
-
// @ts-ignore
|
|
1131
|
-
mockRpc[Symbol.dispose] = () => {
|
|
1132
|
-
remove(rpcId);
|
|
1133
|
-
};
|
|
1134
|
-
// @ts-ignore
|
|
1135
|
-
return mockRpc;
|
|
1136
|
-
},
|
|
1137
|
-
set(rpc) {
|
|
1138
|
-
set$5(rpcId, rpc);
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
};
|
|
1142
|
-
|
|
1143
1141
|
const {
|
|
1144
1142
|
invoke: invoke$1,
|
|
1145
1143
|
set: set$4
|
|
@@ -1159,7 +1157,6 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1159
1157
|
number(menuId);
|
|
1160
1158
|
number(x);
|
|
1161
1159
|
number(y);
|
|
1162
|
-
// @ts-ignore
|
|
1163
1160
|
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1164
1161
|
};
|
|
1165
1162
|
const readFile$1 = async uri => {
|
|
@@ -1174,7 +1171,6 @@ const activateByEvent$1 = (event, assetDir, platform) => {
|
|
|
1174
1171
|
};
|
|
1175
1172
|
const sendMessagePortToTextMeasurementWorker$1 = async port => {
|
|
1176
1173
|
const command = 'TextMeasurement.handleMessagePort';
|
|
1177
|
-
// @ts-ignore
|
|
1178
1174
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1179
1175
|
};
|
|
1180
1176
|
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
@@ -1200,42 +1196,68 @@ const create = () => {
|
|
|
1200
1196
|
const states = Object.create(null);
|
|
1201
1197
|
const commandMapRef = {};
|
|
1202
1198
|
return {
|
|
1203
|
-
|
|
1204
|
-
|
|
1199
|
+
clear() {
|
|
1200
|
+
for (const key of Object.keys(states)) {
|
|
1201
|
+
delete states[key];
|
|
1202
|
+
}
|
|
1205
1203
|
},
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
};
|
|
1204
|
+
diff(uid, modules, numbers) {
|
|
1205
|
+
const {
|
|
1206
|
+
newState,
|
|
1207
|
+
oldState
|
|
1208
|
+
} = states[uid];
|
|
1209
|
+
const diffResult = [];
|
|
1210
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1211
|
+
const fn = modules[i];
|
|
1212
|
+
if (!fn(oldState, newState)) {
|
|
1213
|
+
diffResult.push(numbers[i]);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
return diffResult;
|
|
1211
1217
|
},
|
|
1212
1218
|
dispose(uid) {
|
|
1213
1219
|
delete states[uid];
|
|
1214
1220
|
},
|
|
1221
|
+
get(uid) {
|
|
1222
|
+
return states[uid];
|
|
1223
|
+
},
|
|
1224
|
+
getCommandIds() {
|
|
1225
|
+
const keys = Object.keys(commandMapRef);
|
|
1226
|
+
const ids = keys.map(toCommandId);
|
|
1227
|
+
return ids;
|
|
1228
|
+
},
|
|
1215
1229
|
getKeys() {
|
|
1216
1230
|
return Object.keys(states).map(key => {
|
|
1217
|
-
return Number.
|
|
1231
|
+
return Number.parseFloat(key);
|
|
1218
1232
|
});
|
|
1219
1233
|
},
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1234
|
+
registerCommands(commandMap) {
|
|
1235
|
+
Object.assign(commandMapRef, commandMap);
|
|
1236
|
+
},
|
|
1237
|
+
set(uid, oldState, newState) {
|
|
1238
|
+
states[uid] = {
|
|
1239
|
+
newState,
|
|
1240
|
+
oldState
|
|
1241
|
+
};
|
|
1224
1242
|
},
|
|
1225
1243
|
wrapCommand(fn) {
|
|
1226
1244
|
const wrapped = async (uid, ...args) => {
|
|
1227
1245
|
const {
|
|
1228
|
-
|
|
1229
|
-
|
|
1246
|
+
newState,
|
|
1247
|
+
oldState
|
|
1230
1248
|
} = states[uid];
|
|
1231
1249
|
const newerState = await fn(newState, ...args);
|
|
1232
1250
|
if (oldState === newerState || newState === newerState) {
|
|
1233
1251
|
return;
|
|
1234
1252
|
}
|
|
1235
|
-
const
|
|
1253
|
+
const latestOld = states[uid];
|
|
1254
|
+
const latestNew = {
|
|
1255
|
+
...latestOld.newState,
|
|
1256
|
+
...newerState
|
|
1257
|
+
};
|
|
1236
1258
|
states[uid] = {
|
|
1237
|
-
|
|
1238
|
-
|
|
1259
|
+
newState: latestNew,
|
|
1260
|
+
oldState: latestOld.oldState
|
|
1239
1261
|
};
|
|
1240
1262
|
};
|
|
1241
1263
|
return wrapped;
|
|
@@ -1249,27 +1271,36 @@ const create = () => {
|
|
|
1249
1271
|
};
|
|
1250
1272
|
return wrapped;
|
|
1251
1273
|
},
|
|
1252
|
-
|
|
1253
|
-
const {
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
-
|
|
1274
|
+
wrapLoadContent(fn) {
|
|
1275
|
+
const wrapped = async (uid, ...args) => {
|
|
1276
|
+
const {
|
|
1277
|
+
newState,
|
|
1278
|
+
oldState
|
|
1279
|
+
} = states[uid];
|
|
1280
|
+
const result = await fn(newState, ...args);
|
|
1281
|
+
const {
|
|
1282
|
+
error,
|
|
1283
|
+
state
|
|
1284
|
+
} = result;
|
|
1285
|
+
if (oldState === state || newState === state) {
|
|
1286
|
+
return {
|
|
1287
|
+
error
|
|
1288
|
+
};
|
|
1262
1289
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1290
|
+
const latestOld = states[uid];
|
|
1291
|
+
const latestNew = {
|
|
1292
|
+
...latestOld.newState,
|
|
1293
|
+
...state
|
|
1294
|
+
};
|
|
1295
|
+
states[uid] = {
|
|
1296
|
+
newState: latestNew,
|
|
1297
|
+
oldState: latestOld.oldState
|
|
1298
|
+
};
|
|
1299
|
+
return {
|
|
1300
|
+
error
|
|
1301
|
+
};
|
|
1302
|
+
};
|
|
1303
|
+
return wrapped;
|
|
1273
1304
|
}
|
|
1274
1305
|
};
|
|
1275
1306
|
};
|
|
@@ -1312,7 +1343,7 @@ const getDisplayItemsGroup = (group, expandedGroups, iconDefinitions) => {
|
|
|
1312
1343
|
const {
|
|
1313
1344
|
length
|
|
1314
1345
|
} = items;
|
|
1315
|
-
const isExpanded = expandedGroups[id]
|
|
1346
|
+
const isExpanded = expandedGroups[id] ?? false;
|
|
1316
1347
|
const type = isExpanded ? DirectoryExpanded : Directory;
|
|
1317
1348
|
const icon = isExpanded ? 'ChevronDown' : 'ChevronRight';
|
|
1318
1349
|
if (length > 0) {
|
|
@@ -1451,9 +1482,13 @@ const executeProvider = async ({
|
|
|
1451
1482
|
|
|
1452
1483
|
const CommandExecute = 'ExtensionHostCommand.executeCommand';
|
|
1453
1484
|
const SourceControlAcceptInput = 'ExtensionHostSourceControl.acceptInput';
|
|
1485
|
+
const SourceControlGenerateCommitMessage = 'ExtensionHostSourceControl.generateCommitMessage';
|
|
1486
|
+
const SourceControlGetBadgeCount = 'ExtensionHostSourceControl.getBadgeCount';
|
|
1487
|
+
const SourceControlGetChangedFiles = 'ExtensionHost.sourceControlGetChangedFiles';
|
|
1454
1488
|
const SourceControlGetFileDecorations = 'ExtensionHostSourceControl.getFileDecorations';
|
|
1455
1489
|
const SourceControlGetEnabledProviderIds = 'ExtensionHostSourceControl.getEnabledProviderIds';
|
|
1456
1490
|
const SourceControlGetFileBefore = 'ExtensionHostSourceControl.getFileBefore';
|
|
1491
|
+
const SourceControlGetFeatures = 'ExtensionHostSourceControl.getFeatures';
|
|
1457
1492
|
const SourceControlGetGroups = 'ExtensionHostSourceControl.getGroups';
|
|
1458
1493
|
|
|
1459
1494
|
const acceptInput$2 = async (providerId, text, assetDir, platform) => {
|
|
@@ -1466,6 +1501,43 @@ const acceptInput$2 = async (providerId, text, assetDir, platform) => {
|
|
|
1466
1501
|
// noProviderFoundMessage: 'No source control provider found',
|
|
1467
1502
|
});
|
|
1468
1503
|
};
|
|
1504
|
+
const generateCommitMessage$2 = async (providerId, assetDir, platform) => {
|
|
1505
|
+
return executeProvider({
|
|
1506
|
+
assetDir,
|
|
1507
|
+
event: 'none',
|
|
1508
|
+
method: SourceControlGenerateCommitMessage,
|
|
1509
|
+
params: [providerId],
|
|
1510
|
+
platform
|
|
1511
|
+
});
|
|
1512
|
+
};
|
|
1513
|
+
const getFeatures = async (providerId, assetDir, platform) => {
|
|
1514
|
+
return executeProvider({
|
|
1515
|
+
assetDir,
|
|
1516
|
+
event: 'none',
|
|
1517
|
+
method: SourceControlGetFeatures,
|
|
1518
|
+
params: [providerId],
|
|
1519
|
+
platform
|
|
1520
|
+
});
|
|
1521
|
+
};
|
|
1522
|
+
const getChangedFiles = (providerId, assetDir, platform) => {
|
|
1523
|
+
return executeProvider({
|
|
1524
|
+
assetDir,
|
|
1525
|
+
event: 'none',
|
|
1526
|
+
method: SourceControlGetChangedFiles,
|
|
1527
|
+
params: [providerId],
|
|
1528
|
+
platform
|
|
1529
|
+
// noProviderFoundMessage: 'No source control provider found',
|
|
1530
|
+
});
|
|
1531
|
+
};
|
|
1532
|
+
const getBadgeCount$2 = (providerId, assetDir, platform) => {
|
|
1533
|
+
return executeProvider({
|
|
1534
|
+
assetDir,
|
|
1535
|
+
event: 'none',
|
|
1536
|
+
method: SourceControlGetBadgeCount,
|
|
1537
|
+
params: [providerId],
|
|
1538
|
+
platform
|
|
1539
|
+
});
|
|
1540
|
+
};
|
|
1469
1541
|
const getFileDecorations$1 = (providerId, uris, assetDir, platform) => {
|
|
1470
1542
|
string(assetDir);
|
|
1471
1543
|
number(platform);
|
|
@@ -1513,11 +1585,68 @@ const getIconDefinitions$1 = async providerId => {
|
|
|
1513
1585
|
return result;
|
|
1514
1586
|
};
|
|
1515
1587
|
|
|
1588
|
+
const Disk = 'file';
|
|
1589
|
+
|
|
1590
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1591
|
+
const getProtocol = uri => {
|
|
1592
|
+
if (!uri) {
|
|
1593
|
+
return Disk;
|
|
1594
|
+
}
|
|
1595
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1596
|
+
if (protocolMatch) {
|
|
1597
|
+
return protocolMatch[1];
|
|
1598
|
+
}
|
|
1599
|
+
return Disk;
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1516
1602
|
const acceptInput$1 = (providerId, text, assetDir, platform) => {
|
|
1517
1603
|
string(providerId);
|
|
1518
1604
|
string(text);
|
|
1519
1605
|
return acceptInput$2(providerId, text, assetDir, platform);
|
|
1520
1606
|
};
|
|
1607
|
+
const generateCommitMessage$1 = (providerId, assetDir, platform) => {
|
|
1608
|
+
string(providerId);
|
|
1609
|
+
return generateCommitMessage$2(providerId, assetDir, platform);
|
|
1610
|
+
};
|
|
1611
|
+
const getShowGenerateCommitMessageButton = async (providerId, assetDir, platform) => {
|
|
1612
|
+
string(providerId);
|
|
1613
|
+
try {
|
|
1614
|
+
const features = await getFeatures(providerId, assetDir, platform);
|
|
1615
|
+
if (!features || typeof features !== 'object') {
|
|
1616
|
+
return true;
|
|
1617
|
+
}
|
|
1618
|
+
if ('showGenerateCommitMessageButton' in features && typeof features.showGenerateCommitMessageButton === 'boolean') {
|
|
1619
|
+
return features.showGenerateCommitMessageButton;
|
|
1620
|
+
}
|
|
1621
|
+
return true;
|
|
1622
|
+
} catch {
|
|
1623
|
+
return true;
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
const getProviderBadgeCount = async (providerId, assetDir, platform) => {
|
|
1627
|
+
try {
|
|
1628
|
+
return await getBadgeCount$2(providerId, assetDir, platform);
|
|
1629
|
+
} catch {
|
|
1630
|
+
try {
|
|
1631
|
+
const changedFiles = await getChangedFiles(providerId, assetDir, platform);
|
|
1632
|
+
return changedFiles.length;
|
|
1633
|
+
} catch {
|
|
1634
|
+
return 0;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
const getBadgeCount$1 = async (providerIds, assetDir, platform) => {
|
|
1639
|
+
let badgeCount = 0;
|
|
1640
|
+
for (const providerId of providerIds) {
|
|
1641
|
+
badgeCount += await getProviderBadgeCount(providerId, assetDir, platform);
|
|
1642
|
+
}
|
|
1643
|
+
return badgeCount;
|
|
1644
|
+
};
|
|
1645
|
+
const getWorkspaceBadgeCount = async (root, assetDir, platform) => {
|
|
1646
|
+
const scheme = getProtocol(root);
|
|
1647
|
+
const providerIds = await getEnabledProviderIds(scheme, root, assetDir, platform);
|
|
1648
|
+
return getBadgeCount$1(providerIds, assetDir, platform);
|
|
1649
|
+
};
|
|
1521
1650
|
const getFileDecorations = (providerId, uris, assetDir, platform) => {
|
|
1522
1651
|
return getFileDecorations$1(providerId, uris, assetDir, platform);
|
|
1523
1652
|
};
|
|
@@ -1555,6 +1684,12 @@ const getGroups = async (enabledProviderIds, root, assetDir, platform) => {
|
|
|
1555
1684
|
};
|
|
1556
1685
|
};
|
|
1557
1686
|
|
|
1687
|
+
const inputPaddingBlock = 11;
|
|
1688
|
+
const buttonBlockHeight = 34;
|
|
1689
|
+
const getHeaderHeight = (inputBoxHeight, sourceControlButtons) => {
|
|
1690
|
+
return inputBoxHeight + inputPaddingBlock + sourceControlButtons.length * buttonBlockHeight;
|
|
1691
|
+
};
|
|
1692
|
+
|
|
1558
1693
|
const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight, inputPadding) => {
|
|
1559
1694
|
try {
|
|
1560
1695
|
if (!input) {
|
|
@@ -1598,20 +1733,6 @@ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
|
1598
1733
|
return Math.ceil(listHeight / itemHeight) + 1;
|
|
1599
1734
|
};
|
|
1600
1735
|
|
|
1601
|
-
const Disk = 'file';
|
|
1602
|
-
|
|
1603
|
-
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1604
|
-
const getProtocol = uri => {
|
|
1605
|
-
if (!uri) {
|
|
1606
|
-
return Disk;
|
|
1607
|
-
}
|
|
1608
|
-
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1609
|
-
if (protocolMatch) {
|
|
1610
|
-
return protocolMatch[1];
|
|
1611
|
-
}
|
|
1612
|
-
return Disk;
|
|
1613
|
-
};
|
|
1614
|
-
|
|
1615
1736
|
const emptySourceControlButtons = [];
|
|
1616
1737
|
|
|
1617
1738
|
const getContextId = (groupId, type) => {
|
|
@@ -1652,23 +1773,41 @@ const get$1 = key => {
|
|
|
1652
1773
|
return getPreference(key);
|
|
1653
1774
|
};
|
|
1654
1775
|
|
|
1655
|
-
const
|
|
1656
|
-
return
|
|
1776
|
+
const isCompatible = (extension, platform) => {
|
|
1777
|
+
return platform !== Web || extension?.compatibility?.web !== false;
|
|
1778
|
+
};
|
|
1779
|
+
const getExtensions = async platform => {
|
|
1780
|
+
const extensions = await invoke$1('Extensions.getExtensions');
|
|
1781
|
+
return extensions.filter(extension => isCompatible(extension, platform));
|
|
1657
1782
|
};
|
|
1658
1783
|
|
|
1659
|
-
const requestSourceActions = async () => {
|
|
1660
|
-
const extensions = await getExtensions();
|
|
1784
|
+
const requestSourceActions = async (platform = 0) => {
|
|
1785
|
+
const extensions = await getExtensions(platform);
|
|
1661
1786
|
const newCache = Object.create(null);
|
|
1662
1787
|
for (const extension of extensions) {
|
|
1663
|
-
if (extension
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1788
|
+
if (!extension || !extension['source-control-actions']) {
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
const sourceControlActions = Object.entries(extension['source-control-actions']);
|
|
1792
|
+
for (const [key, value] of sourceControlActions) {
|
|
1793
|
+
newCache[key] = value;
|
|
1667
1794
|
}
|
|
1668
1795
|
}
|
|
1669
1796
|
return newCache;
|
|
1670
1797
|
};
|
|
1671
1798
|
|
|
1799
|
+
const requestSourceControlButtons = async (platform = 0) => {
|
|
1800
|
+
const extensions = await getExtensions(platform);
|
|
1801
|
+
const buttons = [];
|
|
1802
|
+
for (const extension of extensions) {
|
|
1803
|
+
if (!extension || !Array.isArray(extension['source-control-buttons'])) {
|
|
1804
|
+
continue;
|
|
1805
|
+
}
|
|
1806
|
+
buttons.push(...extension['source-control-buttons']);
|
|
1807
|
+
}
|
|
1808
|
+
return buttons;
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1672
1811
|
/* eslint-disable unicorn/no-array-reduce */
|
|
1673
1812
|
const restoreExpandedGroups = groups => {
|
|
1674
1813
|
return groups.map(group => group.id).reduce((total, current) => {
|
|
@@ -1721,9 +1860,11 @@ const RevealInExplorerView = 'Reveal in Explorer View';
|
|
|
1721
1860
|
const OpenContainingFolder = 'Open Containing Folder';
|
|
1722
1861
|
const ViewAsTree$1 = 'View As Tree';
|
|
1723
1862
|
const CommitAndPush$1 = 'Commit and Push';
|
|
1863
|
+
const GenerateCommitMessage$1 = 'Generate Commit Message';
|
|
1724
1864
|
const Refresh$2 = 'Refresh';
|
|
1725
1865
|
const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
|
|
1726
1866
|
const SourceControlInput$1 = 'Source Control Input';
|
|
1867
|
+
const NoSourceControlProvidersAvailableForWeb = 'No source control providers are available for web.';
|
|
1727
1868
|
|
|
1728
1869
|
const openChanges = () => {
|
|
1729
1870
|
return i18nString(OpenChanges);
|
|
@@ -1755,6 +1896,9 @@ const viewAsTree$1 = () => {
|
|
|
1755
1896
|
const commitAndPush = () => {
|
|
1756
1897
|
return i18nString(CommitAndPush$1);
|
|
1757
1898
|
};
|
|
1899
|
+
const generateCommitMessage = () => {
|
|
1900
|
+
return i18nString(GenerateCommitMessage$1);
|
|
1901
|
+
};
|
|
1758
1902
|
const refresh$1 = () => {
|
|
1759
1903
|
return i18nString(Refresh$2);
|
|
1760
1904
|
};
|
|
@@ -1764,6 +1908,9 @@ const messageEnterToCommitOnMaster = () => {
|
|
|
1764
1908
|
const sourceControlInput = () => {
|
|
1765
1909
|
return i18nString(SourceControlInput$1);
|
|
1766
1910
|
};
|
|
1911
|
+
const noSourceControlProvidersAvailableForWeb = () => {
|
|
1912
|
+
return i18nString(NoSourceControlProvidersAvailableForWeb);
|
|
1913
|
+
};
|
|
1767
1914
|
|
|
1768
1915
|
const loadContent = async (state, savedState) => {
|
|
1769
1916
|
const {
|
|
@@ -1790,6 +1937,7 @@ const loadContent = async (state, savedState) => {
|
|
|
1790
1937
|
platform
|
|
1791
1938
|
} = state;
|
|
1792
1939
|
const enabledProviderIds = await getEnabledProviderIds(scheme, root, assetDir, platform);
|
|
1940
|
+
const showGenerateCommitMessageButton = enabledProviderIds.length === 0 ? false : await getShowGenerateCommitMessageButton(enabledProviderIds[0], assetDir, platform);
|
|
1793
1941
|
const iconDefinitions = await getIconDefinitions(enabledProviderIds);
|
|
1794
1942
|
const {
|
|
1795
1943
|
allGroups,
|
|
@@ -1797,11 +1945,12 @@ const loadContent = async (state, savedState) => {
|
|
|
1797
1945
|
} = await getGroups(enabledProviderIds, root, assetDir, platform);
|
|
1798
1946
|
const expandedGroups = restoreExpandedGroups(allGroups);
|
|
1799
1947
|
const displayItems = getDisplayItems(allGroups, expandedGroups, iconDefinitions);
|
|
1800
|
-
const actionsCache = await requestSourceActions();
|
|
1948
|
+
const actionsCache = enabledProviderIds.length === 0 ? Object.create(null) : await requestSourceActions(platform);
|
|
1949
|
+
const sourceControlButtons = enabledProviderIds.length === 0 ? [] : await requestSourceControlButtons(platform);
|
|
1801
1950
|
|
|
1802
1951
|
// TODO make preferences async and more functional
|
|
1803
1952
|
const splitButtonEnabled = await get$1('sourceControl.splitButtonEnabled');
|
|
1804
|
-
const badgeCount =
|
|
1953
|
+
const badgeCount = await getBadgeCount$1(enabledProviderIds, assetDir, platform);
|
|
1805
1954
|
const total = displayItems.length;
|
|
1806
1955
|
const contentHeight = total * itemHeight;
|
|
1807
1956
|
const listHeight = getListHeight(total, itemHeight, height);
|
|
@@ -1814,6 +1963,7 @@ const loadContent = async (state, savedState) => {
|
|
|
1814
1963
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
1815
1964
|
const inputPlaceholder = messageEnterToCommitOnMaster();
|
|
1816
1965
|
const inputBoxHeight = await getInputHeight(inputValue, width, inputFontFamily, inputFontSize, inputFontWeight, inputLetterSpacing, inputLineHeight, inputPadding);
|
|
1966
|
+
const headerHeight = getHeaderHeight(inputBoxHeight, sourceControlButtons);
|
|
1817
1967
|
return {
|
|
1818
1968
|
...state,
|
|
1819
1969
|
actionsCache,
|
|
@@ -1824,6 +1974,7 @@ const loadContent = async (state, savedState) => {
|
|
|
1824
1974
|
fileIconCache: newFileIconCache,
|
|
1825
1975
|
finalDeltaY,
|
|
1826
1976
|
gitRoot,
|
|
1977
|
+
headerHeight,
|
|
1827
1978
|
iconDefinitions,
|
|
1828
1979
|
initial: false,
|
|
1829
1980
|
inputBoxHeight,
|
|
@@ -1833,6 +1984,8 @@ const loadContent = async (state, savedState) => {
|
|
|
1833
1984
|
maxLineY,
|
|
1834
1985
|
root,
|
|
1835
1986
|
scrollBarHeight,
|
|
1987
|
+
showGenerateCommitMessageButton,
|
|
1988
|
+
sourceControlButtons,
|
|
1836
1989
|
splitButtonEnabled,
|
|
1837
1990
|
visibleItems
|
|
1838
1991
|
};
|
|
@@ -1859,15 +2012,76 @@ const acceptInput = async state => {
|
|
|
1859
2012
|
info('[ViewletSourceControl] no source control provider found');
|
|
1860
2013
|
return state;
|
|
1861
2014
|
}
|
|
1862
|
-
const providerId
|
|
1863
|
-
|
|
2015
|
+
for (const providerId of enabledProviderIds) {
|
|
2016
|
+
await acceptInput$1(providerId, inputValue, assetDir, platform);
|
|
2017
|
+
}
|
|
1864
2018
|
const newState = await loadContent(state, {});
|
|
1865
2019
|
return {
|
|
1866
2020
|
...newState,
|
|
2021
|
+
inputMessage: '',
|
|
1867
2022
|
inputValue: ''
|
|
1868
2023
|
};
|
|
1869
2024
|
};
|
|
1870
2025
|
|
|
2026
|
+
const createDefaultState = () => ({
|
|
2027
|
+
actionsCache: Object.create(null),
|
|
2028
|
+
allGroups: [],
|
|
2029
|
+
assetDir: '',
|
|
2030
|
+
badgeCount: 0,
|
|
2031
|
+
decorationIcons: [],
|
|
2032
|
+
deltaY: 0,
|
|
2033
|
+
enabledProviderIds: [],
|
|
2034
|
+
expandedGroups: Object.create(null),
|
|
2035
|
+
fileIconCache: {},
|
|
2036
|
+
finalDeltaY: 0,
|
|
2037
|
+
focus: 0,
|
|
2038
|
+
gitRoot: '',
|
|
2039
|
+
handleOffset: 0,
|
|
2040
|
+
headerHeight: 40,
|
|
2041
|
+
height: 100,
|
|
2042
|
+
history: [],
|
|
2043
|
+
iconDefinitions: [],
|
|
2044
|
+
id: 1,
|
|
2045
|
+
index: [],
|
|
2046
|
+
initial: false,
|
|
2047
|
+
inputBoxHeight: 30,
|
|
2048
|
+
inputBoxMaxHeight: 214,
|
|
2049
|
+
inputFontFamily: '',
|
|
2050
|
+
inputFontSize: 15,
|
|
2051
|
+
inputFontWeight: 400,
|
|
2052
|
+
inputLetterSpacing: 0.5,
|
|
2053
|
+
inputLineHeight: 14.95,
|
|
2054
|
+
inputMessage: '',
|
|
2055
|
+
inputPadding: 2,
|
|
2056
|
+
inputPlaceholder: '',
|
|
2057
|
+
inputSource: 0,
|
|
2058
|
+
inputValue: '',
|
|
2059
|
+
isVisible: true,
|
|
2060
|
+
itemHeight: 20,
|
|
2061
|
+
items: [],
|
|
2062
|
+
maxInputLines: 5,
|
|
2063
|
+
maxLineY: 0,
|
|
2064
|
+
merge: [],
|
|
2065
|
+
minimumSliderSize: 30,
|
|
2066
|
+
minLineY: 0,
|
|
2067
|
+
platform: 0,
|
|
2068
|
+
providerId: '',
|
|
2069
|
+
root: '/',
|
|
2070
|
+
scrollBarActive: false,
|
|
2071
|
+
scrollBarHeight: 0,
|
|
2072
|
+
showGenerateCommitMessageButton: false,
|
|
2073
|
+
sourceControlButtons: [],
|
|
2074
|
+
splitButtonEnabled: false,
|
|
2075
|
+
untracked: [],
|
|
2076
|
+
viewMode: 1,
|
|
2077
|
+
visibleItems: [],
|
|
2078
|
+
width: 100,
|
|
2079
|
+
workingTree: [],
|
|
2080
|
+
workspacePath: '',
|
|
2081
|
+
x: 0,
|
|
2082
|
+
y: 0
|
|
2083
|
+
});
|
|
2084
|
+
|
|
1871
2085
|
const {
|
|
1872
2086
|
get,
|
|
1873
2087
|
getCommandIds,
|
|
@@ -1877,59 +2091,16 @@ const {
|
|
|
1877
2091
|
wrapGetter
|
|
1878
2092
|
} = create();
|
|
1879
2093
|
|
|
1880
|
-
const create2 = (id,
|
|
2094
|
+
const create2 = (id, _uri, x, y, width, height, workspacePath, platform, assetDir) => {
|
|
2095
|
+
const defaultState = createDefaultState();
|
|
1881
2096
|
const state = {
|
|
1882
|
-
|
|
1883
|
-
allGroups: [],
|
|
2097
|
+
...defaultState,
|
|
1884
2098
|
assetDir,
|
|
1885
|
-
badgeCount: 0,
|
|
1886
|
-
decorationIcons: [],
|
|
1887
|
-
deltaY: 0,
|
|
1888
|
-
enabledProviderIds: [],
|
|
1889
|
-
expandedGroups: Object.create(null),
|
|
1890
|
-
fileIconCache: Object.create(null),
|
|
1891
|
-
finalDeltaY: 0,
|
|
1892
|
-
focus: 0,
|
|
1893
|
-
gitRoot: '',
|
|
1894
|
-
handleOffset: 0,
|
|
1895
|
-
headerHeight: 40,
|
|
1896
|
-
// TODO
|
|
1897
2099
|
height,
|
|
1898
|
-
history: [],
|
|
1899
|
-
iconDefinitions: [],
|
|
1900
2100
|
id,
|
|
1901
|
-
index: [],
|
|
1902
2101
|
initial: true,
|
|
1903
|
-
inputBoxHeight: 30,
|
|
1904
|
-
inputBoxMaxHeight: 214,
|
|
1905
|
-
inputFontFamily: 'system-ui, Ubuntu, "Droid Sans", sans-serif',
|
|
1906
|
-
inputFontSize: 13,
|
|
1907
|
-
inputFontWeight: 400,
|
|
1908
|
-
inputLetterSpacing: 0,
|
|
1909
|
-
inputLineHeight: 20,
|
|
1910
|
-
inputPadding: 2,
|
|
1911
|
-
inputPlaceholder: '',
|
|
1912
|
-
inputSource: 0,
|
|
1913
|
-
inputValue: '',
|
|
1914
|
-
isVisible: true,
|
|
1915
|
-
itemHeight: 20,
|
|
1916
|
-
items: [],
|
|
1917
|
-
maxInputLines: 5,
|
|
1918
|
-
maxLineY: 0,
|
|
1919
|
-
merge: [],
|
|
1920
|
-
minimumSliderSize: 20,
|
|
1921
|
-
minLineY: 0,
|
|
1922
2102
|
platform,
|
|
1923
|
-
providerId: '',
|
|
1924
|
-
root: '',
|
|
1925
|
-
scrollBarActive: false,
|
|
1926
|
-
scrollBarHeight: 0,
|
|
1927
|
-
splitButtonEnabled: false,
|
|
1928
|
-
untracked: [],
|
|
1929
|
-
viewMode: 1,
|
|
1930
|
-
visibleItems: [],
|
|
1931
2103
|
width,
|
|
1932
|
-
workingTree: [],
|
|
1933
2104
|
workspacePath,
|
|
1934
2105
|
x,
|
|
1935
2106
|
y
|
|
@@ -1946,7 +2117,7 @@ const isEqual$2 = (oldState, newState) => {
|
|
|
1946
2117
|
};
|
|
1947
2118
|
|
|
1948
2119
|
const isEqual$1 = (oldState, newState) => {
|
|
1949
|
-
return oldState.allGroups === newState.allGroups && oldState.deltaY === newState.deltaY && oldState.items === newState.items && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.visibleItems === newState.visibleItems;
|
|
2120
|
+
return oldState.allGroups === newState.allGroups && oldState.deltaY === newState.deltaY && oldState.items === newState.items && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.sourceControlButtons === newState.sourceControlButtons && oldState.visibleItems === newState.visibleItems;
|
|
1950
2121
|
};
|
|
1951
2122
|
|
|
1952
2123
|
const RenderItems = 4;
|
|
@@ -2016,6 +2187,7 @@ const NavigateChild = 7;
|
|
|
2016
2187
|
const NavigateParent = 8;
|
|
2017
2188
|
const RemoveChild = 9;
|
|
2018
2189
|
const NavigateSibling = 10;
|
|
2190
|
+
const SetReferenceNodeUid = 11;
|
|
2019
2191
|
|
|
2020
2192
|
const isKey = key => {
|
|
2021
2193
|
return key !== 'type' && key !== 'childCount';
|
|
@@ -2083,6 +2255,16 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
2083
2255
|
if (oldNode.type !== newNode.type) {
|
|
2084
2256
|
return null;
|
|
2085
2257
|
}
|
|
2258
|
+
// Handle reference nodes - special handling for uid changes
|
|
2259
|
+
if (oldNode.type === Reference) {
|
|
2260
|
+
if (oldNode.uid !== newNode.uid) {
|
|
2261
|
+
patches.push({
|
|
2262
|
+
type: SetReferenceNodeUid,
|
|
2263
|
+
uid: newNode.uid
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
return patches;
|
|
2267
|
+
}
|
|
2086
2268
|
// Handle text nodes
|
|
2087
2269
|
if (oldNode.type === Text && newNode.type === Text) {
|
|
2088
2270
|
if (oldNode.text !== newNode.text) {
|
|
@@ -2218,7 +2400,6 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
2218
2400
|
patches.push({
|
|
2219
2401
|
type: NavigateParent
|
|
2220
2402
|
});
|
|
2221
|
-
currentChildIndex = -1;
|
|
2222
2403
|
}
|
|
2223
2404
|
// Add remove patches in reverse order (highest index first)
|
|
2224
2405
|
// This ensures indices remain valid as we remove
|
|
@@ -2344,10 +2525,64 @@ const getMenuIds = () => {
|
|
|
2344
2525
|
return [SourceControl$1];
|
|
2345
2526
|
};
|
|
2346
2527
|
|
|
2528
|
+
const handleInput = async (state, value, inputSource = User) => {
|
|
2529
|
+
const {
|
|
2530
|
+
inputFontFamily,
|
|
2531
|
+
inputFontSize,
|
|
2532
|
+
inputFontWeight,
|
|
2533
|
+
inputLetterSpacing,
|
|
2534
|
+
inputLineHeight,
|
|
2535
|
+
inputPadding,
|
|
2536
|
+
width
|
|
2537
|
+
} = state;
|
|
2538
|
+
const inputBoxHeight = await getInputHeight(value, width, inputFontFamily, inputFontWeight, inputFontSize, inputLetterSpacing, inputLineHeight, inputPadding);
|
|
2539
|
+
return {
|
|
2540
|
+
...state,
|
|
2541
|
+
inputBoxHeight,
|
|
2542
|
+
inputMessage: '',
|
|
2543
|
+
inputSource,
|
|
2544
|
+
inputValue: value
|
|
2545
|
+
};
|
|
2546
|
+
};
|
|
2547
|
+
|
|
2548
|
+
const toErrorMessage = error => {
|
|
2549
|
+
if (error instanceof Error && error.message) {
|
|
2550
|
+
return `Failed to generate commit message: ${error.message}`;
|
|
2551
|
+
}
|
|
2552
|
+
return 'Failed to generate commit message';
|
|
2553
|
+
};
|
|
2554
|
+
const handleGenerateCommitMessage = async state => {
|
|
2555
|
+
const {
|
|
2556
|
+
assetDir,
|
|
2557
|
+
enabledProviderIds,
|
|
2558
|
+
platform
|
|
2559
|
+
} = state;
|
|
2560
|
+
if (enabledProviderIds.length === 0) {
|
|
2561
|
+
return {
|
|
2562
|
+
...state,
|
|
2563
|
+
inputMessage: 'Failed to generate commit message: no source control provider found'
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
try {
|
|
2567
|
+
const inputValue = await generateCommitMessage$1(enabledProviderIds[0], assetDir, platform);
|
|
2568
|
+
const newState = await handleInput(state, inputValue, Script);
|
|
2569
|
+
return {
|
|
2570
|
+
...newState,
|
|
2571
|
+
inputMessage: ''
|
|
2572
|
+
};
|
|
2573
|
+
} catch (error) {
|
|
2574
|
+
return {
|
|
2575
|
+
...state,
|
|
2576
|
+
inputMessage: toErrorMessage(error)
|
|
2577
|
+
};
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
|
|
2347
2581
|
const SourceControlInput = 'SourceControlInput';
|
|
2348
2582
|
const ViewAsTree = 'ViewAsTree';
|
|
2349
2583
|
const CommitAndPush = 'CommitAndPush';
|
|
2350
2584
|
const Refresh$1 = 'Refresh';
|
|
2585
|
+
const GenerateCommitMessage = 'GenerateCommitMessage';
|
|
2351
2586
|
|
|
2352
2587
|
const refresh = async state => {
|
|
2353
2588
|
const {
|
|
@@ -2369,7 +2604,7 @@ const refresh = async state => {
|
|
|
2369
2604
|
} = await getGroups(enabledProviderIds, root, assetDir, platform);
|
|
2370
2605
|
const expandedGroups = restoreExpandedGroups(allGroups);
|
|
2371
2606
|
const displayItems = getDisplayItems(allGroups, expandedGroups, iconDefinitions);
|
|
2372
|
-
const badgeCount =
|
|
2607
|
+
const badgeCount = await getBadgeCount$1(enabledProviderIds, assetDir, platform);
|
|
2373
2608
|
const total = displayItems.length;
|
|
2374
2609
|
const contentHeight = total * itemHeight;
|
|
2375
2610
|
const listHeight = getListHeight(total, itemHeight, height);
|
|
@@ -2409,6 +2644,8 @@ const handleActionClick = async (state, actionName) => {
|
|
|
2409
2644
|
case CommitAndPush:
|
|
2410
2645
|
warn(`[source-control-worker] CommitAndPush action not yet implemented`);
|
|
2411
2646
|
return state;
|
|
2647
|
+
case GenerateCommitMessage:
|
|
2648
|
+
return handleGenerateCommitMessage(state);
|
|
2412
2649
|
case Refresh$1:
|
|
2413
2650
|
return refresh(state);
|
|
2414
2651
|
case ViewAsTree:
|
|
@@ -2613,32 +2850,13 @@ const handleInputFocus = async state => {
|
|
|
2613
2850
|
};
|
|
2614
2851
|
};
|
|
2615
2852
|
|
|
2616
|
-
const handleInput = async (state, value, inputSource = User) => {
|
|
2617
|
-
const {
|
|
2618
|
-
inputFontFamily,
|
|
2619
|
-
inputFontSize,
|
|
2620
|
-
inputFontWeight,
|
|
2621
|
-
inputLetterSpacing,
|
|
2622
|
-
inputLineHeight,
|
|
2623
|
-
inputPadding,
|
|
2624
|
-
width
|
|
2625
|
-
} = state;
|
|
2626
|
-
const inputBoxHeight = await getInputHeight(value, width, inputFontFamily, inputFontWeight, inputFontSize, inputLetterSpacing, inputLineHeight, inputPadding);
|
|
2627
|
-
return {
|
|
2628
|
-
...state,
|
|
2629
|
-
inputBoxHeight,
|
|
2630
|
-
inputSource,
|
|
2631
|
-
inputValue: value
|
|
2632
|
-
};
|
|
2633
|
-
};
|
|
2634
|
-
|
|
2635
2853
|
const handleInputBlur = async state => {
|
|
2636
2854
|
// TODO reset focus
|
|
2637
2855
|
return state;
|
|
2638
2856
|
};
|
|
2639
2857
|
|
|
2640
2858
|
const handleMessagePort = async port => {
|
|
2641
|
-
await
|
|
2859
|
+
await create$4({
|
|
2642
2860
|
commandMap: {},
|
|
2643
2861
|
messagePort: port
|
|
2644
2862
|
});
|
|
@@ -2679,6 +2897,21 @@ const handleMouseOverAt = async (state, eventX, eventY) => {
|
|
|
2679
2897
|
return handleMouseOver(state, index);
|
|
2680
2898
|
};
|
|
2681
2899
|
|
|
2900
|
+
const handleSourceControlButtonClick = async (state, name) => {
|
|
2901
|
+
const button = state.sourceControlButtons.find(button => button.label === name);
|
|
2902
|
+
if (!button) {
|
|
2903
|
+
warn(`[source-control-worker] Source control button not found ${name}`);
|
|
2904
|
+
return state;
|
|
2905
|
+
}
|
|
2906
|
+
await executeCommand(button.command, state.assetDir, state.platform, state.inputValue);
|
|
2907
|
+
const newState = await loadContent(state, {});
|
|
2908
|
+
return {
|
|
2909
|
+
...newState,
|
|
2910
|
+
inputMessage: '',
|
|
2911
|
+
inputValue: ''
|
|
2912
|
+
};
|
|
2913
|
+
};
|
|
2914
|
+
|
|
2682
2915
|
const setDeltaY = async (state, newDeltaY) => {
|
|
2683
2916
|
const {
|
|
2684
2917
|
actionsCache,
|
|
@@ -2718,7 +2951,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
|
|
|
2718
2951
|
|
|
2719
2952
|
const createExtensionHostRpc = async () => {
|
|
2720
2953
|
try {
|
|
2721
|
-
const rpc = await
|
|
2954
|
+
const rpc = await create$3({
|
|
2722
2955
|
commandMap: {},
|
|
2723
2956
|
send: sendMessagePortToExtensionHostWorker
|
|
2724
2957
|
});
|
|
@@ -2734,7 +2967,7 @@ const sendMessagePortToTextMeasurementWorker = async port => {
|
|
|
2734
2967
|
|
|
2735
2968
|
const createTextMeasurementWorkerRpc = async () => {
|
|
2736
2969
|
try {
|
|
2737
|
-
const rpc = await
|
|
2970
|
+
const rpc = await create$3({
|
|
2738
2971
|
commandMap: {},
|
|
2739
2972
|
send: sendMessagePortToTextMeasurementWorker
|
|
2740
2973
|
});
|
|
@@ -2746,7 +2979,7 @@ const createTextMeasurementWorkerRpc = async () => {
|
|
|
2746
2979
|
|
|
2747
2980
|
const createExtensionManagementWorkerRpc = async () => {
|
|
2748
2981
|
try {
|
|
2749
|
-
const rpc = await
|
|
2982
|
+
const rpc = await create$3({
|
|
2750
2983
|
commandMap: {},
|
|
2751
2984
|
send: port => sendMessagePortToExtensionManagementWorker(port, 0)
|
|
2752
2985
|
});
|
|
@@ -2771,6 +3004,12 @@ const initialize = async () => {
|
|
|
2771
3004
|
set$1(textRpc);
|
|
2772
3005
|
};
|
|
2773
3006
|
|
|
3007
|
+
const getIndentRule = indent => {
|
|
3008
|
+
return `.Indent-${indent} {
|
|
3009
|
+
padding-left: ${indent}px;
|
|
3010
|
+
}`;
|
|
3011
|
+
};
|
|
3012
|
+
|
|
2774
3013
|
const getUnique = items => {
|
|
2775
3014
|
const seens = [];
|
|
2776
3015
|
for (const item of items) {
|
|
@@ -2781,11 +3020,6 @@ const getUnique = items => {
|
|
|
2781
3020
|
return seens;
|
|
2782
3021
|
};
|
|
2783
3022
|
|
|
2784
|
-
const getIndentRule = indent => {
|
|
2785
|
-
return `.Indent-${indent} {
|
|
2786
|
-
padding-left: ${indent}px;
|
|
2787
|
-
}`;
|
|
2788
|
-
};
|
|
2789
3023
|
const renderCss = (oldState, newState) => {
|
|
2790
3024
|
const {
|
|
2791
3025
|
id,
|
|
@@ -2825,19 +3059,13 @@ const IconButton = 'IconButton';
|
|
|
2825
3059
|
const InputBox = 'InputBox';
|
|
2826
3060
|
const Label = 'Label';
|
|
2827
3061
|
const LabelDetail = 'LabelDetail';
|
|
2828
|
-
const
|
|
2829
|
-
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
3062
|
+
const Message = 'Message';
|
|
2830
3063
|
const SourceControl = 'SourceControl';
|
|
2831
3064
|
const SourceControlButton = 'SourceControlButton';
|
|
2832
3065
|
const SourceControlHeader = 'SourceControlHeader';
|
|
2833
3066
|
const SourceControlItems = 'SourceControlItems';
|
|
2834
3067
|
const SplitButton = 'SplitButton';
|
|
2835
3068
|
const SplitButtonContent = 'SplitButtonContent';
|
|
2836
|
-
const SplitButtonContentDisabled = 'SplitButtonContentDisabled';
|
|
2837
|
-
const SplitButtonDisabled = 'SplitButtonDisabled';
|
|
2838
|
-
const SplitButtonDropDown = 'SplitButtonDropDown';
|
|
2839
|
-
const SplitButtonDropDownDisabled = 'SplitButtonDropDownDisabled';
|
|
2840
|
-
const SplitButtonSeparator = 'SplitButtonSeparator';
|
|
2841
3069
|
const StrikeThrough = 'StrikeThrough';
|
|
2842
3070
|
const TreeItem = 'TreeItem';
|
|
2843
3071
|
const Viewlet = 'Viewlet';
|
|
@@ -2851,9 +3079,34 @@ const HandleMouseOver = 7;
|
|
|
2851
3079
|
const HandleMouseOverAt = 8;
|
|
2852
3080
|
const HandleWheel = 9;
|
|
2853
3081
|
const HandleClickAction = 10;
|
|
3082
|
+
const HandleClickSourceControlButton = 11;
|
|
2854
3083
|
|
|
2855
|
-
const
|
|
3084
|
+
const getSourceControlButtonVirtualDom = button => {
|
|
3085
|
+
const {
|
|
3086
|
+
id,
|
|
3087
|
+
label
|
|
3088
|
+
} = button;
|
|
2856
3089
|
return [{
|
|
3090
|
+
childCount: 1,
|
|
3091
|
+
className: SplitButton,
|
|
3092
|
+
type: Div
|
|
3093
|
+
}, {
|
|
3094
|
+
childCount: 1,
|
|
3095
|
+
className: SplitButtonContent,
|
|
3096
|
+
name: label,
|
|
3097
|
+
onClick: HandleClickSourceControlButton,
|
|
3098
|
+
tabIndex: 0,
|
|
3099
|
+
title: id,
|
|
3100
|
+
type: Div
|
|
3101
|
+
}, text(label)];
|
|
3102
|
+
};
|
|
3103
|
+
|
|
3104
|
+
const getSourceControlButtonsVirtualDom = buttons => {
|
|
3105
|
+
return buttons.flatMap(getSourceControlButtonVirtualDom);
|
|
3106
|
+
};
|
|
3107
|
+
|
|
3108
|
+
const getSourceControlInputDom = (inputPlaceholder, inputMessage) => {
|
|
3109
|
+
const dom = [{
|
|
2857
3110
|
ariaLabel: sourceControlInput(),
|
|
2858
3111
|
autocapitalize: 'off',
|
|
2859
3112
|
autocorrect: 'off',
|
|
@@ -2866,14 +3119,26 @@ const getSourceControlInputDom = inputPlaceholder => {
|
|
|
2866
3119
|
spellcheck: false,
|
|
2867
3120
|
type: TextArea
|
|
2868
3121
|
}];
|
|
3122
|
+
if (inputMessage) {
|
|
3123
|
+
dom.push({
|
|
3124
|
+
childCount: 1,
|
|
3125
|
+
className: Message,
|
|
3126
|
+
type: Div
|
|
3127
|
+
}, {
|
|
3128
|
+
text: inputMessage,
|
|
3129
|
+
type: Text
|
|
3130
|
+
});
|
|
3131
|
+
}
|
|
3132
|
+
return dom;
|
|
2869
3133
|
};
|
|
2870
3134
|
|
|
2871
|
-
const getSourceControlHeaderVirtualDom = inputPlaceholder => {
|
|
3135
|
+
const getSourceControlHeaderVirtualDom = (inputPlaceholder, inputMessage) => {
|
|
3136
|
+
const inputDom = getSourceControlInputDom(inputPlaceholder, inputMessage);
|
|
2872
3137
|
return [{
|
|
2873
|
-
childCount: 1,
|
|
3138
|
+
childCount: inputMessage ? 2 : 1,
|
|
2874
3139
|
className: SourceControlHeader,
|
|
2875
3140
|
type: Div
|
|
2876
|
-
}, ...
|
|
3141
|
+
}, ...inputDom];
|
|
2877
3142
|
};
|
|
2878
3143
|
|
|
2879
3144
|
const className$1 = mergeClassNames(Badge, SourceControlBadge);
|
|
@@ -2883,7 +3148,7 @@ const parentNode = {
|
|
|
2883
3148
|
type: Div
|
|
2884
3149
|
};
|
|
2885
3150
|
const getBadgeVirtualDom = count => {
|
|
2886
|
-
return [parentNode, text(
|
|
3151
|
+
return [parentNode, text(String(count))];
|
|
2887
3152
|
};
|
|
2888
3153
|
|
|
2889
3154
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
@@ -3072,40 +3337,15 @@ const getSourceControlListVirtualDom = items => {
|
|
|
3072
3337
|
}, ...items.flatMap(getSourceControlItemVirtualDom)];
|
|
3073
3338
|
};
|
|
3074
3339
|
|
|
3075
|
-
const
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
}
|
|
3079
|
-
return [{
|
|
3080
|
-
childCount: 3,
|
|
3081
|
-
className: mergeClassNames(SplitButton, hasItems ? '' : SplitButtonDisabled),
|
|
3082
|
-
type: Div
|
|
3083
|
-
}, {
|
|
3084
|
-
childCount: 1,
|
|
3085
|
-
className: mergeClassNames(SplitButtonContent, hasItems ? '' : SplitButtonContentDisabled),
|
|
3086
|
-
tabIndex: 0,
|
|
3087
|
-
type: Div
|
|
3088
|
-
}, text(buttonText), {
|
|
3089
|
-
childCount: 0,
|
|
3090
|
-
className: SplitButtonSeparator,
|
|
3091
|
-
type: Div
|
|
3092
|
-
}, {
|
|
3340
|
+
const className = mergeClassNames(Viewlet, SourceControl);
|
|
3341
|
+
const getSourceControlVirtualDom = (items, sourceControlButtons, inputPlaceholder, inputMessage, unavailableMessage) => {
|
|
3342
|
+
const content = unavailableMessage ? [{
|
|
3093
3343
|
childCount: 1,
|
|
3094
|
-
className:
|
|
3095
|
-
tabIndex: 0,
|
|
3096
|
-
type: Div
|
|
3097
|
-
}, {
|
|
3098
|
-
childCount: 0,
|
|
3099
|
-
className: mergeClassNames(MaskIcon, MaskIconChevronDown),
|
|
3344
|
+
className: Message,
|
|
3100
3345
|
type: Div
|
|
3101
|
-
}];
|
|
3102
|
-
};
|
|
3103
|
-
|
|
3104
|
-
const className = mergeClassNames(Viewlet, SourceControl);
|
|
3105
|
-
const getSourceControlVirtualDom = (items, splitButtonEnabled, inputPlaceholder) => {
|
|
3106
|
-
const hasItems = items.length > 0;
|
|
3346
|
+
}, text(unavailableMessage)] : [...getSourceControlHeaderVirtualDom(inputPlaceholder, inputMessage), ...getSourceControlButtonsVirtualDom(sourceControlButtons), ...getSourceControlListVirtualDom(items)];
|
|
3107
3347
|
const dom = [{
|
|
3108
|
-
childCount:
|
|
3348
|
+
childCount: unavailableMessage ? 1 : 2 + sourceControlButtons.length,
|
|
3109
3349
|
className: className,
|
|
3110
3350
|
onContextMenu: HandleContextMenu,
|
|
3111
3351
|
onMouseOver: HandleMouseOver,
|
|
@@ -3113,22 +3353,26 @@ const getSourceControlVirtualDom = (items, splitButtonEnabled, inputPlaceholder)
|
|
|
3113
3353
|
onWheel: HandleWheel,
|
|
3114
3354
|
tabIndex: 0,
|
|
3115
3355
|
type: Div
|
|
3116
|
-
}, ...
|
|
3356
|
+
}, ...content];
|
|
3117
3357
|
return dom;
|
|
3118
3358
|
};
|
|
3119
3359
|
|
|
3120
3360
|
const renderItems = (oldState, newState) => {
|
|
3121
3361
|
const {
|
|
3362
|
+
enabledProviderIds,
|
|
3122
3363
|
id,
|
|
3123
3364
|
initial,
|
|
3365
|
+
inputMessage,
|
|
3124
3366
|
inputPlaceholder,
|
|
3125
|
-
|
|
3367
|
+
platform,
|
|
3368
|
+
sourceControlButtons,
|
|
3126
3369
|
visibleItems
|
|
3127
3370
|
} = newState;
|
|
3128
3371
|
if (initial) {
|
|
3129
3372
|
return [SetDom2, id, []];
|
|
3130
3373
|
}
|
|
3131
|
-
const
|
|
3374
|
+
const unavailableMessage = platform === Web && enabledProviderIds.length === 0 ? noSourceControlProvidersAvailableForWeb() : '';
|
|
3375
|
+
const dom = getSourceControlVirtualDom(visibleItems, sourceControlButtons, inputPlaceholder, inputMessage, unavailableMessage);
|
|
3132
3376
|
return [SetDom2, id, dom];
|
|
3133
3377
|
};
|
|
3134
3378
|
|
|
@@ -3192,11 +3436,21 @@ const render2 = (uid, diffResult) => {
|
|
|
3192
3436
|
const Button = 1;
|
|
3193
3437
|
|
|
3194
3438
|
const Check = 'Check';
|
|
3439
|
+
const DebugAlt2 = 'DebugAlt2';
|
|
3195
3440
|
const ListFlat = 'ListFlat';
|
|
3196
3441
|
const Refresh = 'Refresh';
|
|
3197
3442
|
|
|
3198
|
-
const getActions =
|
|
3199
|
-
|
|
3443
|
+
const getActions = state => {
|
|
3444
|
+
if (state.platform === Web && state.enabledProviderIds.length === 0) {
|
|
3445
|
+
return [{
|
|
3446
|
+
command: '',
|
|
3447
|
+
icon: Refresh,
|
|
3448
|
+
id: refresh$1(),
|
|
3449
|
+
name: Refresh$1,
|
|
3450
|
+
type: Button
|
|
3451
|
+
}];
|
|
3452
|
+
}
|
|
3453
|
+
const actions = [{
|
|
3200
3454
|
command: '',
|
|
3201
3455
|
icon: ListFlat,
|
|
3202
3456
|
id: viewAsTree$1(),
|
|
@@ -3215,6 +3469,16 @@ const getActions = () => {
|
|
|
3215
3469
|
name: Refresh$1,
|
|
3216
3470
|
type: Button
|
|
3217
3471
|
}];
|
|
3472
|
+
if (state.showGenerateCommitMessageButton) {
|
|
3473
|
+
actions.splice(2, 0, {
|
|
3474
|
+
command: '',
|
|
3475
|
+
icon: DebugAlt2,
|
|
3476
|
+
id: generateCommitMessage(),
|
|
3477
|
+
name: GenerateCommitMessage,
|
|
3478
|
+
type: Button
|
|
3479
|
+
});
|
|
3480
|
+
}
|
|
3481
|
+
return actions;
|
|
3218
3482
|
};
|
|
3219
3483
|
|
|
3220
3484
|
const getActionButtonVirtualDom = action => {
|
|
@@ -3259,7 +3523,7 @@ const getActionsVirtualDom = actions => {
|
|
|
3259
3523
|
};
|
|
3260
3524
|
|
|
3261
3525
|
const renderActions = state => {
|
|
3262
|
-
const actions = getActions();
|
|
3526
|
+
const actions = getActions(state);
|
|
3263
3527
|
const dom = getActionsVirtualDom(actions);
|
|
3264
3528
|
return dom;
|
|
3265
3529
|
};
|
|
@@ -3298,6 +3562,9 @@ const renderEventListeners = () => {
|
|
|
3298
3562
|
}, {
|
|
3299
3563
|
name: HandleClickAction,
|
|
3300
3564
|
params: ['handleActionClick', TargetName]
|
|
3565
|
+
}, {
|
|
3566
|
+
name: HandleClickSourceControlButton,
|
|
3567
|
+
params: ['handleSourceControlButtonClick', TargetName]
|
|
3301
3568
|
}];
|
|
3302
3569
|
};
|
|
3303
3570
|
|
|
@@ -3358,12 +3625,14 @@ const commandMap = {
|
|
|
3358
3625
|
'SourceControl.getKeyBindings': getKeyBindings,
|
|
3359
3626
|
'SourceControl.getMenuEntries2': wrapGetter(getMenuEntries2),
|
|
3360
3627
|
'SourceControl.getMenuIds': getMenuIds,
|
|
3628
|
+
'SourceControl.getWorkspaceBadgeCount': getWorkspaceBadgeCount,
|
|
3361
3629
|
'SourceControl.handleActionClick': wrapCommand(handleActionClick),
|
|
3362
3630
|
'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
|
|
3363
3631
|
'SourceControl.handleClickAt': wrapCommand(handleClickAt),
|
|
3364
3632
|
'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
|
|
3365
3633
|
'SourceControl.handleContextMenu': wrapCommand(handleContextMenu),
|
|
3366
3634
|
'SourceControl.handleFocus': wrapCommand(handleInputFocus),
|
|
3635
|
+
'SourceControl.handleGenerateCommitMessage': wrapCommand(handleGenerateCommitMessage),
|
|
3367
3636
|
'SourceControl.handleInput': wrapCommand(handleInput),
|
|
3368
3637
|
'SourceControl.handleInputBlur': wrapCommand(handleInputBlur),
|
|
3369
3638
|
'SourceControl.handleMessagePort': handleMessagePort,
|
|
@@ -3371,6 +3640,7 @@ const commandMap = {
|
|
|
3371
3640
|
'SourceControl.handleMouseOutAt': wrapCommand(handleMouseOutAt),
|
|
3372
3641
|
'SourceControl.handleMouseOver': wrapCommand(handleMouseOver),
|
|
3373
3642
|
'SourceControl.handleMouseOverAt': wrapCommand(handleMouseOverAt),
|
|
3643
|
+
'SourceControl.handleSourceControlButtonClick': wrapCommand(handleSourceControlButtonClick),
|
|
3374
3644
|
'SourceControl.handleWheel': wrapCommand(handleWheel),
|
|
3375
3645
|
'SourceControl.handleWorkspaceRefresh': wrapCommand(handleWorkspaceRefresh),
|
|
3376
3646
|
'SourceControl.loadContent': wrapCommand(loadContent),
|
|
@@ -3390,7 +3660,7 @@ const commandMap = {
|
|
|
3390
3660
|
|
|
3391
3661
|
const listen = async () => {
|
|
3392
3662
|
registerCommands(commandMap);
|
|
3393
|
-
const rpc = await
|
|
3663
|
+
const rpc = await create$2({
|
|
3394
3664
|
commandMap: commandMap
|
|
3395
3665
|
});
|
|
3396
3666
|
set$2(rpc);
|