@lvce-editor/menu-worker 3.1.0 → 4.1.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/menuWorkerMain.js +628 -860
- package/package.json +1 -1
package/dist/menuWorkerMain.js
CHANGED
|
@@ -225,8 +225,8 @@ const getModuleNotFoundError = stderr => {
|
|
|
225
225
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
226
226
|
const message = lines[messageIndex];
|
|
227
227
|
return {
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
229
|
+
message
|
|
230
230
|
};
|
|
231
231
|
};
|
|
232
232
|
const isModuleNotFoundError = stderr => {
|
|
@@ -249,14 +249,14 @@ const isUnhelpfulNativeModuleError = stderr => {
|
|
|
249
249
|
const getNativeModuleErrorMessage = stderr => {
|
|
250
250
|
const message = getMessageCodeBlock(stderr);
|
|
251
251
|
return {
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
253
|
+
message: `Incompatible native node module: ${message}`
|
|
254
254
|
};
|
|
255
255
|
};
|
|
256
256
|
const getModuleSyntaxError = () => {
|
|
257
257
|
return {
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
259
|
+
message: `ES Modules are not supported in electron`
|
|
260
260
|
};
|
|
261
261
|
};
|
|
262
262
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -275,8 +275,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
275
275
|
rest
|
|
276
276
|
} = getDetails(lines);
|
|
277
277
|
return {
|
|
278
|
-
message: actualMessage,
|
|
279
278
|
code: '',
|
|
279
|
+
message: actualMessage,
|
|
280
280
|
stack: rest
|
|
281
281
|
};
|
|
282
282
|
};
|
|
@@ -286,8 +286,8 @@ class IpcError extends VError {
|
|
|
286
286
|
if (stdout || stderr) {
|
|
287
287
|
// @ts-ignore
|
|
288
288
|
const {
|
|
289
|
-
message,
|
|
290
289
|
code,
|
|
290
|
+
message,
|
|
291
291
|
stack
|
|
292
292
|
} = getHelpfulChildProcessError(stdout, stderr);
|
|
293
293
|
const cause = new Error(message);
|
|
@@ -348,8 +348,8 @@ const wrap$f = global => {
|
|
|
348
348
|
};
|
|
349
349
|
const waitForFirstMessage = async port => {
|
|
350
350
|
const {
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
promise,
|
|
352
|
+
resolve
|
|
353
353
|
} = Promise.withResolvers();
|
|
354
354
|
port.addEventListener('message', resolve, {
|
|
355
355
|
once: true
|
|
@@ -369,8 +369,8 @@ const listen$6 = async () => {
|
|
|
369
369
|
const type = firstMessage.params[0];
|
|
370
370
|
if (type === 'message-port') {
|
|
371
371
|
parentIpc.send({
|
|
372
|
-
jsonrpc: '2.0',
|
|
373
372
|
id: firstMessage.id,
|
|
373
|
+
jsonrpc: '2.0',
|
|
374
374
|
result: null
|
|
375
375
|
});
|
|
376
376
|
parentIpc.dispose();
|
|
@@ -427,8 +427,8 @@ const removeListener = (emitter, type, callback) => {
|
|
|
427
427
|
};
|
|
428
428
|
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
429
429
|
const {
|
|
430
|
-
|
|
431
|
-
|
|
430
|
+
promise,
|
|
431
|
+
resolve
|
|
432
432
|
} = Promise.withResolvers();
|
|
433
433
|
const listenerMap = Object.create(null);
|
|
434
434
|
const cleanup = value => {
|
|
@@ -440,8 +440,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
440
440
|
for (const [event, type] of Object.entries(eventMap)) {
|
|
441
441
|
const listener = event => {
|
|
442
442
|
cleanup({
|
|
443
|
-
|
|
444
|
-
|
|
443
|
+
event,
|
|
444
|
+
type
|
|
445
445
|
});
|
|
446
446
|
};
|
|
447
447
|
addListener(eventEmitter, event, listener);
|
|
@@ -451,8 +451,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
451
451
|
};
|
|
452
452
|
const Message$1 = 3;
|
|
453
453
|
const create$5$1 = async ({
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
isMessagePortOpen,
|
|
455
|
+
messagePort
|
|
456
456
|
}) => {
|
|
457
457
|
if (!isMessagePort(messagePort)) {
|
|
458
458
|
throw new IpcError('port must be of type MessagePort');
|
|
@@ -465,8 +465,8 @@ const create$5$1 = async ({
|
|
|
465
465
|
});
|
|
466
466
|
messagePort.start();
|
|
467
467
|
const {
|
|
468
|
-
|
|
469
|
-
|
|
468
|
+
event,
|
|
469
|
+
type
|
|
470
470
|
} = await eventPromise;
|
|
471
471
|
if (type !== Message$1) {
|
|
472
472
|
throw new IpcError('Failed to wait for ipc message');
|
|
@@ -506,56 +506,35 @@ const IpcParentWithMessagePort$1 = {
|
|
|
506
506
|
wrap: wrap$5
|
|
507
507
|
};
|
|
508
508
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
509
|
+
class CommandNotFoundError extends Error {
|
|
510
|
+
constructor(command) {
|
|
511
|
+
super(`Command not found ${command}`);
|
|
512
|
+
this.name = 'CommandNotFoundError';
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
const commands = Object.create(null);
|
|
516
|
+
const register = commandMap => {
|
|
517
|
+
Object.assign(commands, commandMap);
|
|
516
518
|
};
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
519
|
+
const getCommand = key => {
|
|
520
|
+
return commands[key];
|
|
521
|
+
};
|
|
522
|
+
const execute = (command, ...args) => {
|
|
523
|
+
const fn = getCommand(command);
|
|
524
|
+
if (!fn) {
|
|
525
|
+
throw new CommandNotFoundError(command);
|
|
526
|
+
}
|
|
527
|
+
return fn(...args);
|
|
520
528
|
};
|
|
529
|
+
|
|
530
|
+
const Two$1 = '2.0';
|
|
531
|
+
const callbacks = Object.create(null);
|
|
521
532
|
const get$3 = id => {
|
|
522
533
|
return callbacks[id];
|
|
523
534
|
};
|
|
524
|
-
const remove = id => {
|
|
535
|
+
const remove$1 = id => {
|
|
525
536
|
delete callbacks[id];
|
|
526
537
|
};
|
|
527
|
-
let id$a = 0;
|
|
528
|
-
const create$3$1 = () => {
|
|
529
|
-
return ++id$a;
|
|
530
|
-
};
|
|
531
|
-
const registerPromise = () => {
|
|
532
|
-
const id = create$3$1();
|
|
533
|
-
const {
|
|
534
|
-
resolve,
|
|
535
|
-
promise
|
|
536
|
-
} = Promise.withResolvers();
|
|
537
|
-
set$5(id, resolve);
|
|
538
|
-
return {
|
|
539
|
-
id,
|
|
540
|
-
promise
|
|
541
|
-
};
|
|
542
|
-
};
|
|
543
|
-
const create$2$1 = (method, params) => {
|
|
544
|
-
const {
|
|
545
|
-
id,
|
|
546
|
-
promise
|
|
547
|
-
} = registerPromise();
|
|
548
|
-
const message = {
|
|
549
|
-
jsonrpc: Two,
|
|
550
|
-
method,
|
|
551
|
-
params,
|
|
552
|
-
id
|
|
553
|
-
};
|
|
554
|
-
return {
|
|
555
|
-
message,
|
|
556
|
-
promise
|
|
557
|
-
};
|
|
558
|
-
};
|
|
559
538
|
class JsonRpcError extends Error {
|
|
560
539
|
constructor(message) {
|
|
561
540
|
super(message);
|
|
@@ -572,12 +551,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
572
551
|
switch (type) {
|
|
573
552
|
case DomException:
|
|
574
553
|
return DOMException;
|
|
575
|
-
case TypeError$1:
|
|
576
|
-
return TypeError;
|
|
577
|
-
case SyntaxError$1:
|
|
578
|
-
return SyntaxError;
|
|
579
554
|
case ReferenceError$1:
|
|
580
555
|
return ReferenceError;
|
|
556
|
+
case SyntaxError$1:
|
|
557
|
+
return SyntaxError;
|
|
558
|
+
case TypeError$1:
|
|
559
|
+
return TypeError;
|
|
581
560
|
default:
|
|
582
561
|
return Error;
|
|
583
562
|
}
|
|
@@ -706,7 +685,7 @@ const resolve = (id, response) => {
|
|
|
706
685
|
return;
|
|
707
686
|
}
|
|
708
687
|
fn(response);
|
|
709
|
-
remove(id);
|
|
688
|
+
remove$1(id);
|
|
710
689
|
};
|
|
711
690
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
712
691
|
const getErrorType = prettyError => {
|
|
@@ -733,27 +712,27 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
733
712
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
734
713
|
return {
|
|
735
714
|
code: MethodNotFound,
|
|
736
|
-
|
|
737
|
-
|
|
715
|
+
data: error.stack,
|
|
716
|
+
message: error.message
|
|
738
717
|
};
|
|
739
718
|
}
|
|
740
719
|
return {
|
|
741
720
|
code: Custom,
|
|
742
|
-
message: prettyError.message,
|
|
743
721
|
data: {
|
|
744
|
-
stack: getStack(prettyError),
|
|
745
|
-
codeFrame: prettyError.codeFrame,
|
|
746
|
-
type: getErrorType(prettyError),
|
|
747
722
|
code: prettyError.code,
|
|
748
|
-
|
|
749
|
-
|
|
723
|
+
codeFrame: prettyError.codeFrame,
|
|
724
|
+
name: prettyError.name,
|
|
725
|
+
stack: getStack(prettyError),
|
|
726
|
+
type: getErrorType(prettyError)
|
|
727
|
+
},
|
|
728
|
+
message: prettyError.message
|
|
750
729
|
};
|
|
751
730
|
};
|
|
752
731
|
const create$1$1 = (id, error) => {
|
|
753
732
|
return {
|
|
754
|
-
|
|
733
|
+
error,
|
|
755
734
|
id,
|
|
756
|
-
|
|
735
|
+
jsonrpc: Two$1
|
|
757
736
|
};
|
|
758
737
|
};
|
|
759
738
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
@@ -762,27 +741,27 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
762
741
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
763
742
|
return create$1$1(id, errorProperty);
|
|
764
743
|
};
|
|
765
|
-
const create$
|
|
744
|
+
const create$9 = (message, result) => {
|
|
766
745
|
return {
|
|
767
|
-
jsonrpc: Two,
|
|
768
746
|
id: message.id,
|
|
747
|
+
jsonrpc: Two$1,
|
|
769
748
|
result: result ?? null
|
|
770
749
|
};
|
|
771
750
|
};
|
|
772
751
|
const getSuccessResponse = (message, result) => {
|
|
773
752
|
const resultProperty = result ?? null;
|
|
774
|
-
return create$
|
|
753
|
+
return create$9(message, resultProperty);
|
|
775
754
|
};
|
|
776
755
|
const getErrorResponseSimple = (id, error) => {
|
|
777
756
|
return {
|
|
778
|
-
jsonrpc: Two,
|
|
779
|
-
id,
|
|
780
757
|
error: {
|
|
781
758
|
code: Custom,
|
|
759
|
+
data: error,
|
|
782
760
|
// @ts-ignore
|
|
783
|
-
message: error.message
|
|
784
|
-
|
|
785
|
-
|
|
761
|
+
message: error.message
|
|
762
|
+
},
|
|
763
|
+
id,
|
|
764
|
+
jsonrpc: Two$1
|
|
786
765
|
};
|
|
787
766
|
};
|
|
788
767
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -812,35 +791,35 @@ const normalizeParams = args => {
|
|
|
812
791
|
if (args.length === 1) {
|
|
813
792
|
const options = args[0];
|
|
814
793
|
return {
|
|
794
|
+
execute: options.execute,
|
|
815
795
|
ipc: options.ipc,
|
|
796
|
+
logError: options.logError || defaultLogError,
|
|
816
797
|
message: options.message,
|
|
817
|
-
execute: options.execute,
|
|
818
|
-
resolve: options.resolve || defaultResolve,
|
|
819
798
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
820
|
-
|
|
821
|
-
|
|
799
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
800
|
+
resolve: options.resolve || defaultResolve
|
|
822
801
|
};
|
|
823
802
|
}
|
|
824
803
|
return {
|
|
804
|
+
execute: args[2],
|
|
825
805
|
ipc: args[0],
|
|
806
|
+
logError: args[5],
|
|
826
807
|
message: args[1],
|
|
827
|
-
execute: args[2],
|
|
828
|
-
resolve: args[3],
|
|
829
808
|
preparePrettyError: args[4],
|
|
830
|
-
|
|
831
|
-
|
|
809
|
+
requiresSocket: args[6],
|
|
810
|
+
resolve: args[3]
|
|
832
811
|
};
|
|
833
812
|
};
|
|
834
813
|
const handleJsonRpcMessage = async (...args) => {
|
|
835
814
|
const options = normalizeParams(args);
|
|
836
815
|
const {
|
|
837
|
-
message,
|
|
838
|
-
ipc,
|
|
839
816
|
execute,
|
|
840
|
-
|
|
841
|
-
preparePrettyError,
|
|
817
|
+
ipc,
|
|
842
818
|
logError,
|
|
843
|
-
|
|
819
|
+
message,
|
|
820
|
+
preparePrettyError,
|
|
821
|
+
requiresSocket,
|
|
822
|
+
resolve
|
|
844
823
|
} = options;
|
|
845
824
|
if ('id' in message) {
|
|
846
825
|
if ('method' in message) {
|
|
@@ -862,11 +841,51 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
862
841
|
}
|
|
863
842
|
throw new JsonRpcError('unexpected message');
|
|
864
843
|
};
|
|
865
|
-
|
|
844
|
+
|
|
845
|
+
const Two = '2.0';
|
|
846
|
+
|
|
847
|
+
const create$8 = (method, params) => {
|
|
848
|
+
return {
|
|
849
|
+
jsonrpc: Two,
|
|
850
|
+
method,
|
|
851
|
+
params
|
|
852
|
+
};
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
const create$7 = (id, method, params) => {
|
|
856
|
+
const message = {
|
|
857
|
+
id,
|
|
858
|
+
jsonrpc: Two,
|
|
859
|
+
method,
|
|
860
|
+
params
|
|
861
|
+
};
|
|
862
|
+
return message;
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
let id$a = 0;
|
|
866
|
+
const create$6 = () => {
|
|
867
|
+
return ++id$a;
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
const registerPromise = map => {
|
|
871
|
+
const id = create$6();
|
|
866
872
|
const {
|
|
867
|
-
|
|
873
|
+
promise,
|
|
874
|
+
resolve
|
|
875
|
+
} = Promise.withResolvers();
|
|
876
|
+
map[id] = resolve;
|
|
877
|
+
return {
|
|
878
|
+
id,
|
|
879
|
+
promise
|
|
880
|
+
};
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
884
|
+
const {
|
|
885
|
+
id,
|
|
868
886
|
promise
|
|
869
|
-
} =
|
|
887
|
+
} = registerPromise(callbacks);
|
|
888
|
+
const message = create$7(id, method, params);
|
|
870
889
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
871
890
|
ipc.sendAndTransfer(message);
|
|
872
891
|
} else {
|
|
@@ -875,60 +894,40 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
875
894
|
const responseMessage = await promise;
|
|
876
895
|
return unwrapJsonRpcResult(responseMessage);
|
|
877
896
|
};
|
|
878
|
-
const send$1 = (transport, method, ...params) => {
|
|
879
|
-
const message = create$4(method, params);
|
|
880
|
-
transport.send(message);
|
|
881
|
-
};
|
|
882
|
-
const invoke$4 = (ipc, method, ...params) => {
|
|
883
|
-
return invokeHelper(ipc, method, params, false);
|
|
884
|
-
};
|
|
885
|
-
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
886
|
-
return invokeHelper(ipc, method, params, true);
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
class CommandNotFoundError extends Error {
|
|
890
|
-
constructor(command) {
|
|
891
|
-
super(`Command not found ${command}`);
|
|
892
|
-
this.name = 'CommandNotFoundError';
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
const commands = Object.create(null);
|
|
896
|
-
const register = commandMap => {
|
|
897
|
-
Object.assign(commands, commandMap);
|
|
898
|
-
};
|
|
899
|
-
const getCommand = key => {
|
|
900
|
-
return commands[key];
|
|
901
|
-
};
|
|
902
|
-
const execute = (command, ...args) => {
|
|
903
|
-
const fn = getCommand(command);
|
|
904
|
-
if (!fn) {
|
|
905
|
-
throw new CommandNotFoundError(command);
|
|
906
|
-
}
|
|
907
|
-
return fn(...args);
|
|
908
|
-
};
|
|
909
|
-
|
|
910
897
|
const createRpc = ipc => {
|
|
898
|
+
const callbacks = Object.create(null);
|
|
899
|
+
ipc._resolve = (id, response) => {
|
|
900
|
+
const fn = callbacks[id];
|
|
901
|
+
if (!fn) {
|
|
902
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
fn(response);
|
|
906
|
+
delete callbacks[id];
|
|
907
|
+
};
|
|
911
908
|
const rpc = {
|
|
909
|
+
async dispose() {
|
|
910
|
+
await ipc?.dispose();
|
|
911
|
+
},
|
|
912
|
+
invoke(method, ...params) {
|
|
913
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
914
|
+
},
|
|
915
|
+
invokeAndTransfer(method, ...params) {
|
|
916
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
917
|
+
},
|
|
912
918
|
// @ts-ignore
|
|
913
919
|
ipc,
|
|
914
920
|
/**
|
|
915
921
|
* @deprecated
|
|
916
922
|
*/
|
|
917
923
|
send(method, ...params) {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
invoke(method, ...params) {
|
|
921
|
-
return invoke$4(ipc, method, ...params);
|
|
922
|
-
},
|
|
923
|
-
invokeAndTransfer(method, ...params) {
|
|
924
|
-
return invokeAndTransfer$1(ipc, method, ...params);
|
|
925
|
-
},
|
|
926
|
-
async dispose() {
|
|
927
|
-
await ipc?.dispose();
|
|
924
|
+
const message = create$8(method, params);
|
|
925
|
+
ipc.send(message);
|
|
928
926
|
}
|
|
929
927
|
};
|
|
930
928
|
return rpc;
|
|
931
929
|
};
|
|
930
|
+
|
|
932
931
|
const requiresSocket = () => {
|
|
933
932
|
return false;
|
|
934
933
|
};
|
|
@@ -941,8 +940,9 @@ const logError = () => {
|
|
|
941
940
|
const handleMessage = event => {
|
|
942
941
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
943
942
|
const actualExecute = event?.target?.execute || execute;
|
|
944
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
943
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
945
944
|
};
|
|
945
|
+
|
|
946
946
|
const handleIpc = ipc => {
|
|
947
947
|
if ('addEventListener' in ipc) {
|
|
948
948
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -951,6 +951,7 @@ const handleIpc = ipc => {
|
|
|
951
951
|
ipc.on('message', handleMessage);
|
|
952
952
|
}
|
|
953
953
|
};
|
|
954
|
+
|
|
954
955
|
const listen$1 = async (module, options) => {
|
|
955
956
|
const rawIpc = await module.listen(options);
|
|
956
957
|
if (module.signal) {
|
|
@@ -959,15 +960,17 @@ const listen$1 = async (module, options) => {
|
|
|
959
960
|
const ipc = module.wrap(rawIpc);
|
|
960
961
|
return ipc;
|
|
961
962
|
};
|
|
963
|
+
|
|
962
964
|
const create$5 = async ({
|
|
963
965
|
commandMap,
|
|
966
|
+
isMessagePortOpen = true,
|
|
964
967
|
messagePort
|
|
965
968
|
}) => {
|
|
966
969
|
// TODO create a commandMap per rpc instance
|
|
967
970
|
register(commandMap);
|
|
968
971
|
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
969
|
-
|
|
970
|
-
|
|
972
|
+
isMessagePortOpen,
|
|
973
|
+
messagePort
|
|
971
974
|
});
|
|
972
975
|
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
973
976
|
handleIpc(ipc);
|
|
@@ -975,8 +978,10 @@ const create$5 = async ({
|
|
|
975
978
|
messagePort.start();
|
|
976
979
|
return rpc;
|
|
977
980
|
};
|
|
978
|
-
|
|
981
|
+
|
|
982
|
+
const create$4 = async ({
|
|
979
983
|
commandMap,
|
|
984
|
+
isMessagePortOpen,
|
|
980
985
|
send
|
|
981
986
|
}) => {
|
|
982
987
|
const {
|
|
@@ -986,13 +991,53 @@ const create$3 = async ({
|
|
|
986
991
|
await send(port1);
|
|
987
992
|
return create$5({
|
|
988
993
|
commandMap,
|
|
994
|
+
isMessagePortOpen,
|
|
989
995
|
messagePort: port2
|
|
990
996
|
});
|
|
991
997
|
};
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
998
|
+
|
|
999
|
+
const createSharedLazyRpc = factory => {
|
|
1000
|
+
let rpcPromise;
|
|
1001
|
+
const getOrCreate = () => {
|
|
1002
|
+
if (!rpcPromise) {
|
|
1003
|
+
rpcPromise = factory();
|
|
1004
|
+
}
|
|
1005
|
+
return rpcPromise;
|
|
1006
|
+
};
|
|
1007
|
+
return {
|
|
1008
|
+
async dispose() {
|
|
1009
|
+
const rpc = await getOrCreate();
|
|
1010
|
+
await rpc.dispose();
|
|
1011
|
+
},
|
|
1012
|
+
async invoke(method, ...params) {
|
|
1013
|
+
const rpc = await getOrCreate();
|
|
1014
|
+
return rpc.invoke(method, ...params);
|
|
1015
|
+
},
|
|
1016
|
+
async invokeAndTransfer(method, ...params) {
|
|
1017
|
+
const rpc = await getOrCreate();
|
|
1018
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1019
|
+
},
|
|
1020
|
+
async send(method, ...params) {
|
|
1021
|
+
const rpc = await getOrCreate();
|
|
1022
|
+
rpc.send(method, ...params);
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
995
1025
|
};
|
|
1026
|
+
|
|
1027
|
+
const create$3 = async ({
|
|
1028
|
+
commandMap,
|
|
1029
|
+
isMessagePortOpen,
|
|
1030
|
+
send
|
|
1031
|
+
}) => {
|
|
1032
|
+
return createSharedLazyRpc(() => {
|
|
1033
|
+
return create$4({
|
|
1034
|
+
commandMap,
|
|
1035
|
+
isMessagePortOpen,
|
|
1036
|
+
send
|
|
1037
|
+
});
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
|
|
996
1041
|
const create$2 = async ({
|
|
997
1042
|
commandMap
|
|
998
1043
|
}) => {
|
|
@@ -1003,10 +1048,7 @@ const create$2 = async ({
|
|
|
1003
1048
|
const rpc = createRpc(ipc);
|
|
1004
1049
|
return rpc;
|
|
1005
1050
|
};
|
|
1006
|
-
|
|
1007
|
-
__proto__: null,
|
|
1008
|
-
create: create$2
|
|
1009
|
-
};
|
|
1051
|
+
|
|
1010
1052
|
const createMockRpc = ({
|
|
1011
1053
|
commandMap
|
|
1012
1054
|
}) => {
|
|
@@ -1020,13 +1062,62 @@ const createMockRpc = ({
|
|
|
1020
1062
|
return command(...params);
|
|
1021
1063
|
};
|
|
1022
1064
|
const mockRpc = {
|
|
1065
|
+
invocations,
|
|
1023
1066
|
invoke,
|
|
1024
|
-
invokeAndTransfer: invoke
|
|
1025
|
-
invocations
|
|
1067
|
+
invokeAndTransfer: invoke
|
|
1026
1068
|
};
|
|
1027
1069
|
return mockRpc;
|
|
1028
1070
|
};
|
|
1029
1071
|
|
|
1072
|
+
const rpcs = Object.create(null);
|
|
1073
|
+
const set$4 = (id, rpc) => {
|
|
1074
|
+
rpcs[id] = rpc;
|
|
1075
|
+
};
|
|
1076
|
+
const get$2 = id => {
|
|
1077
|
+
return rpcs[id];
|
|
1078
|
+
};
|
|
1079
|
+
const remove = id => {
|
|
1080
|
+
delete rpcs[id];
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1084
|
+
const create$1 = rpcId => {
|
|
1085
|
+
return {
|
|
1086
|
+
async dispose() {
|
|
1087
|
+
const rpc = get$2(rpcId);
|
|
1088
|
+
await rpc.dispose();
|
|
1089
|
+
},
|
|
1090
|
+
// @ts-ignore
|
|
1091
|
+
invoke(method, ...params) {
|
|
1092
|
+
const rpc = get$2(rpcId);
|
|
1093
|
+
// @ts-ignore
|
|
1094
|
+
return rpc.invoke(method, ...params);
|
|
1095
|
+
},
|
|
1096
|
+
// @ts-ignore
|
|
1097
|
+
invokeAndTransfer(method, ...params) {
|
|
1098
|
+
const rpc = get$2(rpcId);
|
|
1099
|
+
// @ts-ignore
|
|
1100
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1101
|
+
},
|
|
1102
|
+
registerMockRpc(commandMap) {
|
|
1103
|
+
const mockRpc = createMockRpc({
|
|
1104
|
+
commandMap
|
|
1105
|
+
});
|
|
1106
|
+
set$4(rpcId, mockRpc);
|
|
1107
|
+
// @ts-ignore
|
|
1108
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1109
|
+
remove(rpcId);
|
|
1110
|
+
};
|
|
1111
|
+
// @ts-ignore
|
|
1112
|
+
return mockRpc;
|
|
1113
|
+
},
|
|
1114
|
+
set(rpc) {
|
|
1115
|
+
set$4(rpcId, rpc);
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
const Div$1 = 4;
|
|
1030
1121
|
const Text = 12;
|
|
1031
1122
|
|
|
1032
1123
|
const Button = 'event.button';
|
|
@@ -1166,34 +1257,14 @@ const Plus = '+';
|
|
|
1166
1257
|
|
|
1167
1258
|
const getKeyCodeString = keyCode => {
|
|
1168
1259
|
switch (keyCode) {
|
|
1260
|
+
case Backquote$1:
|
|
1261
|
+
return Backquote;
|
|
1262
|
+
case Backslash$1:
|
|
1263
|
+
return Backslash;
|
|
1169
1264
|
case Backspace$1:
|
|
1170
1265
|
return Backspace;
|
|
1171
|
-
case
|
|
1172
|
-
return
|
|
1173
|
-
case Escape$1:
|
|
1174
|
-
return Escape;
|
|
1175
|
-
case Enter$1:
|
|
1176
|
-
return Enter;
|
|
1177
|
-
case Space$1:
|
|
1178
|
-
return Space;
|
|
1179
|
-
case PageUp$1:
|
|
1180
|
-
return PageUp;
|
|
1181
|
-
case PageDown$1:
|
|
1182
|
-
return PageDown;
|
|
1183
|
-
case End$1:
|
|
1184
|
-
return End;
|
|
1185
|
-
case Home$1:
|
|
1186
|
-
return Home;
|
|
1187
|
-
case LeftArrow$1:
|
|
1188
|
-
return LeftArrow;
|
|
1189
|
-
case UpArrow$1:
|
|
1190
|
-
return UpArrow;
|
|
1191
|
-
case RightArrow$1:
|
|
1192
|
-
return RightArrow;
|
|
1193
|
-
case DownArrow$1:
|
|
1194
|
-
return DownArrow;
|
|
1195
|
-
case Insert$1:
|
|
1196
|
-
return Insert;
|
|
1266
|
+
case Comma$1:
|
|
1267
|
+
return Comma;
|
|
1197
1268
|
case Delete$1:
|
|
1198
1269
|
return Delete;
|
|
1199
1270
|
case Digit0$1:
|
|
@@ -1216,6 +1287,32 @@ const getKeyCodeString = keyCode => {
|
|
|
1216
1287
|
return Digit8;
|
|
1217
1288
|
case Digit9$1:
|
|
1218
1289
|
return Digit9;
|
|
1290
|
+
case DownArrow$1:
|
|
1291
|
+
return DownArrow;
|
|
1292
|
+
case End$1:
|
|
1293
|
+
return End;
|
|
1294
|
+
case Enter$1:
|
|
1295
|
+
return Enter;
|
|
1296
|
+
case Equal$1:
|
|
1297
|
+
return Equal;
|
|
1298
|
+
case Escape$1:
|
|
1299
|
+
return Escape;
|
|
1300
|
+
case F1$1:
|
|
1301
|
+
return F1;
|
|
1302
|
+
case F2$1:
|
|
1303
|
+
return F2;
|
|
1304
|
+
case F3$1:
|
|
1305
|
+
return F3;
|
|
1306
|
+
case F4$1:
|
|
1307
|
+
return F4;
|
|
1308
|
+
case F5$1:
|
|
1309
|
+
return F5;
|
|
1310
|
+
case F6$1:
|
|
1311
|
+
return F6;
|
|
1312
|
+
case Home$1:
|
|
1313
|
+
return Home;
|
|
1314
|
+
case Insert$1:
|
|
1315
|
+
return Insert;
|
|
1219
1316
|
case KeyA$1:
|
|
1220
1317
|
return KeyA;
|
|
1221
1318
|
case KeyB$1:
|
|
@@ -1268,45 +1365,39 @@ const getKeyCodeString = keyCode => {
|
|
|
1268
1365
|
return KeyY;
|
|
1269
1366
|
case KeyZ$1:
|
|
1270
1367
|
return KeyZ;
|
|
1271
|
-
case
|
|
1272
|
-
return
|
|
1273
|
-
case
|
|
1274
|
-
return
|
|
1275
|
-
case
|
|
1276
|
-
return
|
|
1277
|
-
case
|
|
1278
|
-
return
|
|
1279
|
-
case F5$1:
|
|
1280
|
-
return F5;
|
|
1281
|
-
case F6$1:
|
|
1282
|
-
return F6;
|
|
1283
|
-
case Backslash$1:
|
|
1284
|
-
return Backslash;
|
|
1285
|
-
case Equal$1:
|
|
1286
|
-
return Equal;
|
|
1287
|
-
case Comma$1:
|
|
1288
|
-
return Comma;
|
|
1289
|
-
case Backquote$1:
|
|
1290
|
-
return Backquote;
|
|
1368
|
+
case LeftArrow$1:
|
|
1369
|
+
return LeftArrow;
|
|
1370
|
+
case Minus$1:
|
|
1371
|
+
return Minus;
|
|
1372
|
+
case PageDown$1:
|
|
1373
|
+
return PageDown;
|
|
1374
|
+
case PageUp$1:
|
|
1375
|
+
return PageUp;
|
|
1291
1376
|
case Plus$1:
|
|
1292
1377
|
return Plus;
|
|
1378
|
+
case RightArrow$1:
|
|
1379
|
+
return RightArrow;
|
|
1380
|
+
case Space$1:
|
|
1381
|
+
return Space;
|
|
1293
1382
|
case Star$1:
|
|
1294
1383
|
return Star;
|
|
1295
|
-
case
|
|
1296
|
-
return
|
|
1384
|
+
case Tab$1:
|
|
1385
|
+
return Tab;
|
|
1386
|
+
case UpArrow$1:
|
|
1387
|
+
return UpArrow;
|
|
1297
1388
|
default:
|
|
1298
1389
|
return Unknown;
|
|
1299
1390
|
}
|
|
1300
1391
|
};
|
|
1301
1392
|
|
|
1302
|
-
const Script = 2;
|
|
1303
|
-
|
|
1304
1393
|
const CtrlCmd = 1 << 11 >>> 0;
|
|
1305
1394
|
const Shift = 1 << 10 >>> 0;
|
|
1306
1395
|
|
|
1307
1396
|
const Separator$2 = 1;
|
|
1308
1397
|
const None$1 = 0;
|
|
1309
1398
|
const SubMenu$1 = 4;
|
|
1399
|
+
const Checked$1 = 2;
|
|
1400
|
+
const Unchecked$1 = 3;
|
|
1310
1401
|
const Disabled$1 = 5;
|
|
1311
1402
|
const RestoreFocus$1 = 6;
|
|
1312
1403
|
const Ignore$1 = 7;
|
|
@@ -1317,435 +1408,64 @@ const parseKey = rawKey => {
|
|
|
1317
1408
|
const keyCode = rawKey & 0x00_00_00_ff;
|
|
1318
1409
|
const key = getKeyCodeString(keyCode);
|
|
1319
1410
|
return {
|
|
1320
|
-
key,
|
|
1321
1411
|
isCtrl,
|
|
1322
|
-
isShift
|
|
1323
|
-
|
|
1324
|
-
};
|
|
1325
|
-
|
|
1326
|
-
const DebugWorker = 55;
|
|
1327
|
-
const RendererProcess = 1670;
|
|
1328
|
-
const RendererWorker$1 = 1;
|
|
1329
|
-
|
|
1330
|
-
const FocusSelector = 'Viewlet.focusSelector';
|
|
1331
|
-
|
|
1332
|
-
const rpcs = Object.create(null);
|
|
1333
|
-
const set$4 = (id, rpc) => {
|
|
1334
|
-
rpcs[id] = rpc;
|
|
1335
|
-
};
|
|
1336
|
-
const get$2 = id => {
|
|
1337
|
-
return rpcs[id];
|
|
1338
|
-
};
|
|
1339
|
-
|
|
1340
|
-
const create$1 = rpcId => {
|
|
1341
|
-
return {
|
|
1342
|
-
// @ts-ignore
|
|
1343
|
-
invoke(method, ...params) {
|
|
1344
|
-
const rpc = get$2(rpcId);
|
|
1345
|
-
// @ts-ignore
|
|
1346
|
-
return rpc.invoke(method, ...params);
|
|
1347
|
-
},
|
|
1348
|
-
// @ts-ignore
|
|
1349
|
-
invokeAndTransfer(method, ...params) {
|
|
1350
|
-
const rpc = get$2(rpcId);
|
|
1351
|
-
// @ts-ignore
|
|
1352
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1353
|
-
},
|
|
1354
|
-
set(rpc) {
|
|
1355
|
-
set$4(rpcId, rpc);
|
|
1356
|
-
},
|
|
1357
|
-
async dispose() {
|
|
1358
|
-
const rpc = get$2(rpcId);
|
|
1359
|
-
await rpc.dispose();
|
|
1360
|
-
}
|
|
1412
|
+
isShift,
|
|
1413
|
+
key
|
|
1361
1414
|
};
|
|
1362
1415
|
};
|
|
1363
1416
|
|
|
1364
|
-
const
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
const
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
} = create$1(
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
};
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
const showContextMenu = async (x, y, id, ...args) => {
|
|
1384
|
-
return invoke$2('ContextMenu.show', x, y, id, ...args);
|
|
1385
|
-
};
|
|
1386
|
-
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1387
|
-
number(uid);
|
|
1388
|
-
number(menuId);
|
|
1389
|
-
number(x);
|
|
1390
|
-
number(y);
|
|
1391
|
-
// @ts-ignore
|
|
1392
|
-
await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1393
|
-
};
|
|
1394
|
-
const getElectronVersion = async () => {
|
|
1395
|
-
return invoke$2('Process.getElectronVersion');
|
|
1396
|
-
};
|
|
1397
|
-
const applyBulkReplacement = async bulkEdits => {
|
|
1398
|
-
await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
|
|
1399
|
-
};
|
|
1400
|
-
const setColorTheme = async id => {
|
|
1401
|
-
// @ts-ignore
|
|
1402
|
-
return invoke$2(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
1403
|
-
};
|
|
1404
|
-
const getNodeVersion = async () => {
|
|
1405
|
-
return invoke$2('Process.getNodeVersion');
|
|
1406
|
-
};
|
|
1407
|
-
const getChromeVersion = async () => {
|
|
1408
|
-
return invoke$2('Process.getChromeVersion');
|
|
1409
|
-
};
|
|
1410
|
-
const getV8Version = async () => {
|
|
1411
|
-
return invoke$2('Process.getV8Version');
|
|
1412
|
-
};
|
|
1413
|
-
const getFileHandles = async fileIds => {
|
|
1414
|
-
const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
|
|
1415
|
-
return files;
|
|
1416
|
-
};
|
|
1417
|
-
const setWorkspacePath = async path => {
|
|
1418
|
-
await invoke$2('Workspace.setPath', path);
|
|
1419
|
-
};
|
|
1420
|
-
const registerWebViewInterceptor = async (id, port) => {
|
|
1421
|
-
await invokeAndTransfer('WebView.registerInterceptor', id, port);
|
|
1422
|
-
};
|
|
1423
|
-
const unregisterWebViewInterceptor = async id => {
|
|
1424
|
-
await invoke$2('WebView.unregisterInterceptor', id);
|
|
1425
|
-
};
|
|
1426
|
-
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1427
|
-
const command = 'HandleMessagePort.handleMessagePort';
|
|
1428
|
-
// @ts-ignore
|
|
1429
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1430
|
-
};
|
|
1431
|
-
const sendMessagePortToErrorWorker = async (port, rpcId) => {
|
|
1432
|
-
const command = 'Errors.handleMessagePort';
|
|
1433
|
-
// @ts-ignore
|
|
1434
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1435
|
-
};
|
|
1436
|
-
const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
|
|
1437
|
-
const command = 'Markdown.handleMessagePort';
|
|
1438
|
-
// @ts-ignore
|
|
1439
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
|
|
1440
|
-
};
|
|
1441
|
-
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1442
|
-
const command = 'IconTheme.handleMessagePort';
|
|
1443
|
-
// @ts-ignore
|
|
1444
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
1445
|
-
};
|
|
1446
|
-
const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
|
|
1447
|
-
const command = 'FileSystem.handleMessagePort';
|
|
1448
|
-
// @ts-ignore
|
|
1449
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1450
|
-
};
|
|
1451
|
-
const readFile = async uri => {
|
|
1452
|
-
return invoke$2('FileSystem.readFile', uri);
|
|
1453
|
-
};
|
|
1454
|
-
const getWebViewSecret = async key => {
|
|
1455
|
-
// @ts-ignore
|
|
1456
|
-
return invoke$2('WebView.getSecret', key);
|
|
1457
|
-
};
|
|
1458
|
-
const setWebViewPort = async (uid, port, origin, portType) => {
|
|
1459
|
-
return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
|
|
1460
|
-
};
|
|
1461
|
-
const setFocus = key => {
|
|
1462
|
-
return invoke$2('Focus.setFocus', key);
|
|
1463
|
-
};
|
|
1464
|
-
const getFileIcon = async options => {
|
|
1465
|
-
return invoke$2('IconTheme.getFileIcon', options);
|
|
1466
|
-
};
|
|
1467
|
-
const getColorThemeNames = async () => {
|
|
1468
|
-
return invoke$2('ColorTheme.getColorThemeNames');
|
|
1469
|
-
};
|
|
1470
|
-
const disableExtension = async id => {
|
|
1471
|
-
// @ts-ignore
|
|
1472
|
-
return invoke$2('ExtensionManagement.disable', id);
|
|
1473
|
-
};
|
|
1474
|
-
const enableExtension = async id => {
|
|
1475
|
-
// @ts-ignore
|
|
1476
|
-
return invoke$2('ExtensionManagement.enable', id);
|
|
1477
|
-
};
|
|
1478
|
-
const handleDebugChange = async params => {
|
|
1479
|
-
// @ts-ignore
|
|
1480
|
-
return invoke$2('Run And Debug.handleChange', params);
|
|
1481
|
-
};
|
|
1482
|
-
const getFolderIcon = async options => {
|
|
1483
|
-
return invoke$2('IconTheme.getFolderIcon', options);
|
|
1484
|
-
};
|
|
1485
|
-
const closeWidget = async widgetId => {
|
|
1486
|
-
return invoke$2('Viewlet.closeWidget', widgetId);
|
|
1487
|
-
};
|
|
1488
|
-
const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
|
|
1489
|
-
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1490
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1491
|
-
};
|
|
1492
|
-
const sendMessagePortToSearchProcess = async port => {
|
|
1493
|
-
await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
|
|
1494
|
-
};
|
|
1495
|
-
const confirm = async (message, options) => {
|
|
1496
|
-
// @ts-ignore
|
|
1497
|
-
const result = await invoke$2('ConfirmPrompt.prompt', message, options);
|
|
1498
|
-
return result;
|
|
1499
|
-
};
|
|
1500
|
-
const getRecentlyOpened$1 = async () => {
|
|
1501
|
-
return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
1502
|
-
};
|
|
1503
|
-
const getKeyBindings$1 = async () => {
|
|
1504
|
-
return invoke$2('KeyBindingsInitial.getKeyBindings');
|
|
1505
|
-
};
|
|
1506
|
-
const writeClipBoardText = async text => {
|
|
1507
|
-
await invoke$2('ClipBoard.writeText', /* text */text);
|
|
1508
|
-
};
|
|
1509
|
-
const readClipBoardText = async () => {
|
|
1510
|
-
return invoke$2('ClipBoard.readText');
|
|
1511
|
-
};
|
|
1512
|
-
const writeClipBoardImage = async blob => {
|
|
1513
|
-
// @ts-ignore
|
|
1514
|
-
await invoke$2('ClipBoard.writeImage', /* text */blob);
|
|
1515
|
-
};
|
|
1516
|
-
const searchFileMemory = async uri => {
|
|
1517
|
-
// @ts-ignore
|
|
1518
|
-
return invoke$2('ExtensionHost.searchFileWithMemory', uri);
|
|
1519
|
-
};
|
|
1520
|
-
const searchFileFetch = async uri => {
|
|
1521
|
-
return invoke$2('ExtensionHost.searchFileWithFetch', uri);
|
|
1522
|
-
};
|
|
1523
|
-
const showMessageBox = async options => {
|
|
1524
|
-
return invoke$2('ElectronDialog.showMessageBox', options);
|
|
1525
|
-
};
|
|
1526
|
-
const handleDebugResumed = async params => {
|
|
1527
|
-
await invoke$2('Run And Debug.handleResumed', params);
|
|
1528
|
-
};
|
|
1529
|
-
const openWidget = async name => {
|
|
1530
|
-
await invoke$2('Viewlet.openWidget', name);
|
|
1531
|
-
};
|
|
1532
|
-
const getIcons = async requests => {
|
|
1533
|
-
const icons = await invoke$2('IconTheme.getIcons', requests);
|
|
1534
|
-
return icons;
|
|
1535
|
-
};
|
|
1536
|
-
const activateByEvent = event => {
|
|
1537
|
-
return invoke$2('ExtensionHostManagement.activateByEvent', event);
|
|
1538
|
-
};
|
|
1539
|
-
const setAdditionalFocus = focusKey => {
|
|
1540
|
-
// @ts-ignore
|
|
1541
|
-
return invoke$2('Focus.setAdditionalFocus', focusKey);
|
|
1542
|
-
};
|
|
1543
|
-
const getActiveEditorId = () => {
|
|
1544
|
-
// @ts-ignore
|
|
1545
|
-
return invoke$2('GetActiveEditor.getActiveEditorId');
|
|
1546
|
-
};
|
|
1547
|
-
const getWorkspacePath = () => {
|
|
1548
|
-
return invoke$2('Workspace.getPath');
|
|
1549
|
-
};
|
|
1550
|
-
const sendMessagePortToRendererProcess = async port => {
|
|
1551
|
-
const command = 'HandleMessagePort.handleMessagePort';
|
|
1552
|
-
// @ts-ignore
|
|
1553
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
|
|
1554
|
-
};
|
|
1555
|
-
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
1556
|
-
const command = 'TextMeasurement.handleMessagePort';
|
|
1557
|
-
// @ts-ignore
|
|
1558
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1559
|
-
};
|
|
1560
|
-
const sendMessagePortToSourceControlWorker = async port => {
|
|
1561
|
-
const command = 'SourceControl.handleMessagePort';
|
|
1562
|
-
// @ts-ignore
|
|
1563
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
|
|
1564
|
-
};
|
|
1565
|
-
const getPreference = async key => {
|
|
1566
|
-
return await invoke$2('Preferences.get', key);
|
|
1567
|
-
};
|
|
1568
|
-
const getAllExtensions = async () => {
|
|
1569
|
-
return invoke$2('ExtensionManagement.getAllExtensions');
|
|
1570
|
-
};
|
|
1571
|
-
const rerenderEditor = async key => {
|
|
1572
|
-
// @ts-ignore
|
|
1573
|
-
return invoke$2('Editor.rerender', key);
|
|
1574
|
-
};
|
|
1575
|
-
const handleDebugPaused = async params => {
|
|
1576
|
-
await invoke$2('Run And Debug.handlePaused', params);
|
|
1577
|
-
};
|
|
1578
|
-
const openUri = async (uri, focus, options) => {
|
|
1579
|
-
await invoke$2('Main.openUri', uri, focus, options);
|
|
1580
|
-
};
|
|
1581
|
-
const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
1582
|
-
await invokeAndTransfer(
|
|
1583
|
-
// @ts-ignore
|
|
1584
|
-
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
|
|
1585
|
-
};
|
|
1586
|
-
const handleDebugScriptParsed = async script => {
|
|
1587
|
-
await invoke$2('Run And Debug.handleScriptParsed', script);
|
|
1588
|
-
};
|
|
1589
|
-
const getWindowId = async () => {
|
|
1590
|
-
return invoke$2('GetWindowId.getWindowId');
|
|
1591
|
-
};
|
|
1592
|
-
const getBlob = async uri => {
|
|
1593
|
-
// @ts-ignore
|
|
1594
|
-
return invoke$2('FileSystem.getBlob', uri);
|
|
1595
|
-
};
|
|
1596
|
-
const getExtensionCommands = async () => {
|
|
1597
|
-
return invoke$2('ExtensionHost.getCommands');
|
|
1598
|
-
};
|
|
1599
|
-
const showErrorDialog = async errorInfo => {
|
|
1600
|
-
// @ts-ignore
|
|
1601
|
-
await invoke$2('ErrorHandling.showErrorDialog', errorInfo);
|
|
1602
|
-
};
|
|
1603
|
-
const getFolderSize = async uri => {
|
|
1604
|
-
// @ts-ignore
|
|
1605
|
-
return await invoke$2('FileSystem.getFolderSize', uri);
|
|
1606
|
-
};
|
|
1607
|
-
const getExtension = async id => {
|
|
1608
|
-
// @ts-ignore
|
|
1609
|
-
return invoke$2('ExtensionManagement.getExtension', id);
|
|
1610
|
-
};
|
|
1611
|
-
const getMarkdownDom = async html => {
|
|
1612
|
-
// @ts-ignore
|
|
1613
|
-
return invoke$2('Markdown.getVirtualDom', html);
|
|
1614
|
-
};
|
|
1615
|
-
const renderMarkdown = async (markdown, options) => {
|
|
1616
|
-
// @ts-ignore
|
|
1617
|
-
return invoke$2('Markdown.renderMarkdown', markdown, options);
|
|
1618
|
-
};
|
|
1619
|
-
const openNativeFolder = async uri => {
|
|
1620
|
-
// @ts-ignore
|
|
1621
|
-
await invoke$2('OpenNativeFolder.openNativeFolder', uri);
|
|
1622
|
-
};
|
|
1623
|
-
const uninstallExtension = async id => {
|
|
1624
|
-
return invoke$2('ExtensionManagement.uninstall', id);
|
|
1625
|
-
};
|
|
1626
|
-
const installExtension = async id => {
|
|
1627
|
-
// @ts-ignore
|
|
1628
|
-
return invoke$2('ExtensionManagement.install', id);
|
|
1629
|
-
};
|
|
1630
|
-
const openExtensionSearch = async () => {
|
|
1631
|
-
// @ts-ignore
|
|
1632
|
-
return invoke$2('SideBar.openViewlet', 'Extensions');
|
|
1633
|
-
};
|
|
1634
|
-
const setExtensionsSearchValue = async searchValue => {
|
|
1635
|
-
// @ts-ignore
|
|
1636
|
-
return invoke$2('Extensions.handleInput', searchValue, Script);
|
|
1637
|
-
};
|
|
1638
|
-
const openExternal = async uri => {
|
|
1639
|
-
// @ts-ignore
|
|
1640
|
-
await invoke$2('Open.openExternal', uri);
|
|
1641
|
-
};
|
|
1642
|
-
const openUrl = async uri => {
|
|
1643
|
-
// @ts-ignore
|
|
1644
|
-
await invoke$2('Open.openUrl', uri);
|
|
1645
|
-
};
|
|
1646
|
-
const getAllPreferences = async () => {
|
|
1647
|
-
// @ts-ignore
|
|
1648
|
-
return invoke$2('Preferences.getAll');
|
|
1649
|
-
};
|
|
1650
|
-
const showSaveFilePicker = async () => {
|
|
1651
|
-
// @ts-ignore
|
|
1652
|
-
return invoke$2('FilePicker.showSaveFilePicker');
|
|
1653
|
-
};
|
|
1654
|
-
const getLogsDir = async () => {
|
|
1655
|
-
// @ts-ignore
|
|
1656
|
-
return invoke$2('PlatformPaths.getLogsDir');
|
|
1417
|
+
const DebugWorker = 55;
|
|
1418
|
+
const RendererProcess = 1670;
|
|
1419
|
+
const RendererWorker$1 = 1;
|
|
1420
|
+
|
|
1421
|
+
const FocusSelector = 'Viewlet.focusSelector';
|
|
1422
|
+
|
|
1423
|
+
const {
|
|
1424
|
+
invoke: invoke$3,
|
|
1425
|
+
set: set$3
|
|
1426
|
+
} = create$1(RendererProcess);
|
|
1427
|
+
|
|
1428
|
+
const {
|
|
1429
|
+
invoke: invoke$2,
|
|
1430
|
+
invokeAndTransfer,
|
|
1431
|
+
set: set$2
|
|
1432
|
+
} = create$1(RendererWorker$1);
|
|
1433
|
+
const sendMessagePortToRendererProcess = async port => {
|
|
1434
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1435
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
|
|
1657
1436
|
};
|
|
1658
|
-
const
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1661
|
-
});
|
|
1662
|
-
set$2(mockRpc);
|
|
1663
|
-
return mockRpc;
|
|
1437
|
+
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
1438
|
+
const command = 'TextMeasurement.handleMessagePort';
|
|
1439
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1664
1440
|
};
|
|
1665
1441
|
|
|
1666
1442
|
const RendererWorker = {
|
|
1667
1443
|
__proto__: null,
|
|
1668
|
-
activateByEvent,
|
|
1669
|
-
applyBulkReplacement,
|
|
1670
|
-
closeWidget,
|
|
1671
|
-
confirm,
|
|
1672
|
-
disableExtension,
|
|
1673
|
-
dispose,
|
|
1674
|
-
enableExtension,
|
|
1675
|
-
getActiveEditorId,
|
|
1676
|
-
getAllExtensions,
|
|
1677
|
-
getAllPreferences,
|
|
1678
|
-
getBlob,
|
|
1679
|
-
getChromeVersion,
|
|
1680
|
-
getColorThemeNames,
|
|
1681
|
-
getElectronVersion,
|
|
1682
|
-
getExtension,
|
|
1683
|
-
getExtensionCommands,
|
|
1684
|
-
getFileHandles,
|
|
1685
|
-
getFileIcon,
|
|
1686
|
-
getFilePathElectron,
|
|
1687
|
-
getFolderIcon,
|
|
1688
|
-
getFolderSize,
|
|
1689
|
-
getIcons,
|
|
1690
|
-
getKeyBindings: getKeyBindings$1,
|
|
1691
|
-
getLogsDir,
|
|
1692
|
-
getMarkdownDom,
|
|
1693
|
-
getNodeVersion,
|
|
1694
|
-
getPreference,
|
|
1695
|
-
getRecentlyOpened: getRecentlyOpened$1,
|
|
1696
|
-
getV8Version,
|
|
1697
|
-
getWebViewSecret,
|
|
1698
|
-
getWindowId,
|
|
1699
|
-
getWorkspacePath,
|
|
1700
|
-
handleDebugChange,
|
|
1701
|
-
handleDebugPaused,
|
|
1702
|
-
handleDebugResumed,
|
|
1703
|
-
handleDebugScriptParsed,
|
|
1704
|
-
installExtension,
|
|
1705
1444
|
invoke: invoke$2,
|
|
1706
1445
|
invokeAndTransfer,
|
|
1707
|
-
openExtensionSearch,
|
|
1708
|
-
openExternal,
|
|
1709
|
-
openNativeFolder,
|
|
1710
|
-
openUri,
|
|
1711
|
-
openUrl,
|
|
1712
|
-
openWidget,
|
|
1713
|
-
readClipBoardText,
|
|
1714
|
-
readFile,
|
|
1715
|
-
registerMockRpc,
|
|
1716
|
-
registerWebViewInterceptor,
|
|
1717
|
-
renderMarkdown,
|
|
1718
|
-
rerenderEditor,
|
|
1719
|
-
searchFileFetch,
|
|
1720
|
-
searchFileHtml,
|
|
1721
|
-
searchFileMemory,
|
|
1722
|
-
sendMessagePortToEditorWorker,
|
|
1723
|
-
sendMessagePortToErrorWorker,
|
|
1724
|
-
sendMessagePortToExtensionHostWorker,
|
|
1725
|
-
sendMessagePortToFileSystemWorker,
|
|
1726
|
-
sendMessagePortToIconThemeWorker,
|
|
1727
|
-
sendMessagePortToMarkdownWorker,
|
|
1728
1446
|
sendMessagePortToRendererProcess,
|
|
1729
|
-
sendMessagePortToSearchProcess,
|
|
1730
|
-
sendMessagePortToSourceControlWorker,
|
|
1731
|
-
sendMessagePortToSyntaxHighlightingWorker,
|
|
1732
1447
|
sendMessagePortToTextMeasurementWorker,
|
|
1733
|
-
set: set$2
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1448
|
+
set: set$2
|
|
1449
|
+
};
|
|
1450
|
+
|
|
1451
|
+
const send$1 = port => {
|
|
1452
|
+
return sendMessagePortToRendererProcess(port);
|
|
1453
|
+
};
|
|
1454
|
+
const createRendererProcessRpc = async () => {
|
|
1455
|
+
try {
|
|
1456
|
+
const rpc = await create$4({
|
|
1457
|
+
commandMap: {},
|
|
1458
|
+
send: send$1
|
|
1459
|
+
});
|
|
1460
|
+
return rpc;
|
|
1461
|
+
} catch (error) {
|
|
1462
|
+
throw new VError(error, `Failed to create renderer process rpc`);
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
|
|
1466
|
+
const initializeRendererProcess = async () => {
|
|
1467
|
+
const rpc = await createRendererProcessRpc();
|
|
1468
|
+
set$3(rpc);
|
|
1749
1469
|
};
|
|
1750
1470
|
|
|
1751
1471
|
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
@@ -1758,8 +1478,9 @@ const RendererWorker = {
|
|
|
1758
1478
|
// TODO this code seems a bit too complicated, maybe it can be simplified
|
|
1759
1479
|
|
|
1760
1480
|
const state$1 = {
|
|
1761
|
-
|
|
1762
|
-
|
|
1481
|
+
latestTimeStamp: 0,
|
|
1482
|
+
menus: []
|
|
1483
|
+
};
|
|
1763
1484
|
const addMenuInternal = menu => {
|
|
1764
1485
|
if (state$1.menus.length > 5) {
|
|
1765
1486
|
throw new Error('too many menus');
|
|
@@ -1796,6 +1517,54 @@ const closeSubMenu = async () => {
|
|
|
1796
1517
|
await invoke$3(/* Menu.hideSubMenu */7903, /* parentIndex */parentMenu.focusedIndex);
|
|
1797
1518
|
};
|
|
1798
1519
|
|
|
1520
|
+
const send = port => {
|
|
1521
|
+
return sendMessagePortToTextMeasurementWorker(port);
|
|
1522
|
+
};
|
|
1523
|
+
const createTextMeasurementWorkerRpc = async () => {
|
|
1524
|
+
try {
|
|
1525
|
+
const rpc = await create$3({
|
|
1526
|
+
commandMap: {},
|
|
1527
|
+
send
|
|
1528
|
+
});
|
|
1529
|
+
return rpc;
|
|
1530
|
+
} catch (error) {
|
|
1531
|
+
throw new VError(error, `Failed to create text measurement worker rpc`);
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
|
|
1535
|
+
let rpcPromise;
|
|
1536
|
+
const getRpc = () => {
|
|
1537
|
+
rpcPromise ||= createTextMeasurementWorkerRpc();
|
|
1538
|
+
return rpcPromise;
|
|
1539
|
+
};
|
|
1540
|
+
const measureTextWidths = async (texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth) => {
|
|
1541
|
+
const rpc = await getRpc();
|
|
1542
|
+
return rpc.invoke('TextMeasurement.measureTextWidths', texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth);
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
const FontWeight = 400;
|
|
1546
|
+
const FontSize = 13;
|
|
1547
|
+
const FontFamily = 'system-ui, Ubuntu, Droid Sans, sans-serif';
|
|
1548
|
+
const LetterSpacing = 0;
|
|
1549
|
+
const IsMonospaceFont = false;
|
|
1550
|
+
const CharWidth = 8;
|
|
1551
|
+
const getLabels = items => {
|
|
1552
|
+
return items.map(item => item.label).filter(label => typeof label === 'string' && label);
|
|
1553
|
+
};
|
|
1554
|
+
const getMenuLabelWidths = async items => {
|
|
1555
|
+
const labels = getLabels(items);
|
|
1556
|
+
return measureTextWidths(labels, FontWeight, FontSize, FontFamily, LetterSpacing, IsMonospaceFont, CharWidth);
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
const MENU_MIN_WIDTH = 150;
|
|
1560
|
+
const MENU_ITEM_HORIZONTAL_PADDING = 56;
|
|
1561
|
+
const MENU_ITEM_HORIZONTAL_MARGIN = 8;
|
|
1562
|
+
const getMenuMeasuredWidth = async items => {
|
|
1563
|
+
const labelWidths = await getMenuLabelWidths(items);
|
|
1564
|
+
const maxLabelWidth = Math.max(0, ...labelWidths);
|
|
1565
|
+
return Math.ceil(Math.max(MENU_MIN_WIDTH, maxLabelWidth + MENU_ITEM_HORIZONTAL_PADDING + MENU_ITEM_HORIZONTAL_MARGIN));
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1799
1568
|
const Separator$1 = 1;
|
|
1800
1569
|
const None = 0;
|
|
1801
1570
|
const SubMenu = 4;
|
|
@@ -1806,7 +1575,7 @@ const RestoreFocus = 6;
|
|
|
1806
1575
|
const Ignore = 7;
|
|
1807
1576
|
|
|
1808
1577
|
// TODO lazyload menuEntries and use Command.execute (maybe)
|
|
1809
|
-
const
|
|
1578
|
+
const MENU_TARGET_GAP = 5;
|
|
1810
1579
|
|
|
1811
1580
|
// TODO difference between focusing with mouse or keyboard
|
|
1812
1581
|
// with mouse -> open submenu
|
|
@@ -1837,8 +1606,8 @@ const getMenuHeight$1 = items => {
|
|
|
1837
1606
|
}
|
|
1838
1607
|
return height;
|
|
1839
1608
|
};
|
|
1840
|
-
const getMenuBounds = (x, y, items) => {
|
|
1841
|
-
const menuWidth =
|
|
1609
|
+
const getMenuBounds = async (x, y, items) => {
|
|
1610
|
+
const menuWidth = await getMenuMeasuredWidth(items);
|
|
1842
1611
|
const menuHeight = getMenuHeight$1(items);
|
|
1843
1612
|
const layoutState = {
|
|
1844
1613
|
points: [0, 0]
|
|
@@ -1849,7 +1618,7 @@ const getMenuBounds = (x, y, items) => {
|
|
|
1849
1618
|
// TODO what about separators?
|
|
1850
1619
|
|
|
1851
1620
|
if (x + menuWidth > windowWidth) {
|
|
1852
|
-
x -= menuWidth;
|
|
1621
|
+
x -= menuWidth + MENU_TARGET_GAP;
|
|
1853
1622
|
x = Math.max(x, 0);
|
|
1854
1623
|
}
|
|
1855
1624
|
if (y + menuHeight > windowHeight) {
|
|
@@ -1857,10 +1626,10 @@ const getMenuBounds = (x, y, items) => {
|
|
|
1857
1626
|
y = Math.max(y, 0);
|
|
1858
1627
|
}
|
|
1859
1628
|
return {
|
|
1860
|
-
|
|
1861
|
-
y,
|
|
1629
|
+
height: menuHeight,
|
|
1862
1630
|
width: menuWidth,
|
|
1863
|
-
|
|
1631
|
+
x,
|
|
1632
|
+
y
|
|
1864
1633
|
};
|
|
1865
1634
|
};
|
|
1866
1635
|
|
|
@@ -1934,7 +1703,8 @@ const UiStrings$2 = {
|
|
|
1934
1703
|
SelectAll: 'Select All',
|
|
1935
1704
|
ToggleBlockComment: 'Toggle Block Comment',
|
|
1936
1705
|
ToggleLineComment: 'Toggle Line Comment',
|
|
1937
|
-
Undo: 'Undo'
|
|
1706
|
+
Undo: 'Undo'
|
|
1707
|
+
};
|
|
1938
1708
|
const cut = () => {
|
|
1939
1709
|
return i18nString(UiStrings$2.Cut);
|
|
1940
1710
|
};
|
|
@@ -1984,49 +1754,49 @@ const TitleBar = 15;
|
|
|
1984
1754
|
const View$1 = 16;
|
|
1985
1755
|
|
|
1986
1756
|
const menuEntrySeparator = {
|
|
1987
|
-
|
|
1988
|
-
label: '',
|
|
1757
|
+
command: '',
|
|
1989
1758
|
flags: Separator$2,
|
|
1990
|
-
|
|
1759
|
+
id: 'separator',
|
|
1760
|
+
label: ''
|
|
1991
1761
|
};
|
|
1992
1762
|
|
|
1993
1763
|
const id$9 = Edit$1;
|
|
1994
1764
|
const getMenuEntries$d = () => {
|
|
1995
1765
|
return [{
|
|
1996
|
-
|
|
1997
|
-
label: undo(),
|
|
1766
|
+
command: /* TODO */'-1',
|
|
1998
1767
|
flags: Disabled,
|
|
1999
|
-
|
|
1768
|
+
id: 'undo',
|
|
1769
|
+
label: undo()
|
|
2000
1770
|
}, {
|
|
2001
|
-
|
|
2002
|
-
label: redo(),
|
|
1771
|
+
command: /* TODO */'-1',
|
|
2003
1772
|
flags: Disabled,
|
|
2004
|
-
|
|
1773
|
+
id: 'redo',
|
|
1774
|
+
label: redo()
|
|
2005
1775
|
}, menuEntrySeparator, {
|
|
2006
|
-
|
|
2007
|
-
label: cut(),
|
|
1776
|
+
command: /* Editor.cut */'Editor.cut',
|
|
2008
1777
|
flags: None,
|
|
2009
|
-
|
|
1778
|
+
id: 'cut',
|
|
1779
|
+
label: cut()
|
|
2010
1780
|
}, {
|
|
2011
|
-
|
|
2012
|
-
label: copy(),
|
|
1781
|
+
command: /* Editor.copy */'Editor.copy',
|
|
2013
1782
|
flags: None,
|
|
2014
|
-
|
|
1783
|
+
id: 'copy',
|
|
1784
|
+
label: copy()
|
|
2015
1785
|
}, {
|
|
2016
|
-
|
|
2017
|
-
label: paste(),
|
|
1786
|
+
command: /* Editor.paste */'Editor.paste',
|
|
2018
1787
|
flags: None,
|
|
2019
|
-
|
|
1788
|
+
id: 'paste',
|
|
1789
|
+
label: paste()
|
|
2020
1790
|
}, menuEntrySeparator, {
|
|
2021
|
-
|
|
2022
|
-
label: toggleLineComment(),
|
|
1791
|
+
command: /* Editor.toggleLineComment */'Editor.toggleLineComment',
|
|
2023
1792
|
flags: None,
|
|
2024
|
-
|
|
1793
|
+
id: 'toggle-line-comment',
|
|
1794
|
+
label: toggleLineComment()
|
|
2025
1795
|
}, {
|
|
2026
|
-
|
|
2027
|
-
label: toggleBlockComment(),
|
|
1796
|
+
command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment',
|
|
2028
1797
|
flags: None,
|
|
2029
|
-
|
|
1798
|
+
id: 'toggle-block-comment',
|
|
1799
|
+
label: toggleBlockComment()
|
|
2030
1800
|
}];
|
|
2031
1801
|
};
|
|
2032
1802
|
|
|
@@ -2040,15 +1810,14 @@ const MenuEntriesEdit = {
|
|
|
2040
1810
|
* @enum {string}
|
|
2041
1811
|
*/
|
|
2042
1812
|
const UiStrings$1 = {
|
|
1813
|
+
Exit: 'Exit',
|
|
2043
1814
|
NewFile: 'New File',
|
|
2044
1815
|
NewWindow: 'New Window',
|
|
2045
1816
|
OpenFile: 'Open File',
|
|
2046
1817
|
OpenFolder: 'Open Folder',
|
|
2047
1818
|
OpenRecent: 'Open Recent',
|
|
2048
|
-
Exit: 'Exit',
|
|
2049
1819
|
Save: 'Save',
|
|
2050
|
-
SaveAll: 'Save All'
|
|
2051
|
-
};
|
|
1820
|
+
SaveAll: 'Save All'};
|
|
2052
1821
|
const newFile = () => {
|
|
2053
1822
|
return i18nString(UiStrings$1.NewFile);
|
|
2054
1823
|
};
|
|
@@ -2080,47 +1849,47 @@ const Electron = 2;
|
|
|
2080
1849
|
const id$8 = File$2;
|
|
2081
1850
|
const getMenuEntries$c = platform => {
|
|
2082
1851
|
const entries = [{
|
|
2083
|
-
|
|
2084
|
-
label: newFile(),
|
|
1852
|
+
command: '-1',
|
|
2085
1853
|
flags: None,
|
|
2086
|
-
|
|
1854
|
+
id: 'newFile',
|
|
1855
|
+
label: newFile()
|
|
2087
1856
|
}, {
|
|
2088
|
-
|
|
2089
|
-
label: newWindow(),
|
|
1857
|
+
command: /* Window.openNew */'Window.openNew',
|
|
2090
1858
|
flags: None,
|
|
2091
|
-
|
|
1859
|
+
id: 'newWindow',
|
|
1860
|
+
label: newWindow()
|
|
2092
1861
|
}, menuEntrySeparator, {
|
|
2093
|
-
|
|
2094
|
-
label: openFile(),
|
|
1862
|
+
command: 'Dialog.openFile',
|
|
2095
1863
|
flags: None,
|
|
2096
|
-
|
|
1864
|
+
id: 'openFile',
|
|
1865
|
+
label: openFile()
|
|
2097
1866
|
}, {
|
|
2098
|
-
|
|
2099
|
-
label: openFolder(),
|
|
1867
|
+
command: 'Dialog.openFolder',
|
|
2100
1868
|
flags: RestoreFocus,
|
|
2101
|
-
|
|
1869
|
+
id: 'openFolder',
|
|
1870
|
+
label: openFolder()
|
|
2102
1871
|
}, {
|
|
2103
|
-
|
|
2104
|
-
label: openRecent(),
|
|
1872
|
+
command: '',
|
|
2105
1873
|
flags: SubMenu,
|
|
2106
|
-
|
|
1874
|
+
id: OpenRecent,
|
|
1875
|
+
label: openRecent()
|
|
2107
1876
|
}, menuEntrySeparator, {
|
|
2108
|
-
|
|
2109
|
-
label: save(),
|
|
1877
|
+
command: 'Main.save',
|
|
2110
1878
|
flags: None,
|
|
2111
|
-
|
|
1879
|
+
id: 'save',
|
|
1880
|
+
label: save()
|
|
2112
1881
|
}, {
|
|
2113
|
-
|
|
2114
|
-
label: saveAll(),
|
|
1882
|
+
command: 'Main.saveAll',
|
|
2115
1883
|
flags: None,
|
|
2116
|
-
|
|
1884
|
+
id: 'saveAll',
|
|
1885
|
+
label: saveAll()
|
|
2117
1886
|
}];
|
|
2118
1887
|
if (platform === Electron) {
|
|
2119
1888
|
entries.push(menuEntrySeparator, {
|
|
2120
|
-
|
|
2121
|
-
label: exit(),
|
|
1889
|
+
command: 'Chrome.exit',
|
|
2122
1890
|
flags: Ignore,
|
|
2123
|
-
|
|
1891
|
+
id: 'exit',
|
|
1892
|
+
label: exit()
|
|
2124
1893
|
});
|
|
2125
1894
|
}
|
|
2126
1895
|
return entries;
|
|
@@ -2170,25 +1939,25 @@ const getMenuEntries$a = async platform => {
|
|
|
2170
1939
|
const entries = [];
|
|
2171
1940
|
if (platform !== Web) {
|
|
2172
1941
|
entries.push({
|
|
2173
|
-
|
|
2174
|
-
label: toggleDeveloperTools(),
|
|
1942
|
+
command: 'Developer.toggleDeveloperTools',
|
|
2175
1943
|
flags: None,
|
|
2176
|
-
|
|
1944
|
+
id: 'toggleDeveloperTools',
|
|
1945
|
+
label: toggleDeveloperTools()
|
|
2177
1946
|
}, {
|
|
2178
|
-
|
|
2179
|
-
label: openProcessExplorer(),
|
|
1947
|
+
command: 'Developer.openProcessExplorer',
|
|
2180
1948
|
flags: RestoreFocus,
|
|
2181
|
-
|
|
1949
|
+
id: 'openProcessExplorer',
|
|
1950
|
+
label: openProcessExplorer()
|
|
2182
1951
|
});
|
|
2183
1952
|
}
|
|
2184
1953
|
if (entries.length > 0) {
|
|
2185
1954
|
entries.push(menuEntrySeparator);
|
|
2186
1955
|
}
|
|
2187
1956
|
entries.push({
|
|
2188
|
-
|
|
2189
|
-
label: about(),
|
|
1957
|
+
command: 'About.showAbout',
|
|
2190
1958
|
flags: None,
|
|
2191
|
-
|
|
1959
|
+
id: 'about',
|
|
1960
|
+
label: about()
|
|
2192
1961
|
});
|
|
2193
1962
|
return entries;
|
|
2194
1963
|
};
|
|
@@ -2199,8 +1968,9 @@ const MenuEntriesHelp = {
|
|
|
2199
1968
|
id: id$6
|
|
2200
1969
|
};
|
|
2201
1970
|
|
|
2202
|
-
const getRecentlyOpened = () => {
|
|
2203
|
-
|
|
1971
|
+
const getRecentlyOpened = async () => {
|
|
1972
|
+
const recentlyOpened = await invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
1973
|
+
return recentlyOpened;
|
|
2204
1974
|
};
|
|
2205
1975
|
|
|
2206
1976
|
const File = 'file://';
|
|
@@ -2224,10 +1994,10 @@ const toMenuItem = folder => {
|
|
|
2224
1994
|
const homeDir = getHomeDir();
|
|
2225
1995
|
const label = getTitle(homeDir, folder);
|
|
2226
1996
|
return {
|
|
2227
|
-
|
|
2228
|
-
flags: None,
|
|
1997
|
+
args: [folder],
|
|
2229
1998
|
command: 'Workspace.setPath',
|
|
2230
|
-
|
|
1999
|
+
flags: None,
|
|
2000
|
+
label
|
|
2231
2001
|
};
|
|
2232
2002
|
};
|
|
2233
2003
|
const id$5 = OpenRecent;
|
|
@@ -2239,15 +2009,15 @@ const getMenuEntries$9 = async () => {
|
|
|
2239
2009
|
items.push(...itemsToShow.map(toMenuItem), menuEntrySeparator);
|
|
2240
2010
|
}
|
|
2241
2011
|
items.push({
|
|
2242
|
-
|
|
2243
|
-
label: '...',
|
|
2012
|
+
command: 'QuickPick.showRecent',
|
|
2244
2013
|
flags: None,
|
|
2245
|
-
|
|
2014
|
+
id: 'more',
|
|
2015
|
+
label: '...'
|
|
2246
2016
|
}, menuEntrySeparator, {
|
|
2247
|
-
|
|
2248
|
-
label: 'clear',
|
|
2017
|
+
command: 'RecentlyOpened.clearRecentlyOpened',
|
|
2249
2018
|
flags: None,
|
|
2250
|
-
|
|
2019
|
+
id: 'clearRecentlyOpened',
|
|
2020
|
+
label: 'clear'
|
|
2251
2021
|
});
|
|
2252
2022
|
return items;
|
|
2253
2023
|
};
|
|
@@ -2272,30 +2042,30 @@ const MenuEntriesRun = {
|
|
|
2272
2042
|
const id$3 = Selection$1;
|
|
2273
2043
|
const getMenuEntries$7 = () => {
|
|
2274
2044
|
return [{
|
|
2275
|
-
|
|
2276
|
-
label: selectAll(),
|
|
2045
|
+
command: 'Editor.selectAll',
|
|
2277
2046
|
flags: None,
|
|
2278
|
-
|
|
2047
|
+
id: 'selectAll',
|
|
2048
|
+
label: selectAll()
|
|
2279
2049
|
}, {
|
|
2280
|
-
|
|
2281
|
-
label: copyLineUp(),
|
|
2050
|
+
command: 'Editor.copyLineUp',
|
|
2282
2051
|
flags: None,
|
|
2283
|
-
|
|
2052
|
+
id: 'copyLineUp',
|
|
2053
|
+
label: copyLineUp()
|
|
2284
2054
|
}, {
|
|
2285
|
-
|
|
2286
|
-
label: copyLineDown(),
|
|
2055
|
+
command: 'Editor.copyLineDown',
|
|
2287
2056
|
flags: None,
|
|
2288
|
-
|
|
2057
|
+
id: 'copyLineDown',
|
|
2058
|
+
label: copyLineDown()
|
|
2289
2059
|
}, {
|
|
2290
|
-
|
|
2291
|
-
label: moveLineUp(),
|
|
2060
|
+
command: 'Editor.moveLineUp',
|
|
2292
2061
|
flags: Disabled,
|
|
2293
|
-
|
|
2062
|
+
id: 'moveLineUp',
|
|
2063
|
+
label: moveLineUp()
|
|
2294
2064
|
}, {
|
|
2295
|
-
|
|
2296
|
-
label: moveLineDown(),
|
|
2065
|
+
command: 'Editor.moveLineDown',
|
|
2297
2066
|
flags: Disabled,
|
|
2298
|
-
|
|
2067
|
+
id: 'moveLineDown',
|
|
2068
|
+
label: moveLineDown()
|
|
2299
2069
|
}];
|
|
2300
2070
|
};
|
|
2301
2071
|
|
|
@@ -2309,8 +2079,7 @@ const MenuEntriesSelection = {
|
|
|
2309
2079
|
* @enum {string}
|
|
2310
2080
|
*/
|
|
2311
2081
|
const UiStrings = {
|
|
2312
|
-
NewTerminal: 'New Terminal'
|
|
2313
|
-
};
|
|
2082
|
+
NewTerminal: 'New Terminal'};
|
|
2314
2083
|
const newTerminal = () => {
|
|
2315
2084
|
return i18nString(UiStrings.NewTerminal);
|
|
2316
2085
|
};
|
|
@@ -2318,11 +2087,11 @@ const newTerminal = () => {
|
|
|
2318
2087
|
const id$2 = Terminal$1;
|
|
2319
2088
|
const getMenuEntries$6 = () => {
|
|
2320
2089
|
return [{
|
|
2321
|
-
|
|
2322
|
-
label: newTerminal(),
|
|
2323
|
-
flags: None,
|
|
2090
|
+
args: ['Terminal'],
|
|
2324
2091
|
command: 'Layout.togglePanel',
|
|
2325
|
-
|
|
2092
|
+
flags: None,
|
|
2093
|
+
id: 'newTerminal',
|
|
2094
|
+
label: newTerminal()
|
|
2326
2095
|
}];
|
|
2327
2096
|
};
|
|
2328
2097
|
|
|
@@ -2359,68 +2128,68 @@ const help = () => {
|
|
|
2359
2128
|
|
|
2360
2129
|
const getMenuEntries$5 = () => {
|
|
2361
2130
|
return [{
|
|
2131
|
+
flags: SubMenu,
|
|
2362
2132
|
id: File$2,
|
|
2363
|
-
label: file()
|
|
2364
|
-
flags: SubMenu
|
|
2133
|
+
label: file()
|
|
2365
2134
|
}, {
|
|
2135
|
+
flags: SubMenu,
|
|
2366
2136
|
id: Edit$1,
|
|
2367
|
-
label: edit()
|
|
2368
|
-
flags: SubMenu
|
|
2137
|
+
label: edit()
|
|
2369
2138
|
}, {
|
|
2139
|
+
flags: SubMenu,
|
|
2370
2140
|
id: Selection$1,
|
|
2371
|
-
label: selection()
|
|
2372
|
-
flags: SubMenu
|
|
2141
|
+
label: selection()
|
|
2373
2142
|
}, {
|
|
2143
|
+
flags: SubMenu,
|
|
2374
2144
|
id: View$1,
|
|
2375
|
-
label: view()
|
|
2376
|
-
flags: SubMenu
|
|
2145
|
+
label: view()
|
|
2377
2146
|
}, {
|
|
2147
|
+
flags: SubMenu,
|
|
2378
2148
|
id: Go$1,
|
|
2379
|
-
label: go()
|
|
2380
|
-
flags: SubMenu
|
|
2149
|
+
label: go()
|
|
2381
2150
|
}, {
|
|
2151
|
+
flags: SubMenu,
|
|
2382
2152
|
id: Run$1,
|
|
2383
|
-
label: run(),
|
|
2384
2153
|
keyboardShortCut: 'Alt+r',
|
|
2385
|
-
|
|
2154
|
+
label: run()
|
|
2386
2155
|
}, {
|
|
2156
|
+
flags: SubMenu,
|
|
2387
2157
|
id: Terminal$1,
|
|
2388
|
-
label: terminal(),
|
|
2389
2158
|
keyboardShortCut: 'Alt+t',
|
|
2390
|
-
|
|
2159
|
+
label: terminal()
|
|
2391
2160
|
}, {
|
|
2161
|
+
flags: SubMenu,
|
|
2392
2162
|
id: Help$1,
|
|
2393
|
-
label: help(),
|
|
2394
2163
|
keyboardShortCut: 'Alt+h',
|
|
2395
|
-
|
|
2164
|
+
label: help()
|
|
2396
2165
|
}];
|
|
2397
2166
|
};
|
|
2398
2167
|
|
|
2399
2168
|
const getMenuEntries$4 = () => {
|
|
2400
2169
|
return [{
|
|
2170
|
+
flags: None,
|
|
2401
2171
|
id: File$2,
|
|
2402
|
-
label: file()
|
|
2403
|
-
flags: None
|
|
2172
|
+
label: file()
|
|
2404
2173
|
}, {
|
|
2174
|
+
flags: None,
|
|
2405
2175
|
id: Edit$1,
|
|
2406
|
-
label: edit()
|
|
2407
|
-
flags: None
|
|
2176
|
+
label: edit()
|
|
2408
2177
|
}, {
|
|
2178
|
+
flags: None,
|
|
2409
2179
|
id: Selection$1,
|
|
2410
|
-
label: selection()
|
|
2411
|
-
flags: None
|
|
2180
|
+
label: selection()
|
|
2412
2181
|
}, {
|
|
2182
|
+
flags: None,
|
|
2413
2183
|
id: View$1,
|
|
2414
|
-
label: view()
|
|
2415
|
-
flags: None
|
|
2184
|
+
label: view()
|
|
2416
2185
|
}, {
|
|
2186
|
+
flags: None,
|
|
2417
2187
|
id: Go$1,
|
|
2418
|
-
label: go()
|
|
2419
|
-
flags: None
|
|
2188
|
+
label: go()
|
|
2420
2189
|
}, {
|
|
2190
|
+
flags: None,
|
|
2421
2191
|
id: Help$1,
|
|
2422
|
-
label: help()
|
|
2423
|
-
flags: None
|
|
2192
|
+
label: help()
|
|
2424
2193
|
}];
|
|
2425
2194
|
};
|
|
2426
2195
|
|
|
@@ -2517,9 +2286,9 @@ const mergeClassNames = (...classNames) => {
|
|
|
2517
2286
|
|
|
2518
2287
|
const text = data => {
|
|
2519
2288
|
return {
|
|
2520
|
-
|
|
2289
|
+
childCount: 0,
|
|
2521
2290
|
text: data,
|
|
2522
|
-
|
|
2291
|
+
type: Text
|
|
2523
2292
|
};
|
|
2524
2293
|
};
|
|
2525
2294
|
|
|
@@ -2527,16 +2296,16 @@ const Div = 4;
|
|
|
2527
2296
|
const Span = 8;
|
|
2528
2297
|
|
|
2529
2298
|
const checkboxChecked = {
|
|
2530
|
-
|
|
2299
|
+
ariaChecked: true,
|
|
2300
|
+
childCount: 2,
|
|
2531
2301
|
className: mergeClassNames(MenuItem, MenuItemCheckMark),
|
|
2532
2302
|
role: MenuItemCheckBox,
|
|
2533
|
-
ariaChecked: true,
|
|
2534
2303
|
tabIndex: -1,
|
|
2535
|
-
|
|
2304
|
+
type: Div
|
|
2536
2305
|
};
|
|
2537
2306
|
const checkMark = {
|
|
2538
|
-
|
|
2539
|
-
|
|
2307
|
+
className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck),
|
|
2308
|
+
type: Div
|
|
2540
2309
|
};
|
|
2541
2310
|
const getMenuItemCheckedDom = menuItem => {
|
|
2542
2311
|
const {
|
|
@@ -2559,41 +2328,41 @@ const getKeyBindingString = (key, altKey, ctrlKey, shiftKey, metaKey) => {
|
|
|
2559
2328
|
|
|
2560
2329
|
const getMenuItemDefaultDom = menuItem => {
|
|
2561
2330
|
const {
|
|
2562
|
-
label,
|
|
2563
2331
|
isFocused,
|
|
2564
|
-
key
|
|
2332
|
+
key,
|
|
2333
|
+
label
|
|
2565
2334
|
} = menuItem;
|
|
2566
2335
|
let className = MenuItem;
|
|
2567
2336
|
if (isFocused) {
|
|
2568
2337
|
className += ' ' + MenuItemFocused;
|
|
2569
2338
|
}
|
|
2570
2339
|
const dom = [{
|
|
2571
|
-
|
|
2340
|
+
childCount: 1,
|
|
2572
2341
|
className,
|
|
2573
2342
|
role: MenuItem$1,
|
|
2574
2343
|
tabIndex: -1,
|
|
2575
|
-
|
|
2344
|
+
type: Div
|
|
2576
2345
|
}, text(label)];
|
|
2577
2346
|
if (key) {
|
|
2578
2347
|
dom[0].childCount++;
|
|
2579
2348
|
const parsedKey = parseKey(key);
|
|
2580
2349
|
const keyBindingsString = getKeyBindingString(parsedKey.key, false, parsedKey.isCtrl, parsedKey.isShift);
|
|
2581
2350
|
dom.push({
|
|
2582
|
-
|
|
2351
|
+
childCount: 1,
|
|
2583
2352
|
className: MenuItemKeyBinding,
|
|
2584
|
-
|
|
2353
|
+
type: Span
|
|
2585
2354
|
}, text(keyBindingsString));
|
|
2586
2355
|
}
|
|
2587
2356
|
return dom;
|
|
2588
2357
|
};
|
|
2589
2358
|
|
|
2590
2359
|
const disabled = {
|
|
2591
|
-
|
|
2360
|
+
childCount: 1,
|
|
2592
2361
|
className: MenuItem,
|
|
2362
|
+
disabled: true,
|
|
2593
2363
|
role: MenuItem$1,
|
|
2594
2364
|
tabIndex: -1,
|
|
2595
|
-
|
|
2596
|
-
childCount: 1
|
|
2365
|
+
type: Div
|
|
2597
2366
|
};
|
|
2598
2367
|
const getMenuItemDisabledDom = menuItem => {
|
|
2599
2368
|
const {
|
|
@@ -2603,34 +2372,37 @@ const getMenuItemDisabledDom = menuItem => {
|
|
|
2603
2372
|
};
|
|
2604
2373
|
|
|
2605
2374
|
const getMenuItemsNoopDom = () => {
|
|
2606
|
-
return [
|
|
2375
|
+
return [{
|
|
2376
|
+
childCount: 1,
|
|
2377
|
+
type: Div$1
|
|
2378
|
+
}, text(`Unsupport menu item type`)];
|
|
2607
2379
|
};
|
|
2608
2380
|
|
|
2609
2381
|
const separator = {
|
|
2610
|
-
|
|
2382
|
+
childCount: 1,
|
|
2611
2383
|
className: MenuItemSeparator,
|
|
2612
2384
|
role: Separator,
|
|
2613
|
-
|
|
2385
|
+
type: Div
|
|
2614
2386
|
};
|
|
2615
2387
|
const separatorLine = {
|
|
2616
|
-
|
|
2388
|
+
childCount: 0,
|
|
2617
2389
|
className: MenuItemSeparatorLine,
|
|
2618
|
-
|
|
2390
|
+
type: Div
|
|
2619
2391
|
};
|
|
2620
2392
|
const getMenuItemSeparatorDom = menuItem => {
|
|
2621
2393
|
return [separator, separatorLine];
|
|
2622
2394
|
};
|
|
2623
2395
|
|
|
2624
2396
|
const arrowRight = {
|
|
2625
|
-
|
|
2397
|
+
childCount: 0,
|
|
2626
2398
|
className: MenuItemSubMenuArrowRight,
|
|
2627
|
-
|
|
2399
|
+
type: Div
|
|
2628
2400
|
};
|
|
2629
2401
|
const getMenuItemSubMenuDom = menuItem => {
|
|
2630
2402
|
const {
|
|
2631
|
-
label,
|
|
2632
|
-
isFocused,
|
|
2633
2403
|
isExpanded,
|
|
2404
|
+
isFocused,
|
|
2405
|
+
label,
|
|
2634
2406
|
level
|
|
2635
2407
|
} = menuItem;
|
|
2636
2408
|
let className = MenuItem;
|
|
@@ -2639,24 +2411,24 @@ const getMenuItemSubMenuDom = menuItem => {
|
|
|
2639
2411
|
className += ' ' + MenuItemFocused;
|
|
2640
2412
|
}
|
|
2641
2413
|
return [{
|
|
2642
|
-
|
|
2414
|
+
ariaExpanded: isExpanded,
|
|
2415
|
+
ariaHasPopup: true,
|
|
2416
|
+
ariaOwns: isExpanded ? `Menu-${level + 1}` : undefined,
|
|
2417
|
+
childCount: 2,
|
|
2643
2418
|
className,
|
|
2644
2419
|
role: MenuItem$1,
|
|
2645
2420
|
tabIndex: -1,
|
|
2646
|
-
|
|
2647
|
-
ariaExpanded: isExpanded,
|
|
2648
|
-
ariaOwns: isExpanded ? `Menu-${level + 1}` : undefined,
|
|
2649
|
-
childCount: 2
|
|
2421
|
+
type: Div
|
|
2650
2422
|
}, text(label), arrowRight];
|
|
2651
2423
|
};
|
|
2652
2424
|
|
|
2653
2425
|
const checkboxUnchecked = {
|
|
2654
|
-
|
|
2426
|
+
ariaChecked: false,
|
|
2427
|
+
childCount: 1,
|
|
2655
2428
|
className: MenuItem,
|
|
2656
2429
|
role: MenuItemCheckBox,
|
|
2657
|
-
ariaChecked: false,
|
|
2658
2430
|
tabIndex: -1,
|
|
2659
|
-
|
|
2431
|
+
type: Div
|
|
2660
2432
|
};
|
|
2661
2433
|
const getMenuItemUncheckedDom = menuItem => {
|
|
2662
2434
|
const {
|
|
@@ -2667,20 +2439,20 @@ const getMenuItemUncheckedDom = menuItem => {
|
|
|
2667
2439
|
|
|
2668
2440
|
const getMenuItemRenderer = flags => {
|
|
2669
2441
|
switch (flags) {
|
|
2442
|
+
case Checked:
|
|
2443
|
+
return getMenuItemCheckedDom;
|
|
2444
|
+
case Disabled:
|
|
2445
|
+
return getMenuItemDisabledDom;
|
|
2446
|
+
case Ignore:
|
|
2670
2447
|
case None:
|
|
2671
2448
|
case RestoreFocus:
|
|
2672
|
-
case Ignore:
|
|
2673
2449
|
return getMenuItemDefaultDom;
|
|
2674
2450
|
case Separator$1:
|
|
2675
2451
|
return getMenuItemSeparatorDom;
|
|
2676
|
-
case Checked:
|
|
2677
|
-
return getMenuItemCheckedDom;
|
|
2678
|
-
case Unchecked:
|
|
2679
|
-
return getMenuItemUncheckedDom;
|
|
2680
|
-
case Disabled:
|
|
2681
|
-
return getMenuItemDisabledDom;
|
|
2682
2452
|
case SubMenu:
|
|
2683
2453
|
return getMenuItemSubMenuDom;
|
|
2454
|
+
case Unchecked:
|
|
2455
|
+
return getMenuItemUncheckedDom;
|
|
2684
2456
|
default:
|
|
2685
2457
|
return getMenuItemsNoopDom;
|
|
2686
2458
|
}
|
|
@@ -2696,11 +2468,11 @@ const getMenuItemVirtualDom = menuItem => {
|
|
|
2696
2468
|
|
|
2697
2469
|
const getMenuVirtualDom = menuItems => {
|
|
2698
2470
|
const dom = [{
|
|
2699
|
-
|
|
2471
|
+
childCount: menuItems.length,
|
|
2700
2472
|
className: Menu,
|
|
2701
2473
|
role: Menu$1,
|
|
2702
2474
|
tabIndex: -1,
|
|
2703
|
-
|
|
2475
|
+
type: Div
|
|
2704
2476
|
}, ...menuItems.flatMap(getMenuItemVirtualDom)];
|
|
2705
2477
|
return dom;
|
|
2706
2478
|
};
|
|
@@ -2714,12 +2486,12 @@ const getVisible = (items, focusedIndex, expanded, level) => {
|
|
|
2714
2486
|
label
|
|
2715
2487
|
} = item;
|
|
2716
2488
|
visibleItems.push({
|
|
2717
|
-
label,
|
|
2718
2489
|
flags,
|
|
2719
|
-
isFocused: i === focusedIndex,
|
|
2720
2490
|
isExpanded: i === focusedIndex && expanded,
|
|
2721
|
-
|
|
2722
|
-
key: item.key
|
|
2491
|
+
isFocused: i === focusedIndex,
|
|
2492
|
+
key: item.key,
|
|
2493
|
+
label,
|
|
2494
|
+
level
|
|
2723
2495
|
});
|
|
2724
2496
|
}
|
|
2725
2497
|
return visibleItems;
|
|
@@ -2752,8 +2524,8 @@ const getMenuHeight = items => {
|
|
|
2752
2524
|
const getMenuHideCommands = async (restoreFocus = true) => {
|
|
2753
2525
|
if (getCount() === 0) {
|
|
2754
2526
|
return {
|
|
2755
|
-
|
|
2756
|
-
|
|
2527
|
+
commands: [],
|
|
2528
|
+
newMenus: []
|
|
2757
2529
|
};
|
|
2758
2530
|
}
|
|
2759
2531
|
reset();
|
|
@@ -2788,11 +2560,11 @@ const MENU_WIDTH = 150;
|
|
|
2788
2560
|
|
|
2789
2561
|
const show$2 = async (x, y, id, mouseBlocking = false, ...args) => {
|
|
2790
2562
|
const items = await getMenuEntriesWithKeyBindings(id, ...args);
|
|
2791
|
-
const bounds = getMenuBounds(x, y, items);
|
|
2563
|
+
const bounds = await getMenuBounds(x, y, items);
|
|
2792
2564
|
const menu = addMenuInternal({
|
|
2565
|
+
focusedIndex: -1,
|
|
2793
2566
|
id,
|
|
2794
2567
|
items,
|
|
2795
|
-
focusedIndex: -1,
|
|
2796
2568
|
level: getCount(),
|
|
2797
2569
|
x: bounds.x,
|
|
2798
2570
|
y: bounds.y
|
|
@@ -2803,11 +2575,11 @@ const show$2 = async (x, y, id, mouseBlocking = false, ...args) => {
|
|
|
2803
2575
|
};
|
|
2804
2576
|
const show2$2 = async (uid, menuId, x, y, mouseBlocking = false, ...args) => {
|
|
2805
2577
|
const items = await getMenuEntriesWithKeyBindings2(uid, menuId, ...args);
|
|
2806
|
-
const bounds = getMenuBounds(x, y, items);
|
|
2578
|
+
const bounds = await getMenuBounds(x, y, items);
|
|
2807
2579
|
const menu = addMenuInternal({
|
|
2580
|
+
focusedIndex: -1,
|
|
2808
2581
|
id: menuId,
|
|
2809
2582
|
items,
|
|
2810
|
-
focusedIndex: -1,
|
|
2811
2583
|
level: getCount(),
|
|
2812
2584
|
x: bounds.x,
|
|
2813
2585
|
y: bounds.y
|
|
@@ -2903,8 +2675,8 @@ const create = () => {
|
|
|
2903
2675
|
},
|
|
2904
2676
|
set(uid, oldState, newState) {
|
|
2905
2677
|
states[uid] = {
|
|
2906
|
-
|
|
2907
|
-
|
|
2678
|
+
newState,
|
|
2679
|
+
oldState
|
|
2908
2680
|
};
|
|
2909
2681
|
}
|
|
2910
2682
|
};
|
|
@@ -2917,16 +2689,16 @@ const {
|
|
|
2917
2689
|
|
|
2918
2690
|
const diff2 = uid => {
|
|
2919
2691
|
const {
|
|
2920
|
-
|
|
2921
|
-
|
|
2692
|
+
newState,
|
|
2693
|
+
oldState
|
|
2922
2694
|
} = get(uid);
|
|
2923
2695
|
return diff(oldState, newState);
|
|
2924
2696
|
};
|
|
2925
2697
|
|
|
2926
2698
|
const canBeFocused = item => {
|
|
2927
2699
|
switch (item.flags) {
|
|
2928
|
-
case Separator$2:
|
|
2929
2700
|
case Disabled$1:
|
|
2701
|
+
case Separator$2:
|
|
2930
2702
|
return false;
|
|
2931
2703
|
default:
|
|
2932
2704
|
return true;
|
|
@@ -3033,36 +2805,36 @@ const FocusTitleBarMenuBar = 26;
|
|
|
3033
2805
|
|
|
3034
2806
|
const getKeyBindings = () => {
|
|
3035
2807
|
return [{
|
|
3036
|
-
key: DownArrow$1,
|
|
3037
2808
|
command: 'TitleBarMenuBar.handleKeyArrowDown',
|
|
2809
|
+
key: DownArrow$1,
|
|
3038
2810
|
when: FocusTitleBarMenuBar
|
|
3039
2811
|
}, {
|
|
3040
|
-
key: UpArrow$1,
|
|
3041
2812
|
command: 'TitleBarMenuBar.handleKeyArrowUp',
|
|
2813
|
+
key: UpArrow$1,
|
|
3042
2814
|
when: FocusTitleBarMenuBar
|
|
3043
2815
|
}, {
|
|
3044
|
-
key: RightArrow$1,
|
|
3045
2816
|
command: 'TitleBarMenuBar.handleKeyArrowRight',
|
|
2817
|
+
key: RightArrow$1,
|
|
3046
2818
|
when: FocusTitleBarMenuBar
|
|
3047
2819
|
}, {
|
|
3048
|
-
key: LeftArrow$1,
|
|
3049
2820
|
command: 'TitleBarMenuBar.handleKeyArrowLeft',
|
|
2821
|
+
key: LeftArrow$1,
|
|
3050
2822
|
when: FocusTitleBarMenuBar
|
|
3051
2823
|
}, {
|
|
3052
|
-
key: Space$1,
|
|
3053
2824
|
command: 'TitleBarMenuBar.handleKeySpace',
|
|
2825
|
+
key: Space$1,
|
|
3054
2826
|
when: FocusTitleBarMenuBar
|
|
3055
2827
|
}, {
|
|
3056
|
-
key: Home$1,
|
|
3057
2828
|
command: 'TitleBarMenuBar.handleKeyHome',
|
|
2829
|
+
key: Home$1,
|
|
3058
2830
|
when: FocusTitleBarMenuBar
|
|
3059
2831
|
}, {
|
|
3060
|
-
key: End$1,
|
|
3061
2832
|
command: 'TitleBarMenuBar.handleKeyEnd',
|
|
2833
|
+
key: End$1,
|
|
3062
2834
|
when: FocusTitleBarMenuBar
|
|
3063
2835
|
}, {
|
|
3064
|
-
key: Escape$1,
|
|
3065
2836
|
command: 'TitleBarMenuBar.handleKeyEscape',
|
|
2837
|
+
key: Escape$1,
|
|
3066
2838
|
when: FocusTitleBarMenuBar
|
|
3067
2839
|
}];
|
|
3068
2840
|
};
|
|
@@ -3095,11 +2867,11 @@ const getMenuEntries = (id, platform) => {
|
|
|
3095
2867
|
// TODO more tests
|
|
3096
2868
|
|
|
3097
2869
|
const getMenuShowCommands = async (items, menuId, x, y, mouseBlocking = false) => {
|
|
3098
|
-
const bounds = getMenuBounds(x, y, items);
|
|
2870
|
+
const bounds = await getMenuBounds(x, y, items);
|
|
3099
2871
|
const menu = addMenuInternal({
|
|
2872
|
+
focusedIndex: -1,
|
|
3100
2873
|
id: menuId,
|
|
3101
2874
|
items,
|
|
3102
|
-
focusedIndex: -1,
|
|
3103
2875
|
level: getCount(),
|
|
3104
2876
|
x: bounds.x,
|
|
3105
2877
|
y: bounds.y
|
|
@@ -3107,9 +2879,9 @@ const getMenuShowCommands = async (items, menuId, x, y, mouseBlocking = false) =
|
|
|
3107
2879
|
const visible = getVisible(menu.items, -1, false, menu.level);
|
|
3108
2880
|
const dom = getMenuVirtualDom(visible).slice(1);
|
|
3109
2881
|
return {
|
|
3110
|
-
|
|
2882
|
+
commands: [/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking],
|
|
3111
2883
|
menu,
|
|
3112
|
-
|
|
2884
|
+
menus: getAll()
|
|
3113
2885
|
};
|
|
3114
2886
|
};
|
|
3115
2887
|
|
|
@@ -3127,8 +2899,8 @@ const hideSubMenus = async level => {
|
|
|
3127
2899
|
const MENU_DELAY_TRIANGLE = 300;
|
|
3128
2900
|
const resolveAfterTimeout = async () => {
|
|
3129
2901
|
const {
|
|
3130
|
-
|
|
3131
|
-
|
|
2902
|
+
promise,
|
|
2903
|
+
resolve
|
|
3132
2904
|
} = Promise.withResolvers();
|
|
3133
2905
|
setTimeout(resolve, MENU_DELAY_TRIANGLE);
|
|
3134
2906
|
await promise;
|
|
@@ -3141,14 +2913,14 @@ const showSubMenuAtEnter = async (level, index, enterX, enterY) => {
|
|
|
3141
2913
|
const item = parentMenu.items[index];
|
|
3142
2914
|
const subMenuItems = await getMenuEntries$1(item.id);
|
|
3143
2915
|
const subMenu = addMenuInternal({
|
|
2916
|
+
enterX,
|
|
2917
|
+
enterY,
|
|
2918
|
+
focusedIndex: -1,
|
|
3144
2919
|
id: item.id,
|
|
3145
2920
|
items: subMenuItems,
|
|
3146
|
-
focusedIndex: -1,
|
|
3147
2921
|
level: getCount(),
|
|
3148
|
-
y: parentMenu.y + index * 25,
|
|
3149
2922
|
x: parentMenu.x + MENU_WIDTH,
|
|
3150
|
-
|
|
3151
|
-
enterY
|
|
2923
|
+
y: parentMenu.y + index * 25
|
|
3152
2924
|
});
|
|
3153
2925
|
const width = getMenuWidth();
|
|
3154
2926
|
const height = getMenuHeight(subMenuItems);
|
|
@@ -3273,8 +3045,8 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
3273
3045
|
|
|
3274
3046
|
const render2 = async (uid, diffResult) => {
|
|
3275
3047
|
const {
|
|
3276
|
-
|
|
3277
|
-
|
|
3048
|
+
newState,
|
|
3049
|
+
oldState
|
|
3278
3050
|
} = get(uid);
|
|
3279
3051
|
set(uid, newState, newState);
|
|
3280
3052
|
const commands = applyRender(oldState, newState, diffResult);
|
|
@@ -3316,6 +3088,8 @@ const saveState = uid => {
|
|
|
3316
3088
|
};
|
|
3317
3089
|
};
|
|
3318
3090
|
|
|
3091
|
+
const selectIndexDefault = async () => {};
|
|
3092
|
+
|
|
3319
3093
|
const {
|
|
3320
3094
|
invoke} = RendererWorker;
|
|
3321
3095
|
|
|
@@ -3323,36 +3097,46 @@ const executeMenuItemCommand = async item => {
|
|
|
3323
3097
|
await invoke(item.command, ...(item.args || []));
|
|
3324
3098
|
};
|
|
3325
3099
|
|
|
3100
|
+
const selectIndexIgnore = async (menu, item) => {
|
|
3101
|
+
await executeMenuItemCommand(item);
|
|
3102
|
+
};
|
|
3103
|
+
|
|
3326
3104
|
const selectIndexNone = async (menu, item) => {
|
|
3327
|
-
await
|
|
3105
|
+
await hide(/* restoreFocus */false);
|
|
3106
|
+
await executeMenuItemCommand(item);
|
|
3328
3107
|
};
|
|
3108
|
+
|
|
3329
3109
|
const selectIndexRestoreFocus = async (menu, item) => {
|
|
3330
|
-
await
|
|
3110
|
+
await hide(/* restoreFocus */true);
|
|
3111
|
+
await executeMenuItemCommand(item);
|
|
3331
3112
|
};
|
|
3113
|
+
|
|
3332
3114
|
const selectIndexSubMenu = async (menu, item, index) => {
|
|
3333
3115
|
if (menu.focusedIndex === index) {
|
|
3334
3116
|
return;
|
|
3335
3117
|
}
|
|
3336
3118
|
await showSubMenu(menu.level, menu.focusedIndex);
|
|
3337
3119
|
};
|
|
3338
|
-
|
|
3339
|
-
const selectIndexIgnore = async (menu, item) => {
|
|
3340
|
-
await executeMenuItemCommand(item);
|
|
3341
|
-
};
|
|
3120
|
+
|
|
3342
3121
|
const getSelectIndexFunction = flags => {
|
|
3343
3122
|
switch (flags) {
|
|
3123
|
+
case Checked$1:
|
|
3124
|
+
return selectIndexRestoreFocus;
|
|
3125
|
+
case Ignore$1:
|
|
3126
|
+
return selectIndexIgnore;
|
|
3344
3127
|
case None$1:
|
|
3345
3128
|
return selectIndexNone;
|
|
3129
|
+
case RestoreFocus$1:
|
|
3130
|
+
return selectIndexRestoreFocus;
|
|
3346
3131
|
case SubMenu$1:
|
|
3347
3132
|
return selectIndexSubMenu;
|
|
3348
|
-
case
|
|
3133
|
+
case Unchecked$1:
|
|
3349
3134
|
return selectIndexRestoreFocus;
|
|
3350
|
-
case Ignore$1:
|
|
3351
|
-
return selectIndexIgnore;
|
|
3352
3135
|
default:
|
|
3353
3136
|
return selectIndexDefault;
|
|
3354
3137
|
}
|
|
3355
3138
|
};
|
|
3139
|
+
|
|
3356
3140
|
const selectIndex = async (level, index) => {
|
|
3357
3141
|
const menu = get$1(level);
|
|
3358
3142
|
// TODO avoid assignment
|
|
@@ -3421,31 +3205,15 @@ const commandMap = {
|
|
|
3421
3205
|
'Menu.showSubMenu': showSubMenu
|
|
3422
3206
|
};
|
|
3423
3207
|
|
|
3424
|
-
const
|
|
3425
|
-
|
|
3426
|
-
};
|
|
3427
|
-
const createRendererProcessRpc = async () => {
|
|
3428
|
-
try {
|
|
3429
|
-
const rpc = await TransferMessagePortRpcParent.create({
|
|
3430
|
-
commandMap: {},
|
|
3431
|
-
send
|
|
3432
|
-
});
|
|
3433
|
-
return rpc;
|
|
3434
|
-
} catch (error) {
|
|
3435
|
-
throw new VError(error, `Failed to create renderer process rpc`);
|
|
3436
|
-
}
|
|
3437
|
-
};
|
|
3438
|
-
|
|
3439
|
-
const initializeRendererProcess = async () => {
|
|
3440
|
-
const rpc = await createRendererProcessRpc();
|
|
3441
|
-
set$3(rpc);
|
|
3442
|
-
};
|
|
3443
|
-
|
|
3444
|
-
const listen = async () => {
|
|
3445
|
-
const rpc = await WebWorkerRpcClient.create({
|
|
3208
|
+
const initializeRendererWorker = async () => {
|
|
3209
|
+
const rpc = await create$2({
|
|
3446
3210
|
commandMap: commandMap
|
|
3447
3211
|
});
|
|
3448
3212
|
set$2(rpc);
|
|
3213
|
+
};
|
|
3214
|
+
|
|
3215
|
+
const listen = async () => {
|
|
3216
|
+
await initializeRendererWorker();
|
|
3449
3217
|
await initializeRendererProcess();
|
|
3450
3218
|
};
|
|
3451
3219
|
|