@lvce-editor/settings-view 2.26.2 → 2.27.1
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/settingsViewWorkerMain.js +658 -227
- package/package.json +2 -2
|
@@ -62,8 +62,8 @@ class AssertionError extends Error {
|
|
|
62
62
|
}
|
|
63
63
|
const Object$1 = 1;
|
|
64
64
|
const Number$2 = 2;
|
|
65
|
-
const Array$1 = 3;
|
|
66
|
-
const String$
|
|
65
|
+
const Array$1$1 = 3;
|
|
66
|
+
const String$2 = 4;
|
|
67
67
|
const Boolean$2 = 5;
|
|
68
68
|
const Function = 6;
|
|
69
69
|
const Null = 7;
|
|
@@ -75,13 +75,13 @@ const getType = value => {
|
|
|
75
75
|
case 'function':
|
|
76
76
|
return Function;
|
|
77
77
|
case 'string':
|
|
78
|
-
return String$
|
|
78
|
+
return String$2;
|
|
79
79
|
case 'object':
|
|
80
80
|
if (value === null) {
|
|
81
81
|
return Null;
|
|
82
82
|
}
|
|
83
83
|
if (Array.isArray(value)) {
|
|
84
|
-
return Array$1;
|
|
84
|
+
return Array$1$1;
|
|
85
85
|
}
|
|
86
86
|
return Object$1;
|
|
87
87
|
case 'boolean':
|
|
@@ -139,7 +139,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
139
139
|
for (const property of Object.values(value)) {
|
|
140
140
|
walkValue(property, transferrables, isTransferrable);
|
|
141
141
|
}
|
|
142
|
-
return;
|
|
143
142
|
}
|
|
144
143
|
};
|
|
145
144
|
const getTransferrables = value => {
|
|
@@ -293,7 +292,14 @@ class IpcError extends VError {
|
|
|
293
292
|
const cause = new Error(message);
|
|
294
293
|
// @ts-ignore
|
|
295
294
|
cause.code = code;
|
|
296
|
-
|
|
295
|
+
if (stack) {
|
|
296
|
+
Object.defineProperty(cause, 'stack', {
|
|
297
|
+
configurable: true,
|
|
298
|
+
enumerable: false,
|
|
299
|
+
value: stack,
|
|
300
|
+
writable: true
|
|
301
|
+
});
|
|
302
|
+
}
|
|
297
303
|
super(cause, betterMessage);
|
|
298
304
|
} else {
|
|
299
305
|
super(betterMessage);
|
|
@@ -450,7 +456,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
450
456
|
return promise;
|
|
451
457
|
};
|
|
452
458
|
const Message$1 = 3;
|
|
453
|
-
const create$5 = async ({
|
|
459
|
+
const create$5$1 = async ({
|
|
454
460
|
isMessagePortOpen,
|
|
455
461
|
messagePort
|
|
456
462
|
}) => {
|
|
@@ -501,11 +507,32 @@ const wrap$5 = messagePort => {
|
|
|
501
507
|
};
|
|
502
508
|
const IpcParentWithMessagePort$1 = {
|
|
503
509
|
__proto__: null,
|
|
504
|
-
create: create$5,
|
|
510
|
+
create: create$5$1,
|
|
505
511
|
signal: signal$1,
|
|
506
512
|
wrap: wrap$5
|
|
507
513
|
};
|
|
508
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
|
+
|
|
509
536
|
const Two$1 = '2.0';
|
|
510
537
|
const callbacks = Object.create(null);
|
|
511
538
|
const get$2 = id => {
|
|
@@ -530,12 +557,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
530
557
|
switch (type) {
|
|
531
558
|
case DomException:
|
|
532
559
|
return DOMException;
|
|
533
|
-
case TypeError$1:
|
|
534
|
-
return TypeError;
|
|
535
|
-
case SyntaxError$1:
|
|
536
|
-
return SyntaxError;
|
|
537
560
|
case ReferenceError$1:
|
|
538
561
|
return ReferenceError;
|
|
562
|
+
case SyntaxError$1:
|
|
563
|
+
return SyntaxError;
|
|
564
|
+
case TypeError$1:
|
|
565
|
+
return TypeError;
|
|
539
566
|
default:
|
|
540
567
|
return Error;
|
|
541
568
|
}
|
|
@@ -559,7 +586,10 @@ const constructError = (message, type, name) => {
|
|
|
559
586
|
if (ErrorConstructor === Error) {
|
|
560
587
|
const error = new Error(message);
|
|
561
588
|
if (name && name !== 'VError') {
|
|
562
|
-
error
|
|
589
|
+
Object.defineProperty(error, 'name', {
|
|
590
|
+
configurable: true,
|
|
591
|
+
value: name
|
|
592
|
+
});
|
|
563
593
|
}
|
|
564
594
|
return error;
|
|
565
595
|
}
|
|
@@ -576,8 +606,10 @@ const getCurrentStack = () => {
|
|
|
576
606
|
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
577
607
|
return currentStack;
|
|
578
608
|
};
|
|
579
|
-
const getNewLineIndex = (string, startIndex
|
|
580
|
-
|
|
609
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
610
|
+
{
|
|
611
|
+
return string.indexOf(NewLine);
|
|
612
|
+
}
|
|
581
613
|
};
|
|
582
614
|
const getParentStack = error => {
|
|
583
615
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -588,55 +620,91 @@ const getParentStack = error => {
|
|
|
588
620
|
};
|
|
589
621
|
const MethodNotFound = -32601;
|
|
590
622
|
const Custom = -32001;
|
|
623
|
+
const setStack = (error, stack) => {
|
|
624
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
625
|
+
if (descriptor) {
|
|
626
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
630
|
+
error.stack = stack;
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
Object.defineProperty(error, 'stack', {
|
|
635
|
+
configurable: true,
|
|
636
|
+
value: stack,
|
|
637
|
+
writable: true
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
const restoreExistingError = (error, currentStack) => {
|
|
641
|
+
if (typeof error.stack === 'string') {
|
|
642
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
643
|
+
}
|
|
644
|
+
return error;
|
|
645
|
+
};
|
|
646
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
647
|
+
const restoredError = new JsonRpcError(error.message);
|
|
648
|
+
const parentStack = getParentStack(error);
|
|
649
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
650
|
+
return restoredError;
|
|
651
|
+
};
|
|
652
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
653
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
654
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (error.data.stack) {
|
|
658
|
+
setStack(restoredError, error.data.stack);
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
const applyDataProperties = (restoredError, error) => {
|
|
662
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
663
|
+
if (error.data.codeFrame) {
|
|
664
|
+
// @ts-ignore
|
|
665
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
666
|
+
}
|
|
667
|
+
if (error.data.code) {
|
|
668
|
+
// @ts-ignore
|
|
669
|
+
restoredError.code = error.data.code;
|
|
670
|
+
}
|
|
671
|
+
if (error.data.type) {
|
|
672
|
+
// @ts-ignore
|
|
673
|
+
restoredError.name = error.data.type;
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
677
|
+
if (error.stack) {
|
|
678
|
+
const lowerStack = restoredError.stack || '';
|
|
679
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
680
|
+
const parentStack = getParentStack(error);
|
|
681
|
+
// @ts-ignore
|
|
682
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
683
|
+
}
|
|
684
|
+
if (error.codeFrame) {
|
|
685
|
+
// @ts-ignore
|
|
686
|
+
restoredError.codeFrame = error.codeFrame;
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
690
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
691
|
+
if (error.data) {
|
|
692
|
+
applyDataProperties(restoredError, error);
|
|
693
|
+
} else {
|
|
694
|
+
applyDirectProperties(restoredError, error);
|
|
695
|
+
}
|
|
696
|
+
return restoredError;
|
|
697
|
+
};
|
|
591
698
|
const restoreJsonRpcError = error => {
|
|
592
699
|
const currentStack = getCurrentStack();
|
|
593
700
|
if (error && error instanceof Error) {
|
|
594
|
-
|
|
595
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
596
|
-
}
|
|
597
|
-
return error;
|
|
701
|
+
return restoreExistingError(error, currentStack);
|
|
598
702
|
}
|
|
599
703
|
if (error && error.code && error.code === MethodNotFound) {
|
|
600
|
-
|
|
601
|
-
const parentStack = getParentStack(error);
|
|
602
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
603
|
-
return restoredError;
|
|
704
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
604
705
|
}
|
|
605
706
|
if (error && error.message) {
|
|
606
|
-
|
|
607
|
-
if (error.data) {
|
|
608
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
609
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
610
|
-
} else if (error.data.stack) {
|
|
611
|
-
restoredError.stack = error.data.stack;
|
|
612
|
-
}
|
|
613
|
-
if (error.data.codeFrame) {
|
|
614
|
-
// @ts-ignore
|
|
615
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
616
|
-
}
|
|
617
|
-
if (error.data.code) {
|
|
618
|
-
// @ts-ignore
|
|
619
|
-
restoredError.code = error.data.code;
|
|
620
|
-
}
|
|
621
|
-
if (error.data.type) {
|
|
622
|
-
// @ts-ignore
|
|
623
|
-
restoredError.name = error.data.type;
|
|
624
|
-
}
|
|
625
|
-
} else {
|
|
626
|
-
if (error.stack) {
|
|
627
|
-
const lowerStack = restoredError.stack || '';
|
|
628
|
-
// @ts-ignore
|
|
629
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
630
|
-
const parentStack = getParentStack(error);
|
|
631
|
-
// @ts-ignore
|
|
632
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
633
|
-
}
|
|
634
|
-
if (error.codeFrame) {
|
|
635
|
-
// @ts-ignore
|
|
636
|
-
restoredError.codeFrame = error.codeFrame;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
return restoredError;
|
|
707
|
+
return restoreMessageError(error);
|
|
640
708
|
}
|
|
641
709
|
if (typeof error === 'string') {
|
|
642
710
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -691,56 +759,56 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
691
759
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
692
760
|
return {
|
|
693
761
|
code: MethodNotFound,
|
|
694
|
-
|
|
695
|
-
|
|
762
|
+
data: error.stack,
|
|
763
|
+
message: error.message
|
|
696
764
|
};
|
|
697
765
|
}
|
|
698
766
|
return {
|
|
699
767
|
code: Custom,
|
|
700
|
-
message: prettyError.message,
|
|
701
768
|
data: {
|
|
702
|
-
stack: getStack(prettyError),
|
|
703
|
-
codeFrame: prettyError.codeFrame,
|
|
704
|
-
type: getErrorType(prettyError),
|
|
705
769
|
code: prettyError.code,
|
|
706
|
-
|
|
707
|
-
|
|
770
|
+
codeFrame: prettyError.codeFrame,
|
|
771
|
+
name: prettyError.name,
|
|
772
|
+
stack: getStack(prettyError),
|
|
773
|
+
type: getErrorType(prettyError)
|
|
774
|
+
},
|
|
775
|
+
message: prettyError.message
|
|
708
776
|
};
|
|
709
777
|
};
|
|
710
|
-
const create$1$
|
|
778
|
+
const create$1$1 = (id, error) => {
|
|
711
779
|
return {
|
|
712
|
-
|
|
780
|
+
error,
|
|
713
781
|
id,
|
|
714
|
-
|
|
782
|
+
jsonrpc: Two$1
|
|
715
783
|
};
|
|
716
784
|
};
|
|
717
785
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
718
786
|
const prettyError = preparePrettyError(error);
|
|
719
787
|
logError(error, prettyError);
|
|
720
788
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
721
|
-
return create$1$
|
|
789
|
+
return create$1$1(id, errorProperty);
|
|
722
790
|
};
|
|
723
|
-
const create$
|
|
791
|
+
const create$a = (message, result) => {
|
|
724
792
|
return {
|
|
725
|
-
jsonrpc: Two$1,
|
|
726
793
|
id: message.id,
|
|
794
|
+
jsonrpc: Two$1,
|
|
727
795
|
result: result ?? null
|
|
728
796
|
};
|
|
729
797
|
};
|
|
730
798
|
const getSuccessResponse = (message, result) => {
|
|
731
799
|
const resultProperty = result ?? null;
|
|
732
|
-
return create$
|
|
800
|
+
return create$a(message, resultProperty);
|
|
733
801
|
};
|
|
734
802
|
const getErrorResponseSimple = (id, error) => {
|
|
735
803
|
return {
|
|
736
|
-
jsonrpc: Two$1,
|
|
737
|
-
id,
|
|
738
804
|
error: {
|
|
739
805
|
code: Custom,
|
|
806
|
+
data: error,
|
|
740
807
|
// @ts-ignore
|
|
741
|
-
message: error.message
|
|
742
|
-
|
|
743
|
-
|
|
808
|
+
message: error.message
|
|
809
|
+
},
|
|
810
|
+
id,
|
|
811
|
+
jsonrpc: Two$1
|
|
744
812
|
};
|
|
745
813
|
};
|
|
746
814
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -770,35 +838,35 @@ const normalizeParams = args => {
|
|
|
770
838
|
if (args.length === 1) {
|
|
771
839
|
const options = args[0];
|
|
772
840
|
return {
|
|
841
|
+
execute: options.execute,
|
|
773
842
|
ipc: options.ipc,
|
|
843
|
+
logError: options.logError || defaultLogError,
|
|
774
844
|
message: options.message,
|
|
775
|
-
execute: options.execute,
|
|
776
|
-
resolve: options.resolve || defaultResolve,
|
|
777
845
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
778
|
-
|
|
779
|
-
|
|
846
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
847
|
+
resolve: options.resolve || defaultResolve
|
|
780
848
|
};
|
|
781
849
|
}
|
|
782
850
|
return {
|
|
851
|
+
execute: args[2],
|
|
783
852
|
ipc: args[0],
|
|
853
|
+
logError: args[5],
|
|
784
854
|
message: args[1],
|
|
785
|
-
execute: args[2],
|
|
786
|
-
resolve: args[3],
|
|
787
855
|
preparePrettyError: args[4],
|
|
788
|
-
|
|
789
|
-
|
|
856
|
+
requiresSocket: args[6],
|
|
857
|
+
resolve: args[3]
|
|
790
858
|
};
|
|
791
859
|
};
|
|
792
860
|
const handleJsonRpcMessage = async (...args) => {
|
|
793
861
|
const options = normalizeParams(args);
|
|
794
862
|
const {
|
|
795
|
-
message,
|
|
796
|
-
ipc,
|
|
797
863
|
execute,
|
|
798
|
-
|
|
799
|
-
preparePrettyError,
|
|
864
|
+
ipc,
|
|
800
865
|
logError,
|
|
801
|
-
|
|
866
|
+
message,
|
|
867
|
+
preparePrettyError,
|
|
868
|
+
requiresSocket,
|
|
869
|
+
resolve
|
|
802
870
|
} = options;
|
|
803
871
|
if ('id' in message) {
|
|
804
872
|
if ('method' in message) {
|
|
@@ -821,36 +889,17 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
821
889
|
throw new JsonRpcError('unexpected message');
|
|
822
890
|
};
|
|
823
891
|
|
|
824
|
-
class CommandNotFoundError extends Error {
|
|
825
|
-
constructor(command) {
|
|
826
|
-
super(`Command not found ${command}`);
|
|
827
|
-
this.name = 'CommandNotFoundError';
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
const commands = Object.create(null);
|
|
831
|
-
const register = commandMap => {
|
|
832
|
-
Object.assign(commands, commandMap);
|
|
833
|
-
};
|
|
834
|
-
const getCommand = key => {
|
|
835
|
-
return commands[key];
|
|
836
|
-
};
|
|
837
|
-
const execute = (command, ...args) => {
|
|
838
|
-
const fn = getCommand(command);
|
|
839
|
-
if (!fn) {
|
|
840
|
-
throw new CommandNotFoundError(command);
|
|
841
|
-
}
|
|
842
|
-
return fn(...args);
|
|
843
|
-
};
|
|
844
|
-
|
|
845
892
|
const Two = '2.0';
|
|
846
|
-
|
|
893
|
+
|
|
894
|
+
const create$9 = (method, params) => {
|
|
847
895
|
return {
|
|
848
896
|
jsonrpc: Two,
|
|
849
897
|
method,
|
|
850
898
|
params
|
|
851
899
|
};
|
|
852
900
|
};
|
|
853
|
-
|
|
901
|
+
|
|
902
|
+
const create$8 = (id, method, params) => {
|
|
854
903
|
const message = {
|
|
855
904
|
id,
|
|
856
905
|
jsonrpc: Two,
|
|
@@ -859,15 +908,14 @@ const create$r = (id, method, params) => {
|
|
|
859
908
|
};
|
|
860
909
|
return message;
|
|
861
910
|
};
|
|
911
|
+
|
|
862
912
|
let id = 0;
|
|
863
|
-
const create$
|
|
913
|
+
const create$7 = () => {
|
|
864
914
|
return ++id;
|
|
865
915
|
};
|
|
866
916
|
|
|
867
|
-
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
868
|
-
|
|
869
917
|
const registerPromise = map => {
|
|
870
|
-
const id = create$
|
|
918
|
+
const id = create$7();
|
|
871
919
|
const {
|
|
872
920
|
promise,
|
|
873
921
|
resolve
|
|
@@ -879,13 +927,12 @@ const registerPromise = map => {
|
|
|
879
927
|
};
|
|
880
928
|
};
|
|
881
929
|
|
|
882
|
-
// @ts-ignore
|
|
883
930
|
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
884
931
|
const {
|
|
885
932
|
id,
|
|
886
933
|
promise
|
|
887
934
|
} = registerPromise(callbacks);
|
|
888
|
-
const message = create$
|
|
935
|
+
const message = create$8(id, method, params);
|
|
889
936
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
890
937
|
ipc.sendAndTransfer(message);
|
|
891
938
|
} else {
|
|
@@ -921,12 +968,13 @@ const createRpc = ipc => {
|
|
|
921
968
|
* @deprecated
|
|
922
969
|
*/
|
|
923
970
|
send(method, ...params) {
|
|
924
|
-
const message = create$
|
|
971
|
+
const message = create$9(method, params);
|
|
925
972
|
ipc.send(message);
|
|
926
973
|
}
|
|
927
974
|
};
|
|
928
975
|
return rpc;
|
|
929
976
|
};
|
|
977
|
+
|
|
930
978
|
const requiresSocket = () => {
|
|
931
979
|
return false;
|
|
932
980
|
};
|
|
@@ -941,6 +989,7 @@ const handleMessage = event => {
|
|
|
941
989
|
const actualExecute = event?.target?.execute || execute;
|
|
942
990
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
943
991
|
};
|
|
992
|
+
|
|
944
993
|
const handleIpc = ipc => {
|
|
945
994
|
if ('addEventListener' in ipc) {
|
|
946
995
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -949,6 +998,7 @@ const handleIpc = ipc => {
|
|
|
949
998
|
ipc.on('message', handleMessage);
|
|
950
999
|
}
|
|
951
1000
|
};
|
|
1001
|
+
|
|
952
1002
|
const listen$1 = async (module, options) => {
|
|
953
1003
|
const rawIpc = await module.listen(options);
|
|
954
1004
|
if (module.signal) {
|
|
@@ -958,8 +1008,6 @@ const listen$1 = async (module, options) => {
|
|
|
958
1008
|
return ipc;
|
|
959
1009
|
};
|
|
960
1010
|
|
|
961
|
-
/* eslint-disable @typescript-eslint/no-misused-promises */
|
|
962
|
-
|
|
963
1011
|
const createSharedLazyRpc = factory => {
|
|
964
1012
|
let rpcPromise;
|
|
965
1013
|
const getOrCreate = () => {
|
|
@@ -987,24 +1035,8 @@ const createSharedLazyRpc = factory => {
|
|
|
987
1035
|
}
|
|
988
1036
|
};
|
|
989
1037
|
};
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
isMessagePortOpen,
|
|
993
|
-
send
|
|
994
|
-
}) => {
|
|
995
|
-
return createSharedLazyRpc(() => {
|
|
996
|
-
return create$2$1({
|
|
997
|
-
commandMap,
|
|
998
|
-
isMessagePortOpen,
|
|
999
|
-
send
|
|
1000
|
-
});
|
|
1001
|
-
});
|
|
1002
|
-
};
|
|
1003
|
-
const LazyTransferMessagePortRpcParent = {
|
|
1004
|
-
__proto__: null,
|
|
1005
|
-
create: create$i
|
|
1006
|
-
};
|
|
1007
|
-
const create$4 = async ({
|
|
1038
|
+
|
|
1039
|
+
const create$6 = async ({
|
|
1008
1040
|
commandMap,
|
|
1009
1041
|
isMessagePortOpen = true,
|
|
1010
1042
|
messagePort
|
|
@@ -1021,11 +1053,8 @@ const create$4 = async ({
|
|
|
1021
1053
|
messagePort.start();
|
|
1022
1054
|
return rpc;
|
|
1023
1055
|
};
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
create: create$4
|
|
1027
|
-
};
|
|
1028
|
-
const create$2$1 = async ({
|
|
1056
|
+
|
|
1057
|
+
const create$5 = async ({
|
|
1029
1058
|
commandMap,
|
|
1030
1059
|
isMessagePortOpen,
|
|
1031
1060
|
send
|
|
@@ -1035,13 +1064,28 @@ const create$2$1 = async ({
|
|
|
1035
1064
|
port2
|
|
1036
1065
|
} = new MessageChannel();
|
|
1037
1066
|
await send(port1);
|
|
1038
|
-
return create$
|
|
1067
|
+
return create$6({
|
|
1039
1068
|
commandMap,
|
|
1040
1069
|
isMessagePortOpen,
|
|
1041
1070
|
messagePort: port2
|
|
1042
1071
|
});
|
|
1043
1072
|
};
|
|
1044
|
-
|
|
1073
|
+
|
|
1074
|
+
const create$4 = async ({
|
|
1075
|
+
commandMap,
|
|
1076
|
+
isMessagePortOpen,
|
|
1077
|
+
send
|
|
1078
|
+
}) => {
|
|
1079
|
+
return createSharedLazyRpc(() => {
|
|
1080
|
+
return create$5({
|
|
1081
|
+
commandMap,
|
|
1082
|
+
isMessagePortOpen,
|
|
1083
|
+
send
|
|
1084
|
+
});
|
|
1085
|
+
});
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
const create$3 = async ({
|
|
1045
1089
|
commandMap
|
|
1046
1090
|
}) => {
|
|
1047
1091
|
// TODO create a commandMap per rpc instance
|
|
@@ -1051,9 +1095,25 @@ const create$1$1 = async ({
|
|
|
1051
1095
|
const rpc = createRpc(ipc);
|
|
1052
1096
|
return rpc;
|
|
1053
1097
|
};
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1098
|
+
|
|
1099
|
+
const createMockRpc = ({
|
|
1100
|
+
commandMap
|
|
1101
|
+
}) => {
|
|
1102
|
+
const invocations = [];
|
|
1103
|
+
const invoke = (method, ...params) => {
|
|
1104
|
+
invocations.push([method, ...params]);
|
|
1105
|
+
const command = commandMap[method];
|
|
1106
|
+
if (!command) {
|
|
1107
|
+
throw new Error(`command ${method} not found`);
|
|
1108
|
+
}
|
|
1109
|
+
return command(...params);
|
|
1110
|
+
};
|
|
1111
|
+
const mockRpc = {
|
|
1112
|
+
invocations,
|
|
1113
|
+
invoke,
|
|
1114
|
+
invokeAndTransfer: invoke
|
|
1115
|
+
};
|
|
1116
|
+
return mockRpc;
|
|
1057
1117
|
};
|
|
1058
1118
|
|
|
1059
1119
|
const toCommandId = key => {
|
|
@@ -1061,45 +1121,161 @@ const toCommandId = key => {
|
|
|
1061
1121
|
return key.slice(dotIndex + 1);
|
|
1062
1122
|
};
|
|
1063
1123
|
const create$2 = () => {
|
|
1124
|
+
const commandQueues = new Map();
|
|
1125
|
+
const generations = Object.create(null);
|
|
1064
1126
|
const states = Object.create(null);
|
|
1065
|
-
const commandMapRef =
|
|
1127
|
+
const commandMapRef = Object.create(null);
|
|
1128
|
+
const commandsById = Object.create(null);
|
|
1129
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
1130
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
1131
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
1132
|
+
};
|
|
1133
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
1134
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1135
|
+
return Promise.resolve(fallbackState);
|
|
1136
|
+
}
|
|
1137
|
+
const current = states[uid];
|
|
1138
|
+
const updatedState = updater(current.newState);
|
|
1139
|
+
if (updatedState !== current.newState) {
|
|
1140
|
+
states[uid] = {
|
|
1141
|
+
newState: updatedState,
|
|
1142
|
+
oldState: current.oldState,
|
|
1143
|
+
scheduledState: updatedState
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
return Promise.resolve(updatedState);
|
|
1147
|
+
};
|
|
1148
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
1149
|
+
let latestState = states[uid].newState;
|
|
1150
|
+
return {
|
|
1151
|
+
getState: () => {
|
|
1152
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
1153
|
+
latestState = states[uid].newState;
|
|
1154
|
+
}
|
|
1155
|
+
return latestState;
|
|
1156
|
+
},
|
|
1157
|
+
updateState: async updater => {
|
|
1158
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
1159
|
+
return latestState;
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
};
|
|
1163
|
+
const enqueueCommand = async (uid, command) => {
|
|
1164
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
1165
|
+
const run = async () => {
|
|
1166
|
+
try {
|
|
1167
|
+
await previous;
|
|
1168
|
+
} catch {
|
|
1169
|
+
// The previous caller receives its error; later commands must still run.
|
|
1170
|
+
}
|
|
1171
|
+
await command();
|
|
1172
|
+
};
|
|
1173
|
+
const current = run();
|
|
1174
|
+
commandQueues.set(uid, current);
|
|
1175
|
+
try {
|
|
1176
|
+
await current;
|
|
1177
|
+
} finally {
|
|
1178
|
+
if (commandQueues.get(uid) === current) {
|
|
1179
|
+
commandQueues.delete(uid);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1066
1183
|
return {
|
|
1067
|
-
|
|
1068
|
-
|
|
1184
|
+
clear() {
|
|
1185
|
+
commandQueues.clear();
|
|
1186
|
+
for (const key of Object.keys(states)) {
|
|
1187
|
+
delete states[key];
|
|
1188
|
+
}
|
|
1069
1189
|
},
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1190
|
+
createDirectEventCommandMap(requestRender) {
|
|
1191
|
+
return {
|
|
1192
|
+
async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
|
|
1193
|
+
const fn = commandsById[command];
|
|
1194
|
+
if (!fn) {
|
|
1195
|
+
throw new Error(`Viewlet command not found: ${command}`);
|
|
1196
|
+
}
|
|
1197
|
+
await fn(uid, ...args);
|
|
1198
|
+
await requestRender(uid);
|
|
1199
|
+
}
|
|
1074
1200
|
};
|
|
1075
1201
|
},
|
|
1202
|
+
diff(uid, modules, numbers) {
|
|
1203
|
+
const {
|
|
1204
|
+
oldState,
|
|
1205
|
+
scheduledState
|
|
1206
|
+
} = states[uid];
|
|
1207
|
+
const diffResult = [];
|
|
1208
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1209
|
+
const fn = modules[i];
|
|
1210
|
+
if (!fn(oldState, scheduledState)) {
|
|
1211
|
+
diffResult.push(numbers[i]);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
return diffResult;
|
|
1215
|
+
},
|
|
1076
1216
|
dispose(uid) {
|
|
1217
|
+
commandQueues.delete(uid);
|
|
1077
1218
|
delete states[uid];
|
|
1078
1219
|
},
|
|
1220
|
+
get(uid) {
|
|
1221
|
+
return states[uid];
|
|
1222
|
+
},
|
|
1223
|
+
getCommandIds() {
|
|
1224
|
+
const keys = Object.keys(commandMapRef);
|
|
1225
|
+
const ids = keys.map(toCommandId);
|
|
1226
|
+
return ids;
|
|
1227
|
+
},
|
|
1079
1228
|
getKeys() {
|
|
1080
|
-
return Object.keys(states).map(
|
|
1081
|
-
return Number.parseInt(key);
|
|
1082
|
-
});
|
|
1229
|
+
return Object.keys(states).map(Number);
|
|
1083
1230
|
},
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1231
|
+
registerCommands(commandMap) {
|
|
1232
|
+
Object.assign(commandMapRef, commandMap);
|
|
1233
|
+
for (const [key, fn] of Object.entries(commandMap)) {
|
|
1234
|
+
commandsById[toCommandId(key)] = fn;
|
|
1235
|
+
}
|
|
1236
|
+
},
|
|
1237
|
+
set(uid, oldState, newState, scheduledState) {
|
|
1238
|
+
const current = states[uid];
|
|
1239
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
1240
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
1087
1241
|
}
|
|
1242
|
+
states[uid] = {
|
|
1243
|
+
newState,
|
|
1244
|
+
oldState,
|
|
1245
|
+
scheduledState: scheduledState ?? newState
|
|
1246
|
+
};
|
|
1247
|
+
},
|
|
1248
|
+
wrapAsyncCommand(fn) {
|
|
1249
|
+
const wrapped = async (uid, ...args) => {
|
|
1250
|
+
const generation = getGeneration(uid);
|
|
1251
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1252
|
+
await fn(context, ...args);
|
|
1253
|
+
};
|
|
1254
|
+
return wrapped;
|
|
1088
1255
|
},
|
|
1089
1256
|
wrapCommand(fn) {
|
|
1090
1257
|
const wrapped = async (uid, ...args) => {
|
|
1258
|
+
const generation = getGeneration(uid);
|
|
1091
1259
|
const {
|
|
1092
|
-
|
|
1093
|
-
|
|
1260
|
+
newState,
|
|
1261
|
+
oldState
|
|
1094
1262
|
} = states[uid];
|
|
1095
1263
|
const newerState = await fn(newState, ...args);
|
|
1096
1264
|
if (oldState === newerState || newState === newerState) {
|
|
1097
1265
|
return;
|
|
1098
1266
|
}
|
|
1099
|
-
|
|
1267
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
const latestOld = states[uid];
|
|
1271
|
+
const latestNew = {
|
|
1272
|
+
...latestOld.newState,
|
|
1273
|
+
...newerState
|
|
1274
|
+
};
|
|
1100
1275
|
states[uid] = {
|
|
1101
|
-
|
|
1102
|
-
|
|
1276
|
+
newState: latestNew,
|
|
1277
|
+
oldState: latestOld.oldState,
|
|
1278
|
+
scheduledState: latestNew
|
|
1103
1279
|
};
|
|
1104
1280
|
};
|
|
1105
1281
|
return wrapped;
|
|
@@ -1113,27 +1289,88 @@ const create$2 = () => {
|
|
|
1113
1289
|
};
|
|
1114
1290
|
return wrapped;
|
|
1115
1291
|
},
|
|
1116
|
-
|
|
1117
|
-
const {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1125
|
-
|
|
1292
|
+
wrapLoadContent(fn) {
|
|
1293
|
+
const wrapped = async (uid, ...args) => {
|
|
1294
|
+
const generation = getGeneration(uid);
|
|
1295
|
+
const {
|
|
1296
|
+
newState,
|
|
1297
|
+
oldState
|
|
1298
|
+
} = states[uid];
|
|
1299
|
+
const result = await fn(newState, ...args);
|
|
1300
|
+
const {
|
|
1301
|
+
error,
|
|
1302
|
+
state
|
|
1303
|
+
} = result;
|
|
1304
|
+
if (oldState === state || newState === state) {
|
|
1305
|
+
return {
|
|
1306
|
+
error
|
|
1307
|
+
};
|
|
1126
1308
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1309
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1310
|
+
return {
|
|
1311
|
+
error
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
const latestOld = states[uid];
|
|
1315
|
+
const latestNew = {
|
|
1316
|
+
...latestOld.newState,
|
|
1317
|
+
...state
|
|
1318
|
+
};
|
|
1319
|
+
states[uid] = {
|
|
1320
|
+
newState: latestNew,
|
|
1321
|
+
oldState: latestOld.oldState,
|
|
1322
|
+
scheduledState: latestNew
|
|
1323
|
+
};
|
|
1324
|
+
return {
|
|
1325
|
+
error
|
|
1326
|
+
};
|
|
1327
|
+
};
|
|
1328
|
+
return wrapped;
|
|
1129
1329
|
},
|
|
1130
|
-
|
|
1131
|
-
const
|
|
1132
|
-
|
|
1133
|
-
|
|
1330
|
+
wrapSerialAsyncCommand(fn) {
|
|
1331
|
+
const wrapped = async (uid, ...args) => {
|
|
1332
|
+
await enqueueCommand(uid, async () => {
|
|
1333
|
+
if (!states[uid]) {
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
const generation = getGeneration(uid);
|
|
1337
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1338
|
+
await fn(context, ...args);
|
|
1339
|
+
});
|
|
1340
|
+
};
|
|
1341
|
+
return wrapped;
|
|
1134
1342
|
},
|
|
1135
|
-
|
|
1136
|
-
|
|
1343
|
+
wrapSerialCommand(fn) {
|
|
1344
|
+
const wrapped = async (uid, ...args) => {
|
|
1345
|
+
await enqueueCommand(uid, async () => {
|
|
1346
|
+
if (!states[uid]) {
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
const generation = getGeneration(uid);
|
|
1350
|
+
const {
|
|
1351
|
+
newState,
|
|
1352
|
+
oldState
|
|
1353
|
+
} = states[uid];
|
|
1354
|
+
const newerState = await fn(newState, ...args);
|
|
1355
|
+
if (oldState === newerState || newState === newerState) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
const latestOld = states[uid];
|
|
1362
|
+
const latestNew = {
|
|
1363
|
+
...latestOld.newState,
|
|
1364
|
+
...newerState
|
|
1365
|
+
};
|
|
1366
|
+
states[uid] = {
|
|
1367
|
+
newState: latestNew,
|
|
1368
|
+
oldState: latestOld.oldState,
|
|
1369
|
+
scheduledState: latestNew
|
|
1370
|
+
};
|
|
1371
|
+
});
|
|
1372
|
+
};
|
|
1373
|
+
return wrapped;
|
|
1137
1374
|
}
|
|
1138
1375
|
};
|
|
1139
1376
|
};
|
|
@@ -1226,7 +1463,7 @@ const validateSettings = (items, modifiedSettings, preferences) => {
|
|
|
1226
1463
|
modified,
|
|
1227
1464
|
options: item.options,
|
|
1228
1465
|
type: item.type,
|
|
1229
|
-
value
|
|
1466
|
+
value
|
|
1230
1467
|
};
|
|
1231
1468
|
});
|
|
1232
1469
|
};
|
|
@@ -1736,7 +1973,7 @@ const ScrollBarThumb = 'ScrollBarThumb';
|
|
|
1736
1973
|
const ScrollBarThumbActive = 'ScrollBarThumbActive';
|
|
1737
1974
|
const ScrollbarTrack = 'ScrollbarTrack';
|
|
1738
1975
|
const ScrollBarVertical = 'ScrollBarVertical';
|
|
1739
|
-
const Search = 'Search';
|
|
1976
|
+
const Search$1 = 'Search';
|
|
1740
1977
|
const SearchField = 'SearchField';
|
|
1741
1978
|
const SearchFieldButton$1 = 'SearchFieldButton';
|
|
1742
1979
|
const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
|
|
@@ -1764,7 +2001,7 @@ const SourceActionIcon = 'SourceActionIcon';
|
|
|
1764
2001
|
const SourceActionItem = 'SourceActionItem';
|
|
1765
2002
|
const SourceActionItemFocused = 'SourceActionItemFocused';
|
|
1766
2003
|
const SourceControlBadge = 'SourceControlBadge';
|
|
1767
|
-
const Table = 'Table';
|
|
2004
|
+
const Table$1 = 'Table';
|
|
1768
2005
|
const TableCell = 'TableCell';
|
|
1769
2006
|
const TableHeading = 'TableHeading';
|
|
1770
2007
|
const ToggleDetails = 'ToggleDetails';
|
|
@@ -1972,7 +2209,7 @@ const ClassNames = {
|
|
|
1972
2209
|
Scrollbar,
|
|
1973
2210
|
ScrollbarThumb,
|
|
1974
2211
|
ScrollbarTrack,
|
|
1975
|
-
Search,
|
|
2212
|
+
Search: Search$1,
|
|
1976
2213
|
SearchField,
|
|
1977
2214
|
SearchFieldButton: SearchFieldButton$1,
|
|
1978
2215
|
SearchFieldButtonChecked,
|
|
@@ -2000,7 +2237,7 @@ const ClassNames = {
|
|
|
2000
2237
|
SourceActionItem,
|
|
2001
2238
|
SourceActionItemFocused,
|
|
2002
2239
|
SourceControlBadge,
|
|
2003
|
-
Table,
|
|
2240
|
+
Table: Table$1,
|
|
2004
2241
|
TableCell,
|
|
2005
2242
|
TableHeading,
|
|
2006
2243
|
ToggleDetails,
|
|
@@ -2017,18 +2254,174 @@ const ClassNames = {
|
|
|
2017
2254
|
WelcomeMessage
|
|
2018
2255
|
};
|
|
2019
2256
|
|
|
2257
|
+
const Audio = 0;
|
|
2020
2258
|
const Button = 1;
|
|
2259
|
+
const Col = 2;
|
|
2260
|
+
const ColGroup = 3;
|
|
2021
2261
|
const Div = 4;
|
|
2022
2262
|
const H1 = 5;
|
|
2023
2263
|
const Input = 6;
|
|
2264
|
+
const Kbd = 7;
|
|
2265
|
+
const Span = 8;
|
|
2266
|
+
const Table = 9;
|
|
2267
|
+
const TBody = 10;
|
|
2268
|
+
const Td = 11;
|
|
2024
2269
|
const Text = 12;
|
|
2270
|
+
const Th = 13;
|
|
2271
|
+
const THead = 14;
|
|
2272
|
+
const Tr = 15;
|
|
2273
|
+
const I = 16;
|
|
2274
|
+
const Img = 17;
|
|
2275
|
+
const Root = 0;
|
|
2276
|
+
const Ins = 20;
|
|
2277
|
+
const Del = 21;
|
|
2278
|
+
const H2 = 22;
|
|
2025
2279
|
const H3 = 23;
|
|
2280
|
+
const H4 = 24;
|
|
2281
|
+
const H5 = 25;
|
|
2282
|
+
const H6 = 26;
|
|
2283
|
+
const Article = 27;
|
|
2026
2284
|
const Aside = 28;
|
|
2285
|
+
const Footer = 29;
|
|
2286
|
+
const Header = 30;
|
|
2287
|
+
const Nav = 40;
|
|
2288
|
+
const Section = 41;
|
|
2289
|
+
const Search = 42;
|
|
2290
|
+
const Dd = 43;
|
|
2291
|
+
const Dl = 44;
|
|
2292
|
+
const Figcaption = 45;
|
|
2293
|
+
const Figure = 46;
|
|
2294
|
+
const Hr = 47;
|
|
2295
|
+
const Li = 48;
|
|
2296
|
+
const Ol = 49;
|
|
2027
2297
|
const P = 50;
|
|
2298
|
+
const Pre = 51;
|
|
2299
|
+
const A = 53;
|
|
2300
|
+
const Abbr = 54;
|
|
2301
|
+
const Br = 55;
|
|
2302
|
+
const Cite = 56;
|
|
2303
|
+
const Data = 57;
|
|
2304
|
+
const Time = 58;
|
|
2305
|
+
const Tfoot = 59;
|
|
2028
2306
|
const Ul = 60;
|
|
2307
|
+
const Video = 61;
|
|
2308
|
+
const TextArea = 62;
|
|
2029
2309
|
const Select$1 = 63;
|
|
2030
2310
|
const Option = 64;
|
|
2311
|
+
const Code = 65;
|
|
2031
2312
|
const Label$1 = 66;
|
|
2313
|
+
const Dt = 67;
|
|
2314
|
+
const Iframe = 68;
|
|
2315
|
+
const Main = 69;
|
|
2316
|
+
const Strong = 70;
|
|
2317
|
+
const Em = 71;
|
|
2318
|
+
const Style = 72;
|
|
2319
|
+
const Html = 73;
|
|
2320
|
+
const Head = 74;
|
|
2321
|
+
const Title = 75;
|
|
2322
|
+
const Meta = 76;
|
|
2323
|
+
const Canvas = 77;
|
|
2324
|
+
const Form = 78;
|
|
2325
|
+
const BlockQuote = 79;
|
|
2326
|
+
const Quote = 80;
|
|
2327
|
+
const Circle = 81;
|
|
2328
|
+
const Defs = 82;
|
|
2329
|
+
const Ellipse = 83;
|
|
2330
|
+
const G = 84;
|
|
2331
|
+
const Line = 85;
|
|
2332
|
+
const Path = 86;
|
|
2333
|
+
const Polygon = 87;
|
|
2334
|
+
const Polyline = 88;
|
|
2335
|
+
const Rect = 89;
|
|
2336
|
+
const Svg = 90;
|
|
2337
|
+
const Use = 91;
|
|
2338
|
+
const Reference = 100;
|
|
2339
|
+
|
|
2340
|
+
const VirtualDomElements = {
|
|
2341
|
+
__proto__: null,
|
|
2342
|
+
A,
|
|
2343
|
+
Abbr,
|
|
2344
|
+
Article,
|
|
2345
|
+
Aside,
|
|
2346
|
+
Audio,
|
|
2347
|
+
BlockQuote,
|
|
2348
|
+
Br,
|
|
2349
|
+
Button,
|
|
2350
|
+
Canvas,
|
|
2351
|
+
Circle,
|
|
2352
|
+
Cite,
|
|
2353
|
+
Code,
|
|
2354
|
+
Col,
|
|
2355
|
+
ColGroup,
|
|
2356
|
+
Data,
|
|
2357
|
+
Dd,
|
|
2358
|
+
Defs,
|
|
2359
|
+
Del,
|
|
2360
|
+
Div,
|
|
2361
|
+
Dl,
|
|
2362
|
+
Dt,
|
|
2363
|
+
Ellipse,
|
|
2364
|
+
Em,
|
|
2365
|
+
Figcaption,
|
|
2366
|
+
Figure,
|
|
2367
|
+
Footer,
|
|
2368
|
+
Form,
|
|
2369
|
+
G,
|
|
2370
|
+
H1,
|
|
2371
|
+
H2,
|
|
2372
|
+
H3,
|
|
2373
|
+
H4,
|
|
2374
|
+
H5,
|
|
2375
|
+
H6,
|
|
2376
|
+
Head,
|
|
2377
|
+
Header,
|
|
2378
|
+
Hr,
|
|
2379
|
+
Html,
|
|
2380
|
+
I,
|
|
2381
|
+
Iframe,
|
|
2382
|
+
Img,
|
|
2383
|
+
Input,
|
|
2384
|
+
Ins,
|
|
2385
|
+
Kbd,
|
|
2386
|
+
Label: Label$1,
|
|
2387
|
+
Li,
|
|
2388
|
+
Line,
|
|
2389
|
+
Main,
|
|
2390
|
+
Meta,
|
|
2391
|
+
Nav,
|
|
2392
|
+
Ol,
|
|
2393
|
+
Option,
|
|
2394
|
+
P,
|
|
2395
|
+
Path,
|
|
2396
|
+
Polygon,
|
|
2397
|
+
Polyline,
|
|
2398
|
+
Pre,
|
|
2399
|
+
Quote,
|
|
2400
|
+
Rect,
|
|
2401
|
+
Reference,
|
|
2402
|
+
Root,
|
|
2403
|
+
Search,
|
|
2404
|
+
Section,
|
|
2405
|
+
Select: Select$1,
|
|
2406
|
+
Span,
|
|
2407
|
+
Strong,
|
|
2408
|
+
Style,
|
|
2409
|
+
Svg,
|
|
2410
|
+
TBody,
|
|
2411
|
+
THead,
|
|
2412
|
+
Table,
|
|
2413
|
+
Td,
|
|
2414
|
+
Text,
|
|
2415
|
+
TextArea,
|
|
2416
|
+
Tfoot,
|
|
2417
|
+
Th,
|
|
2418
|
+
Time,
|
|
2419
|
+
Title,
|
|
2420
|
+
Tr,
|
|
2421
|
+
Ul,
|
|
2422
|
+
Use,
|
|
2423
|
+
Video
|
|
2424
|
+
};
|
|
2032
2425
|
|
|
2033
2426
|
const ClientX = 'event.clientX';
|
|
2034
2427
|
const ClientY = 'event.clientY';
|
|
@@ -2045,6 +2438,9 @@ const SettingsFilter = 94;
|
|
|
2045
2438
|
const None$1 = 0;
|
|
2046
2439
|
const Disabled = 5;
|
|
2047
2440
|
|
|
2441
|
+
const RendererProcess = 1670;
|
|
2442
|
+
const RendererWorker = 1;
|
|
2443
|
+
|
|
2048
2444
|
const SetCss = 'Viewlet.setCss';
|
|
2049
2445
|
|
|
2050
2446
|
const mergeClassNames = (...classNames) => {
|
|
@@ -2059,6 +2455,8 @@ const text = data => {
|
|
|
2059
2455
|
};
|
|
2060
2456
|
};
|
|
2061
2457
|
|
|
2458
|
+
new Set(Object.values(VirtualDomElements));
|
|
2459
|
+
|
|
2062
2460
|
const getKeyBindings = () => {
|
|
2063
2461
|
return [{
|
|
2064
2462
|
command: 'Settings.usePreviousSearchValue',
|
|
@@ -2072,18 +2470,19 @@ const getKeyBindings = () => {
|
|
|
2072
2470
|
};
|
|
2073
2471
|
|
|
2074
2472
|
const emptyObject = {};
|
|
2075
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
2076
2473
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
2077
2474
|
if (placeholders === emptyObject) {
|
|
2078
2475
|
return key;
|
|
2079
2476
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2477
|
+
let result = key;
|
|
2478
|
+
for (const [placeholder, replacement] of Object.entries(placeholders)) {
|
|
2479
|
+
result = result.split(`{${placeholder}}`).join(String(replacement));
|
|
2480
|
+
}
|
|
2481
|
+
return result;
|
|
2084
2482
|
};
|
|
2085
2483
|
|
|
2086
2484
|
const Advanced = 'Advanced';
|
|
2485
|
+
const ArrayValue = 'array value';
|
|
2087
2486
|
const Clear$1 = 'Clear';
|
|
2088
2487
|
const ColorValue = 'Color value';
|
|
2089
2488
|
const Experimental = 'Experimental';
|
|
@@ -2105,6 +2504,7 @@ const Tag = 'Tag';
|
|
|
2105
2504
|
const UnknownSettingType = 'Unknown setting type';
|
|
2106
2505
|
|
|
2107
2506
|
const advanced = () => i18nString(Advanced);
|
|
2507
|
+
const arrayValue = () => i18nString(ArrayValue);
|
|
2108
2508
|
const clear = () => i18nString(Clear$1);
|
|
2109
2509
|
const colorValue = () => i18nString(ColorValue);
|
|
2110
2510
|
const experimental = () => i18nString(Experimental);
|
|
@@ -2214,26 +2614,6 @@ const getName = () => {
|
|
|
2214
2614
|
return 'Settings';
|
|
2215
2615
|
};
|
|
2216
2616
|
|
|
2217
|
-
const createMockRpc = ({
|
|
2218
|
-
commandMap
|
|
2219
|
-
}) => {
|
|
2220
|
-
const invocations = [];
|
|
2221
|
-
const invoke = (method, ...params) => {
|
|
2222
|
-
invocations.push([method, ...params]);
|
|
2223
|
-
const command = commandMap[method];
|
|
2224
|
-
if (!command) {
|
|
2225
|
-
throw new Error(`command ${method} not found`);
|
|
2226
|
-
}
|
|
2227
|
-
return command(...params);
|
|
2228
|
-
};
|
|
2229
|
-
const mockRpc = {
|
|
2230
|
-
invocations,
|
|
2231
|
-
invoke,
|
|
2232
|
-
invokeAndTransfer: invoke
|
|
2233
|
-
};
|
|
2234
|
-
return mockRpc;
|
|
2235
|
-
};
|
|
2236
|
-
|
|
2237
2617
|
const rpcs = Object.create(null);
|
|
2238
2618
|
const set$5 = (id, rpc) => {
|
|
2239
2619
|
rpcs[id] = rpc;
|
|
@@ -2282,9 +2662,6 @@ const create = rpcId => {
|
|
|
2282
2662
|
};
|
|
2283
2663
|
};
|
|
2284
2664
|
|
|
2285
|
-
const RendererProcess = 1670;
|
|
2286
|
-
const RendererWorker = 1;
|
|
2287
|
-
|
|
2288
2665
|
const {
|
|
2289
2666
|
invoke: invoke$3,
|
|
2290
2667
|
set: set$4
|
|
@@ -2464,7 +2841,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
2464
2841
|
await fn(uid, ...args);
|
|
2465
2842
|
await invoke$2('Viewlet.requestRender', uid);
|
|
2466
2843
|
};
|
|
2467
|
-
const rpc = await
|
|
2844
|
+
const rpc = await create$6({
|
|
2468
2845
|
commandMap: {
|
|
2469
2846
|
'Viewlet.executeViewletCommand': executeViewletCommand
|
|
2470
2847
|
},
|
|
@@ -2551,8 +2928,9 @@ const handleSettingChecked = (state, name, value, source = User) => {
|
|
|
2551
2928
|
};
|
|
2552
2929
|
|
|
2553
2930
|
const Enum = 1;
|
|
2554
|
-
const String = 2;
|
|
2931
|
+
const String$1 = 2;
|
|
2555
2932
|
const Boolean$1 = 3;
|
|
2933
|
+
const Array$1 = 4;
|
|
2556
2934
|
const Number$1 = 5;
|
|
2557
2935
|
const Color = 6;
|
|
2558
2936
|
const Url = 7;
|
|
@@ -2564,6 +2942,17 @@ const handleSettingInput = (state, name, value, inputSource = User) => {
|
|
|
2564
2942
|
|
|
2565
2943
|
// TODO maybe have separate input functions for number and string inputs
|
|
2566
2944
|
const settingItem = items.find(item => item.id === name);
|
|
2945
|
+
if (settingItem && settingItem.type === Array$1) {
|
|
2946
|
+
try {
|
|
2947
|
+
const arrayValue = JSON.parse(value);
|
|
2948
|
+
if (!Array.isArray(arrayValue)) {
|
|
2949
|
+
return state;
|
|
2950
|
+
}
|
|
2951
|
+
return handleSettingUpdate(state, name, arrayValue, inputSource);
|
|
2952
|
+
} catch {
|
|
2953
|
+
return state;
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2567
2956
|
if (settingItem && settingItem.type === Number$1) {
|
|
2568
2957
|
const numberValue = value === '' ? '' : Number(value);
|
|
2569
2958
|
return handleSettingUpdate(state, name, numberValue, inputSource);
|
|
@@ -2639,7 +3028,7 @@ const send = async port => {
|
|
|
2639
3028
|
await sendMessagePortToSettingsWorker(port, 0);
|
|
2640
3029
|
};
|
|
2641
3030
|
const launchSettingsWorker = async () => {
|
|
2642
|
-
return
|
|
3031
|
+
return create$4({
|
|
2643
3032
|
commandMap: commandMap$1,
|
|
2644
3033
|
send
|
|
2645
3034
|
});
|
|
@@ -3091,6 +3480,37 @@ const getItemLabelDom = (domId, label) => {
|
|
|
3091
3480
|
}, text(label)];
|
|
3092
3481
|
};
|
|
3093
3482
|
|
|
3483
|
+
const getItemArrayVirtualDom = item => {
|
|
3484
|
+
const {
|
|
3485
|
+
description,
|
|
3486
|
+
errorMessage,
|
|
3487
|
+
hasError,
|
|
3488
|
+
heading,
|
|
3489
|
+
id,
|
|
3490
|
+
modified
|
|
3491
|
+
} = item;
|
|
3492
|
+
const domId = getInputId(id);
|
|
3493
|
+
const inputClassName = hasError ? mergeClassNames(InputBox, InputBoxError) : InputBox;
|
|
3494
|
+
const errorChildCount = hasError ? 1 : 0;
|
|
3495
|
+
return [{
|
|
3496
|
+
childCount: 3 + errorChildCount,
|
|
3497
|
+
className: SettingsItem,
|
|
3498
|
+
'data-modified': modified,
|
|
3499
|
+
name: id,
|
|
3500
|
+
role: Group,
|
|
3501
|
+
type: Div
|
|
3502
|
+
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
3503
|
+
childCount: 0,
|
|
3504
|
+
className: inputClassName,
|
|
3505
|
+
id: domId,
|
|
3506
|
+
inputType: 'text',
|
|
3507
|
+
name: id,
|
|
3508
|
+
onInput: HandleSettingInput,
|
|
3509
|
+
placeholder: arrayValue(),
|
|
3510
|
+
type: Input
|
|
3511
|
+
}, ...getErrorMessageDom(errorMessage)];
|
|
3512
|
+
};
|
|
3513
|
+
|
|
3094
3514
|
const checkBoxWrapperNode = {
|
|
3095
3515
|
childCount: 2,
|
|
3096
3516
|
className: SettingsItemCheckBox,
|
|
@@ -3103,11 +3523,13 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3103
3523
|
hasError,
|
|
3104
3524
|
heading,
|
|
3105
3525
|
id,
|
|
3106
|
-
modified
|
|
3526
|
+
modified,
|
|
3527
|
+
value
|
|
3107
3528
|
} = item;
|
|
3108
3529
|
const domId = getInputId(id);
|
|
3109
3530
|
const checkBoxClassName = hasError ? mergeClassNames(CheckBox, InputBoxError) : CheckBox;
|
|
3110
3531
|
const errorChildCount = hasError ? 1 : 0;
|
|
3532
|
+
const isChecked = value === true || value === 'true';
|
|
3111
3533
|
return [{
|
|
3112
3534
|
childCount: 2 + errorChildCount,
|
|
3113
3535
|
className: SettingsItem,
|
|
@@ -3116,6 +3538,7 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3116
3538
|
role: Group,
|
|
3117
3539
|
type: Div
|
|
3118
3540
|
}, ...getItemHeadingDom(heading), checkBoxWrapperNode, {
|
|
3541
|
+
checked: isChecked,
|
|
3119
3542
|
childCount: 0,
|
|
3120
3543
|
className: checkBoxClassName,
|
|
3121
3544
|
id: domId,
|
|
@@ -3329,6 +3752,8 @@ const getItemUrlVirtualDom = item => {
|
|
|
3329
3752
|
|
|
3330
3753
|
const getItemRender = type => {
|
|
3331
3754
|
switch (type) {
|
|
3755
|
+
case Array$1:
|
|
3756
|
+
return getItemArrayVirtualDom;
|
|
3332
3757
|
case Boolean$1:
|
|
3333
3758
|
return getItemCheckBoxVirtualDom;
|
|
3334
3759
|
case Color:
|
|
@@ -3337,7 +3762,7 @@ const getItemRender = type => {
|
|
|
3337
3762
|
return getItemSelectVirtualDom;
|
|
3338
3763
|
case Number$1:
|
|
3339
3764
|
return getItemNumberVirtualDom;
|
|
3340
|
-
case String:
|
|
3765
|
+
case String$1:
|
|
3341
3766
|
return getItemStringVirtualDom;
|
|
3342
3767
|
case Url:
|
|
3343
3768
|
return getItemUrlVirtualDom;
|
|
@@ -3466,7 +3891,13 @@ const renderItems = (oldState, newState) => {
|
|
|
3466
3891
|
return ['Viewlet.setDom2', newState.id, dom];
|
|
3467
3892
|
};
|
|
3468
3893
|
|
|
3469
|
-
const enabledTypes = [Number$1, String, Color];
|
|
3894
|
+
const enabledTypes = [Array$1, Number$1, String$1, Color];
|
|
3895
|
+
const getInputValue = (type, value) => {
|
|
3896
|
+
if (type === Array$1) {
|
|
3897
|
+
return JSON.stringify(value);
|
|
3898
|
+
}
|
|
3899
|
+
return value;
|
|
3900
|
+
};
|
|
3470
3901
|
const renderSettingValues = (oldState, newState) => {
|
|
3471
3902
|
const {
|
|
3472
3903
|
filteredItems,
|
|
@@ -3475,7 +3906,7 @@ const renderSettingValues = (oldState, newState) => {
|
|
|
3475
3906
|
} = newState;
|
|
3476
3907
|
const enabledSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
|
|
3477
3908
|
const inputValues = enabledSettings.map(item => {
|
|
3478
|
-
const value = preferences[item.id] ?? item.value;
|
|
3909
|
+
const value = getInputValue(item.type, preferences[item.id] ?? item.value);
|
|
3479
3910
|
return {
|
|
3480
3911
|
name: item.id,
|
|
3481
3912
|
value
|
|
@@ -3745,7 +4176,7 @@ const set = rpc => {
|
|
|
3745
4176
|
|
|
3746
4177
|
const listen = async () => {
|
|
3747
4178
|
registerCommands(commandMap);
|
|
3748
|
-
const rpc = await
|
|
4179
|
+
const rpc = await create$3({
|
|
3749
4180
|
commandMap: commandMap
|
|
3750
4181
|
});
|
|
3751
4182
|
set(rpc);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/settings-view",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.27.1",
|
|
4
4
|
"description": "Explorer Worker",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/settingsViewWorkerMain.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@lvce-editor/constants": "^
|
|
14
|
+
"@lvce-editor/constants": "^5.28.0"
|
|
15
15
|
}
|
|
16
16
|
}
|