@lvce-editor/extension-detail-view 3.63.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensionDetailViewWorkerMain.js +1925 -1767
- package/package.json +5 -1
|
@@ -637,10 +637,10 @@ const getFeatureVirtualDomHandler = featureName => {
|
|
|
637
637
|
};
|
|
638
638
|
|
|
639
639
|
const rpcs = Object.create(null);
|
|
640
|
-
const set$
|
|
640
|
+
const set$b = (id, rpc) => {
|
|
641
641
|
rpcs[id] = rpc;
|
|
642
642
|
};
|
|
643
|
-
const get$
|
|
643
|
+
const get$3 = id => {
|
|
644
644
|
return rpcs[id];
|
|
645
645
|
};
|
|
646
646
|
|
|
@@ -648,2010 +648,2131 @@ const create$7 = rpcId => {
|
|
|
648
648
|
return {
|
|
649
649
|
// @ts-ignore
|
|
650
650
|
invoke(method, ...params) {
|
|
651
|
-
const rpc = get$
|
|
651
|
+
const rpc = get$3(rpcId);
|
|
652
652
|
// @ts-ignore
|
|
653
653
|
return rpc.invoke(method, ...params);
|
|
654
654
|
},
|
|
655
655
|
// @ts-ignore
|
|
656
656
|
invokeAndTransfer(method, ...params) {
|
|
657
|
-
const rpc = get$
|
|
657
|
+
const rpc = get$3(rpcId);
|
|
658
658
|
// @ts-ignore
|
|
659
659
|
return rpc.invokeAndTransfer(method, ...params);
|
|
660
660
|
},
|
|
661
661
|
set(rpc) {
|
|
662
|
-
set$
|
|
662
|
+
set$b(rpcId, rpc);
|
|
663
663
|
},
|
|
664
664
|
async dispose() {
|
|
665
|
-
const rpc = get$
|
|
665
|
+
const rpc = get$3(rpcId);
|
|
666
666
|
await rpc.dispose();
|
|
667
667
|
}
|
|
668
668
|
};
|
|
669
669
|
};
|
|
670
670
|
|
|
671
|
-
const {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
return invoke$5('ExtensionHostReference.executeReferenceProvider', id, offset);
|
|
671
|
+
const normalizeLine = line => {
|
|
672
|
+
if (line.startsWith('Error: ')) {
|
|
673
|
+
return line.slice('Error: '.length);
|
|
674
|
+
}
|
|
675
|
+
if (line.startsWith('VError: ')) {
|
|
676
|
+
return line.slice('VError: '.length);
|
|
677
|
+
}
|
|
678
|
+
return line;
|
|
680
679
|
};
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
680
|
+
const getCombinedMessage = (error, message) => {
|
|
681
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
682
|
+
if (message) {
|
|
683
|
+
return `${message}: ${stringifiedError}`;
|
|
684
|
+
}
|
|
685
|
+
return stringifiedError;
|
|
684
686
|
};
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
return
|
|
687
|
+
const NewLine$2 = '\n';
|
|
688
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
689
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
688
690
|
};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
691
|
+
const mergeStacks = (parent, child) => {
|
|
692
|
+
if (!child) {
|
|
693
|
+
return parent;
|
|
694
|
+
}
|
|
695
|
+
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
696
|
+
const childNewLineIndex = getNewLineIndex$1(child);
|
|
697
|
+
if (childNewLineIndex === -1) {
|
|
698
|
+
return parent;
|
|
699
|
+
}
|
|
700
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
701
|
+
const childRest = child.slice(childNewLineIndex);
|
|
702
|
+
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
703
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
704
|
+
return parentFirstLine + childRest;
|
|
705
|
+
}
|
|
706
|
+
return child;
|
|
699
707
|
};
|
|
708
|
+
class VError extends Error {
|
|
709
|
+
constructor(error, message) {
|
|
710
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
711
|
+
super(combinedMessage);
|
|
712
|
+
this.name = 'VError';
|
|
713
|
+
if (error instanceof Error) {
|
|
714
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
715
|
+
}
|
|
716
|
+
if (error.codeFrame) {
|
|
717
|
+
// @ts-ignore
|
|
718
|
+
this.codeFrame = error.codeFrame;
|
|
719
|
+
}
|
|
720
|
+
if (error.code) {
|
|
721
|
+
// @ts-ignore
|
|
722
|
+
this.code = error.code;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
700
726
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
const
|
|
708
|
-
|
|
727
|
+
class AssertionError extends Error {
|
|
728
|
+
constructor(message) {
|
|
729
|
+
super(message);
|
|
730
|
+
this.name = 'AssertionError';
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
const Object$1 = 1;
|
|
734
|
+
const Number$1 = 2;
|
|
735
|
+
const Array$1 = 3;
|
|
736
|
+
const String = 4;
|
|
737
|
+
const Boolean$1 = 5;
|
|
738
|
+
const Function = 6;
|
|
739
|
+
const Null = 7;
|
|
740
|
+
const Unknown = 8;
|
|
741
|
+
const getType = value => {
|
|
742
|
+
switch (typeof value) {
|
|
743
|
+
case 'number':
|
|
744
|
+
return Number$1;
|
|
745
|
+
case 'function':
|
|
746
|
+
return Function;
|
|
747
|
+
case 'string':
|
|
748
|
+
return String;
|
|
749
|
+
case 'object':
|
|
750
|
+
if (value === null) {
|
|
751
|
+
return Null;
|
|
752
|
+
}
|
|
753
|
+
if (Array.isArray(value)) {
|
|
754
|
+
return Array$1;
|
|
755
|
+
}
|
|
756
|
+
return Object$1;
|
|
757
|
+
case 'boolean':
|
|
758
|
+
return Boolean$1;
|
|
759
|
+
default:
|
|
760
|
+
return Unknown;
|
|
761
|
+
}
|
|
709
762
|
};
|
|
710
|
-
const
|
|
711
|
-
|
|
763
|
+
const string = value => {
|
|
764
|
+
const type = getType(value);
|
|
765
|
+
if (type !== String) {
|
|
766
|
+
throw new AssertionError('expected value to be of type string');
|
|
767
|
+
}
|
|
712
768
|
};
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
return
|
|
769
|
+
|
|
770
|
+
const isMessagePort = value => {
|
|
771
|
+
return value && value instanceof MessagePort;
|
|
716
772
|
};
|
|
717
|
-
const
|
|
718
|
-
return
|
|
773
|
+
const isMessagePortMain = value => {
|
|
774
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
719
775
|
};
|
|
720
|
-
const
|
|
721
|
-
return
|
|
776
|
+
const isOffscreenCanvas = value => {
|
|
777
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
722
778
|
};
|
|
723
|
-
const
|
|
724
|
-
return
|
|
779
|
+
const isInstanceOf = (value, constructorName) => {
|
|
780
|
+
return value?.constructor?.name === constructorName;
|
|
725
781
|
};
|
|
726
|
-
const
|
|
727
|
-
return
|
|
782
|
+
const isSocket = value => {
|
|
783
|
+
return isInstanceOf(value, 'Socket');
|
|
728
784
|
};
|
|
729
|
-
const
|
|
730
|
-
|
|
785
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
786
|
+
const isTransferrable = value => {
|
|
787
|
+
for (const fn of transferrables) {
|
|
788
|
+
if (fn(value)) {
|
|
789
|
+
return true;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return false;
|
|
731
793
|
};
|
|
732
|
-
const
|
|
733
|
-
|
|
794
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
795
|
+
if (!value) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
if (isTransferrable(value)) {
|
|
799
|
+
transferrables.push(value);
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (Array.isArray(value)) {
|
|
803
|
+
for (const item of value) {
|
|
804
|
+
walkValue(item, transferrables, isTransferrable);
|
|
805
|
+
}
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (typeof value === 'object') {
|
|
809
|
+
for (const property of Object.values(value)) {
|
|
810
|
+
walkValue(property, transferrables, isTransferrable);
|
|
811
|
+
}
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
734
814
|
};
|
|
735
|
-
const
|
|
736
|
-
|
|
815
|
+
const getTransferrables = value => {
|
|
816
|
+
const transferrables = [];
|
|
817
|
+
walkValue(value, transferrables, isTransferrable);
|
|
818
|
+
return transferrables;
|
|
737
819
|
};
|
|
738
|
-
const
|
|
739
|
-
|
|
820
|
+
const attachEvents = that => {
|
|
821
|
+
const handleMessage = (...args) => {
|
|
822
|
+
const data = that.getData(...args);
|
|
823
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
824
|
+
data
|
|
825
|
+
}));
|
|
826
|
+
};
|
|
827
|
+
that.onMessage(handleMessage);
|
|
828
|
+
const handleClose = event => {
|
|
829
|
+
that.dispatchEvent(new Event('close'));
|
|
830
|
+
};
|
|
831
|
+
that.onClose(handleClose);
|
|
740
832
|
};
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
833
|
+
class Ipc extends EventTarget {
|
|
834
|
+
constructor(rawIpc) {
|
|
835
|
+
super();
|
|
836
|
+
this._rawIpc = rawIpc;
|
|
837
|
+
attachEvents(this);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
841
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
842
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
843
|
+
const NewLine$1 = '\n';
|
|
844
|
+
const joinLines$1 = lines => {
|
|
845
|
+
return lines.join(NewLine$1);
|
|
744
846
|
};
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
|
|
847
|
+
const RE_AT = /^\s+at/;
|
|
848
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
849
|
+
const isNormalStackLine = line => {
|
|
850
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
748
851
|
};
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
852
|
+
const getDetails = lines => {
|
|
853
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
854
|
+
if (index === -1) {
|
|
855
|
+
return {
|
|
856
|
+
actualMessage: joinLines$1(lines),
|
|
857
|
+
rest: []
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
let lastIndex = index - 1;
|
|
861
|
+
while (++lastIndex < lines.length) {
|
|
862
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
863
|
+
break;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return {
|
|
867
|
+
actualMessage: lines[index - 1],
|
|
868
|
+
rest: lines.slice(index, lastIndex)
|
|
869
|
+
};
|
|
752
870
|
};
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
return invoke$4('FileSystem.appendFile', uri, text);
|
|
871
|
+
const splitLines$1 = lines => {
|
|
872
|
+
return lines.split(NewLine$1);
|
|
756
873
|
};
|
|
757
|
-
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
copy,
|
|
762
|
-
createFile,
|
|
763
|
-
dispose: dispose$4,
|
|
764
|
-
exists: exists$1,
|
|
765
|
-
getFolderSize: getFolderSize$2,
|
|
766
|
-
getPathSeparator,
|
|
767
|
-
getRealPath,
|
|
768
|
-
invoke: invoke$4,
|
|
769
|
-
invokeAndTransfer: invokeAndTransfer$3,
|
|
770
|
-
mkdir,
|
|
771
|
-
readDirWithFileTypes,
|
|
772
|
-
readFile: readFile$3,
|
|
773
|
-
readFileAsBlob: readFileAsBlob$1,
|
|
774
|
-
remove: remove$1,
|
|
775
|
-
rename,
|
|
776
|
-
set: set$8,
|
|
777
|
-
stat,
|
|
778
|
-
writeFile
|
|
874
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
875
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
876
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
877
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
779
878
|
};
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
invoke: invoke$3,
|
|
783
|
-
invokeAndTransfer: invokeAndTransfer$2,
|
|
784
|
-
set: set$7,
|
|
785
|
-
dispose: dispose$3
|
|
786
|
-
} = create$7(MarkdownWorker$1);
|
|
787
|
-
const getVirtualDom$1 = async html => {
|
|
788
|
-
// @ts-ignore
|
|
789
|
-
return invoke$3('Markdown.getVirtualDom', html);
|
|
790
|
-
};
|
|
791
|
-
const render$1 = async (markdown, options) => {
|
|
792
|
-
// @ts-ignore
|
|
793
|
-
return invoke$3('Markdown.render', markdown, options);
|
|
794
|
-
};
|
|
795
|
-
|
|
796
|
-
const MarkdownWorker = {
|
|
797
|
-
__proto__: null,
|
|
798
|
-
dispose: dispose$3,
|
|
799
|
-
getVirtualDom: getVirtualDom$1,
|
|
800
|
-
invoke: invoke$3,
|
|
801
|
-
invokeAndTransfer: invokeAndTransfer$2,
|
|
802
|
-
render: render$1,
|
|
803
|
-
set: set$7
|
|
804
|
-
};
|
|
805
|
-
|
|
806
|
-
const {
|
|
807
|
-
invoke: invoke$2,
|
|
808
|
-
invokeAndTransfer: invokeAndTransfer$1,
|
|
809
|
-
set: set$6,
|
|
810
|
-
dispose: dispose$2
|
|
811
|
-
} = create$7(RendererWorker$1);
|
|
812
|
-
const searchFileHtml = async uri => {
|
|
813
|
-
return invoke$2('ExtensionHost.searchFileWithHtml', uri);
|
|
814
|
-
};
|
|
815
|
-
const getFilePathElectron = async file => {
|
|
816
|
-
return invoke$2('FileSystemHandle.getFilePathElectron', file);
|
|
817
|
-
};
|
|
818
|
-
const showContextMenu$1 = async (x, y, id, ...args) => {
|
|
819
|
-
return invoke$2('ContextMenu.show', x, y, id, ...args);
|
|
820
|
-
};
|
|
821
|
-
const getElectronVersion = async () => {
|
|
822
|
-
return invoke$2('Process.getElectronVersion');
|
|
823
|
-
};
|
|
824
|
-
const applyBulkReplacement = async bulkEdits => {
|
|
825
|
-
await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
|
|
879
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
880
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
826
881
|
};
|
|
827
|
-
const
|
|
828
|
-
|
|
829
|
-
|
|
882
|
+
const getMessageCodeBlock = stderr => {
|
|
883
|
+
const lines = splitLines$1(stderr);
|
|
884
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
885
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
886
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
887
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
888
|
+
return relevantMessage;
|
|
830
889
|
};
|
|
831
|
-
const
|
|
832
|
-
return
|
|
890
|
+
const isModuleNotFoundMessage = line => {
|
|
891
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
833
892
|
};
|
|
834
|
-
const
|
|
835
|
-
|
|
893
|
+
const getModuleNotFoundError = stderr => {
|
|
894
|
+
const lines = splitLines$1(stderr);
|
|
895
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
896
|
+
const message = lines[messageIndex];
|
|
897
|
+
return {
|
|
898
|
+
message,
|
|
899
|
+
code: ERR_MODULE_NOT_FOUND
|
|
900
|
+
};
|
|
836
901
|
};
|
|
837
|
-
const
|
|
838
|
-
|
|
902
|
+
const isModuleNotFoundError = stderr => {
|
|
903
|
+
if (!stderr) {
|
|
904
|
+
return false;
|
|
905
|
+
}
|
|
906
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
839
907
|
};
|
|
840
|
-
const
|
|
841
|
-
|
|
842
|
-
|
|
908
|
+
const isModulesSyntaxError = stderr => {
|
|
909
|
+
if (!stderr) {
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
843
913
|
};
|
|
844
|
-
const
|
|
845
|
-
|
|
914
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
915
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
916
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
917
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
846
918
|
};
|
|
847
|
-
const
|
|
848
|
-
|
|
919
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
920
|
+
const message = getMessageCodeBlock(stderr);
|
|
921
|
+
return {
|
|
922
|
+
message: `Incompatible native node module: ${message}`,
|
|
923
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
924
|
+
};
|
|
849
925
|
};
|
|
850
|
-
const
|
|
851
|
-
|
|
926
|
+
const getModuleSyntaxError = () => {
|
|
927
|
+
return {
|
|
928
|
+
message: `ES Modules are not supported in electron`,
|
|
929
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
930
|
+
};
|
|
852
931
|
};
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
932
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
933
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
934
|
+
return getNativeModuleErrorMessage(stderr);
|
|
935
|
+
}
|
|
936
|
+
if (isModulesSyntaxError(stderr)) {
|
|
937
|
+
return getModuleSyntaxError();
|
|
938
|
+
}
|
|
939
|
+
if (isModuleNotFoundError(stderr)) {
|
|
940
|
+
return getModuleNotFoundError(stderr);
|
|
941
|
+
}
|
|
942
|
+
const lines = splitLines$1(stderr);
|
|
943
|
+
const {
|
|
944
|
+
actualMessage,
|
|
945
|
+
rest
|
|
946
|
+
} = getDetails(lines);
|
|
947
|
+
return {
|
|
948
|
+
message: actualMessage,
|
|
949
|
+
code: '',
|
|
950
|
+
stack: rest
|
|
951
|
+
};
|
|
857
952
|
};
|
|
858
|
-
|
|
859
|
-
const command = 'Errors.handleMessagePort';
|
|
953
|
+
class IpcError extends VError {
|
|
860
954
|
// @ts-ignore
|
|
861
|
-
|
|
955
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
956
|
+
if (stdout || stderr) {
|
|
957
|
+
// @ts-ignore
|
|
958
|
+
const {
|
|
959
|
+
message,
|
|
960
|
+
code,
|
|
961
|
+
stack
|
|
962
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
963
|
+
const cause = new Error(message);
|
|
964
|
+
// @ts-ignore
|
|
965
|
+
cause.code = code;
|
|
966
|
+
cause.stack = stack;
|
|
967
|
+
super(cause, betterMessage);
|
|
968
|
+
} else {
|
|
969
|
+
super(betterMessage);
|
|
970
|
+
}
|
|
971
|
+
// @ts-ignore
|
|
972
|
+
this.name = 'IpcError';
|
|
973
|
+
// @ts-ignore
|
|
974
|
+
this.stdout = stdout;
|
|
975
|
+
// @ts-ignore
|
|
976
|
+
this.stderr = stderr;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
const readyMessage = 'ready';
|
|
980
|
+
const getData$2 = event => {
|
|
981
|
+
return event.data;
|
|
862
982
|
};
|
|
863
|
-
const
|
|
864
|
-
const command = 'Markdown.handleMessagePort';
|
|
983
|
+
const listen$7 = () => {
|
|
865
984
|
// @ts-ignore
|
|
866
|
-
|
|
985
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
986
|
+
throw new TypeError('module is not in web worker scope');
|
|
987
|
+
}
|
|
988
|
+
return globalThis;
|
|
867
989
|
};
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
// @ts-ignore
|
|
871
|
-
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
990
|
+
const signal$8 = global => {
|
|
991
|
+
global.postMessage(readyMessage);
|
|
872
992
|
};
|
|
873
|
-
|
|
874
|
-
|
|
993
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
994
|
+
getData(event) {
|
|
995
|
+
return getData$2(event);
|
|
996
|
+
}
|
|
997
|
+
send(message) {
|
|
998
|
+
// @ts-ignore
|
|
999
|
+
this._rawIpc.postMessage(message);
|
|
1000
|
+
}
|
|
1001
|
+
sendAndTransfer(message) {
|
|
1002
|
+
const transfer = getTransferrables(message);
|
|
1003
|
+
// @ts-ignore
|
|
1004
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1005
|
+
}
|
|
1006
|
+
dispose() {
|
|
1007
|
+
// ignore
|
|
1008
|
+
}
|
|
1009
|
+
onClose(callback) {
|
|
1010
|
+
// ignore
|
|
1011
|
+
}
|
|
1012
|
+
onMessage(callback) {
|
|
1013
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
const wrap$f = global => {
|
|
1017
|
+
return new IpcChildWithModuleWorker(global);
|
|
875
1018
|
};
|
|
876
|
-
const
|
|
1019
|
+
const waitForFirstMessage = async port => {
|
|
1020
|
+
const {
|
|
1021
|
+
resolve,
|
|
1022
|
+
promise
|
|
1023
|
+
} = Promise.withResolvers();
|
|
1024
|
+
port.addEventListener('message', resolve, {
|
|
1025
|
+
once: true
|
|
1026
|
+
});
|
|
1027
|
+
const event = await promise;
|
|
877
1028
|
// @ts-ignore
|
|
878
|
-
return
|
|
879
|
-
};
|
|
880
|
-
const setWebViewPort = async (uid, port, origin, portType) => {
|
|
881
|
-
return invokeAndTransfer$1('WebView.setPort', uid, port, origin, portType);
|
|
882
|
-
};
|
|
883
|
-
const setFocus = key => {
|
|
884
|
-
return invoke$2('Focus.setFocus', key);
|
|
1029
|
+
return event.data;
|
|
885
1030
|
};
|
|
886
|
-
const
|
|
887
|
-
|
|
1031
|
+
const listen$6 = async () => {
|
|
1032
|
+
const parentIpcRaw = listen$7();
|
|
1033
|
+
signal$8(parentIpcRaw);
|
|
1034
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
1035
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
1036
|
+
if (firstMessage.method !== 'initialize') {
|
|
1037
|
+
throw new IpcError('unexpected first message');
|
|
1038
|
+
}
|
|
1039
|
+
const type = firstMessage.params[0];
|
|
1040
|
+
if (type === 'message-port') {
|
|
1041
|
+
parentIpc.send({
|
|
1042
|
+
jsonrpc: '2.0',
|
|
1043
|
+
id: firstMessage.id,
|
|
1044
|
+
result: null
|
|
1045
|
+
});
|
|
1046
|
+
parentIpc.dispose();
|
|
1047
|
+
const port = firstMessage.params[1];
|
|
1048
|
+
return port;
|
|
1049
|
+
}
|
|
1050
|
+
return globalThis;
|
|
888
1051
|
};
|
|
889
|
-
|
|
890
|
-
|
|
1052
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
1053
|
+
getData(event) {
|
|
1054
|
+
return getData$2(event);
|
|
1055
|
+
}
|
|
1056
|
+
send(message) {
|
|
1057
|
+
this._rawIpc.postMessage(message);
|
|
1058
|
+
}
|
|
1059
|
+
sendAndTransfer(message) {
|
|
1060
|
+
const transfer = getTransferrables(message);
|
|
1061
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1062
|
+
}
|
|
1063
|
+
dispose() {
|
|
1064
|
+
if (this._rawIpc.close) {
|
|
1065
|
+
this._rawIpc.close();
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
onClose(callback) {
|
|
1069
|
+
// ignore
|
|
1070
|
+
}
|
|
1071
|
+
onMessage(callback) {
|
|
1072
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1073
|
+
this._rawIpc.start();
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
const wrap$e = port => {
|
|
1077
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
891
1078
|
};
|
|
892
|
-
const
|
|
893
|
-
|
|
1079
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
1080
|
+
__proto__: null,
|
|
1081
|
+
listen: listen$6,
|
|
1082
|
+
wrap: wrap$e
|
|
894
1083
|
};
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
|
|
1084
|
+
const addListener = (emitter, type, callback) => {
|
|
1085
|
+
if ('addEventListener' in emitter) {
|
|
1086
|
+
emitter.addEventListener(type, callback);
|
|
1087
|
+
} else {
|
|
1088
|
+
emitter.on(type, callback);
|
|
1089
|
+
}
|
|
898
1090
|
};
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
};
|
|
906
|
-
const closeWidget = async widgetId => {
|
|
907
|
-
return invoke$2('Viewlet.closeWidget', widgetId);
|
|
908
|
-
};
|
|
909
|
-
const sendMessagePortToExtensionHostWorker$2 = async (port, rpcId = 0) => {
|
|
910
|
-
const command = 'HandleMessagePort.handleMessagePort2';
|
|
911
|
-
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
912
|
-
};
|
|
913
|
-
const sendMessagePortToSearchProcess = async port => {
|
|
914
|
-
await invokeAndTransfer$1('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
|
|
915
|
-
};
|
|
916
|
-
const confirm = async (message, options) => {
|
|
917
|
-
// @ts-ignore
|
|
918
|
-
const result = await invoke$2('Confirmprompt.prompt', message, options);
|
|
919
|
-
return result;
|
|
920
|
-
};
|
|
921
|
-
const getRecentlyOpened = async () => {
|
|
922
|
-
return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
923
|
-
};
|
|
924
|
-
const getKeyBindings = async () => {
|
|
925
|
-
return invoke$2('KeyBindingsInitial.getKeyBindings');
|
|
926
|
-
};
|
|
927
|
-
const writeClipBoardText$1 = async text => {
|
|
928
|
-
await invoke$2('ClipBoard.writeText', /* text */text);
|
|
929
|
-
};
|
|
930
|
-
const writeClipBoardImage$1 = async blob => {
|
|
931
|
-
// @ts-ignore
|
|
932
|
-
await invoke$2('ClipBoard.writeImage', /* text */blob);
|
|
933
|
-
};
|
|
934
|
-
const searchFileMemory = async uri => {
|
|
935
|
-
// @ts-ignore
|
|
936
|
-
return invoke$2('ExtensionHost.searchFileWithMemory', uri);
|
|
937
|
-
};
|
|
938
|
-
const searchFileFetch = async uri => {
|
|
939
|
-
return invoke$2('ExtensionHost.searchFileWithFetch', uri);
|
|
940
|
-
};
|
|
941
|
-
const showMessageBox = async options => {
|
|
942
|
-
return invoke$2('ElectronDialog.showMessageBox', options);
|
|
943
|
-
};
|
|
944
|
-
const handleDebugResumed = async params => {
|
|
945
|
-
await invoke$2('Run And Debug.handleResumed', params);
|
|
946
|
-
};
|
|
947
|
-
const openWidget = async name => {
|
|
948
|
-
await invoke$2('Viewlet.openWidget', name);
|
|
949
|
-
};
|
|
950
|
-
const getIcons = async requests => {
|
|
951
|
-
const icons = await invoke$2('IconTheme.getIcons', requests);
|
|
952
|
-
return icons;
|
|
1091
|
+
const removeListener = (emitter, type, callback) => {
|
|
1092
|
+
if ('removeEventListener' in emitter) {
|
|
1093
|
+
emitter.removeEventListener(type, callback);
|
|
1094
|
+
} else {
|
|
1095
|
+
emitter.off(type, callback);
|
|
1096
|
+
}
|
|
953
1097
|
};
|
|
954
|
-
const
|
|
955
|
-
|
|
1098
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1099
|
+
const {
|
|
1100
|
+
resolve,
|
|
1101
|
+
promise
|
|
1102
|
+
} = Promise.withResolvers();
|
|
1103
|
+
const listenerMap = Object.create(null);
|
|
1104
|
+
const cleanup = value => {
|
|
1105
|
+
for (const event of Object.keys(eventMap)) {
|
|
1106
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
1107
|
+
}
|
|
1108
|
+
resolve(value);
|
|
1109
|
+
};
|
|
1110
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
1111
|
+
const listener = event => {
|
|
1112
|
+
cleanup({
|
|
1113
|
+
type,
|
|
1114
|
+
event
|
|
1115
|
+
});
|
|
1116
|
+
};
|
|
1117
|
+
addListener(eventEmitter, event, listener);
|
|
1118
|
+
listenerMap[event] = listener;
|
|
1119
|
+
}
|
|
1120
|
+
return promise;
|
|
956
1121
|
};
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
|
|
1122
|
+
const Message$1 = 3;
|
|
1123
|
+
const create$5$1 = async ({
|
|
1124
|
+
messagePort,
|
|
1125
|
+
isMessagePortOpen
|
|
1126
|
+
}) => {
|
|
1127
|
+
if (!isMessagePort(messagePort)) {
|
|
1128
|
+
throw new IpcError('port must be of type MessagePort');
|
|
1129
|
+
}
|
|
1130
|
+
if (isMessagePortOpen) {
|
|
1131
|
+
return messagePort;
|
|
1132
|
+
}
|
|
1133
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
1134
|
+
message: Message$1
|
|
1135
|
+
});
|
|
1136
|
+
messagePort.start();
|
|
1137
|
+
const {
|
|
1138
|
+
type,
|
|
1139
|
+
event
|
|
1140
|
+
} = await eventPromise;
|
|
1141
|
+
if (type !== Message$1) {
|
|
1142
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
1143
|
+
}
|
|
1144
|
+
if (event.data !== readyMessage) {
|
|
1145
|
+
throw new IpcError('unexpected first message');
|
|
1146
|
+
}
|
|
1147
|
+
return messagePort;
|
|
960
1148
|
};
|
|
961
|
-
const
|
|
962
|
-
|
|
963
|
-
return invoke$2('GetActiveEditor.getActiveEditorId');
|
|
1149
|
+
const signal$1 = messagePort => {
|
|
1150
|
+
messagePort.start();
|
|
964
1151
|
};
|
|
965
|
-
|
|
966
|
-
|
|
1152
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1153
|
+
getData = getData$2;
|
|
1154
|
+
send(message) {
|
|
1155
|
+
this._rawIpc.postMessage(message);
|
|
1156
|
+
}
|
|
1157
|
+
sendAndTransfer(message) {
|
|
1158
|
+
const transfer = getTransferrables(message);
|
|
1159
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1160
|
+
}
|
|
1161
|
+
dispose() {
|
|
1162
|
+
this._rawIpc.close();
|
|
1163
|
+
}
|
|
1164
|
+
onMessage(callback) {
|
|
1165
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1166
|
+
}
|
|
1167
|
+
onClose(callback) {}
|
|
1168
|
+
}
|
|
1169
|
+
const wrap$5 = messagePort => {
|
|
1170
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
967
1171
|
};
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1172
|
+
const IpcParentWithMessagePort$1 = {
|
|
1173
|
+
__proto__: null,
|
|
1174
|
+
create: create$5$1,
|
|
1175
|
+
signal: signal$1,
|
|
1176
|
+
wrap: wrap$5
|
|
972
1177
|
};
|
|
973
|
-
|
|
974
|
-
|
|
1178
|
+
|
|
1179
|
+
const Two = '2.0';
|
|
1180
|
+
const create$4 = (method, params) => {
|
|
1181
|
+
return {
|
|
1182
|
+
jsonrpc: Two,
|
|
1183
|
+
method,
|
|
1184
|
+
params
|
|
1185
|
+
};
|
|
975
1186
|
};
|
|
976
|
-
const
|
|
977
|
-
|
|
1187
|
+
const callbacks = Object.create(null);
|
|
1188
|
+
const set$a = (id, fn) => {
|
|
1189
|
+
callbacks[id] = fn;
|
|
978
1190
|
};
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
return invoke$2('Editor.rerender', key);
|
|
1191
|
+
const get$2 = id => {
|
|
1192
|
+
return callbacks[id];
|
|
982
1193
|
};
|
|
983
|
-
const
|
|
984
|
-
|
|
1194
|
+
const remove$1 = id => {
|
|
1195
|
+
delete callbacks[id];
|
|
985
1196
|
};
|
|
986
|
-
|
|
987
|
-
|
|
1197
|
+
let id = 0;
|
|
1198
|
+
const create$3$1 = () => {
|
|
1199
|
+
return ++id;
|
|
988
1200
|
};
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1201
|
+
const registerPromise = () => {
|
|
1202
|
+
const id = create$3$1();
|
|
1203
|
+
const {
|
|
1204
|
+
resolve,
|
|
1205
|
+
promise
|
|
1206
|
+
} = Promise.withResolvers();
|
|
1207
|
+
set$a(id, resolve);
|
|
1208
|
+
return {
|
|
1209
|
+
id,
|
|
1210
|
+
promise
|
|
1211
|
+
};
|
|
993
1212
|
};
|
|
994
|
-
const
|
|
995
|
-
|
|
1213
|
+
const create$2$1 = (method, params) => {
|
|
1214
|
+
const {
|
|
1215
|
+
id,
|
|
1216
|
+
promise
|
|
1217
|
+
} = registerPromise();
|
|
1218
|
+
const message = {
|
|
1219
|
+
jsonrpc: Two,
|
|
1220
|
+
method,
|
|
1221
|
+
params,
|
|
1222
|
+
id
|
|
1223
|
+
};
|
|
1224
|
+
return {
|
|
1225
|
+
message,
|
|
1226
|
+
promise
|
|
1227
|
+
};
|
|
996
1228
|
};
|
|
997
|
-
|
|
998
|
-
|
|
1229
|
+
class JsonRpcError extends Error {
|
|
1230
|
+
constructor(message) {
|
|
1231
|
+
super(message);
|
|
1232
|
+
this.name = 'JsonRpcError';
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
const NewLine = '\n';
|
|
1236
|
+
const DomException = 'DOMException';
|
|
1237
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
1238
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
1239
|
+
const TypeError$1 = 'TypeError';
|
|
1240
|
+
const getErrorConstructor = (message, type) => {
|
|
1241
|
+
if (type) {
|
|
1242
|
+
switch (type) {
|
|
1243
|
+
case DomException:
|
|
1244
|
+
return DOMException;
|
|
1245
|
+
case TypeError$1:
|
|
1246
|
+
return TypeError;
|
|
1247
|
+
case SyntaxError$1:
|
|
1248
|
+
return SyntaxError;
|
|
1249
|
+
case ReferenceError$1:
|
|
1250
|
+
return ReferenceError;
|
|
1251
|
+
default:
|
|
1252
|
+
return Error;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
if (message.startsWith('TypeError: ')) {
|
|
1256
|
+
return TypeError;
|
|
1257
|
+
}
|
|
1258
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
1259
|
+
return SyntaxError;
|
|
1260
|
+
}
|
|
1261
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
1262
|
+
return ReferenceError;
|
|
1263
|
+
}
|
|
1264
|
+
return Error;
|
|
999
1265
|
};
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1266
|
+
const constructError = (message, type, name) => {
|
|
1267
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
1268
|
+
if (ErrorConstructor === DOMException && name) {
|
|
1269
|
+
return new ErrorConstructor(message, name);
|
|
1270
|
+
}
|
|
1271
|
+
if (ErrorConstructor === Error) {
|
|
1272
|
+
const error = new Error(message);
|
|
1273
|
+
if (name && name !== 'VError') {
|
|
1274
|
+
error.name = name;
|
|
1275
|
+
}
|
|
1276
|
+
return error;
|
|
1277
|
+
}
|
|
1278
|
+
return new ErrorConstructor(message);
|
|
1003
1279
|
};
|
|
1004
|
-
const
|
|
1005
|
-
return
|
|
1280
|
+
const joinLines = lines => {
|
|
1281
|
+
return lines.join(NewLine);
|
|
1006
1282
|
};
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1009
|
-
await invoke$2('ErrorHandling.showErrorDialog', errorInfo);
|
|
1283
|
+
const splitLines = lines => {
|
|
1284
|
+
return lines.split(NewLine);
|
|
1010
1285
|
};
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1013
|
-
|
|
1286
|
+
const getCurrentStack = () => {
|
|
1287
|
+
const stackLinesToSkip = 3;
|
|
1288
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
1289
|
+
return currentStack;
|
|
1014
1290
|
};
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
return invoke$2('ExtensionManagement.getExtension', id);
|
|
1291
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1292
|
+
return string.indexOf(NewLine, startIndex);
|
|
1018
1293
|
};
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1021
|
-
|
|
1294
|
+
const getParentStack = error => {
|
|
1295
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
1296
|
+
if (parentStack.startsWith(' at')) {
|
|
1297
|
+
parentStack = error.message + NewLine + parentStack;
|
|
1298
|
+
}
|
|
1299
|
+
return parentStack;
|
|
1022
1300
|
};
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1036
|
-
|
|
1301
|
+
const MethodNotFound = -32601;
|
|
1302
|
+
const Custom = -32001;
|
|
1303
|
+
const restoreJsonRpcError = error => {
|
|
1304
|
+
const currentStack = getCurrentStack();
|
|
1305
|
+
if (error && error instanceof Error) {
|
|
1306
|
+
if (typeof error.stack === 'string') {
|
|
1307
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
1308
|
+
}
|
|
1309
|
+
return error;
|
|
1310
|
+
}
|
|
1311
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
1312
|
+
const restoredError = new JsonRpcError(error.message);
|
|
1313
|
+
const parentStack = getParentStack(error);
|
|
1314
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
1315
|
+
return restoredError;
|
|
1316
|
+
}
|
|
1317
|
+
if (error && error.message) {
|
|
1318
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
1319
|
+
if (error.data) {
|
|
1320
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
1321
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
1322
|
+
} else if (error.data.stack) {
|
|
1323
|
+
restoredError.stack = error.data.stack;
|
|
1324
|
+
}
|
|
1325
|
+
if (error.data.codeFrame) {
|
|
1326
|
+
// @ts-ignore
|
|
1327
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
1328
|
+
}
|
|
1329
|
+
if (error.data.code) {
|
|
1330
|
+
// @ts-ignore
|
|
1331
|
+
restoredError.code = error.data.code;
|
|
1332
|
+
}
|
|
1333
|
+
if (error.data.type) {
|
|
1334
|
+
// @ts-ignore
|
|
1335
|
+
restoredError.name = error.data.type;
|
|
1336
|
+
}
|
|
1337
|
+
} else {
|
|
1338
|
+
if (error.stack) {
|
|
1339
|
+
const lowerStack = restoredError.stack || '';
|
|
1340
|
+
// @ts-ignore
|
|
1341
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1342
|
+
const parentStack = getParentStack(error);
|
|
1343
|
+
// @ts-ignore
|
|
1344
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
1345
|
+
}
|
|
1346
|
+
if (error.codeFrame) {
|
|
1347
|
+
// @ts-ignore
|
|
1348
|
+
restoredError.codeFrame = error.codeFrame;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
return restoredError;
|
|
1352
|
+
}
|
|
1353
|
+
if (typeof error === 'string') {
|
|
1354
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
1355
|
+
}
|
|
1356
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
1037
1357
|
};
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
|
|
1358
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
1359
|
+
if ('error' in responseMessage) {
|
|
1360
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
1361
|
+
throw restoredError;
|
|
1362
|
+
}
|
|
1363
|
+
if ('result' in responseMessage) {
|
|
1364
|
+
return responseMessage.result;
|
|
1365
|
+
}
|
|
1366
|
+
throw new JsonRpcError('unexpected response message');
|
|
1041
1367
|
};
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1044
|
-
return invoke$2('Extensions.handleInput', searchValue);
|
|
1368
|
+
const warn = (...args) => {
|
|
1369
|
+
console.warn(...args);
|
|
1045
1370
|
};
|
|
1046
|
-
const
|
|
1047
|
-
|
|
1048
|
-
|
|
1371
|
+
const resolve = (id, response) => {
|
|
1372
|
+
const fn = get$2(id);
|
|
1373
|
+
if (!fn) {
|
|
1374
|
+
console.log(response);
|
|
1375
|
+
warn(`callback ${id} may already be disposed`);
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
fn(response);
|
|
1379
|
+
remove$1(id);
|
|
1049
1380
|
};
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1052
|
-
|
|
1381
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1382
|
+
const getErrorType = prettyError => {
|
|
1383
|
+
if (prettyError && prettyError.type) {
|
|
1384
|
+
return prettyError.type;
|
|
1385
|
+
}
|
|
1386
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
1387
|
+
return prettyError.constructor.name;
|
|
1388
|
+
}
|
|
1389
|
+
return undefined;
|
|
1053
1390
|
};
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1056
|
-
return invoke$2('Preferences.getAll');
|
|
1391
|
+
const isAlreadyStack = line => {
|
|
1392
|
+
return line.trim().startsWith('at ');
|
|
1057
1393
|
};
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1060
|
-
|
|
1394
|
+
const getStack = prettyError => {
|
|
1395
|
+
const stackString = prettyError.stack || '';
|
|
1396
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
1397
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
1398
|
+
return stackString.slice(newLineIndex + 1);
|
|
1399
|
+
}
|
|
1400
|
+
return stackString;
|
|
1061
1401
|
};
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
|
|
1402
|
+
const getErrorProperty = (error, prettyError) => {
|
|
1403
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
1404
|
+
return {
|
|
1405
|
+
code: MethodNotFound,
|
|
1406
|
+
message: error.message,
|
|
1407
|
+
data: error.stack
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
return {
|
|
1411
|
+
code: Custom,
|
|
1412
|
+
message: prettyError.message,
|
|
1413
|
+
data: {
|
|
1414
|
+
stack: getStack(prettyError),
|
|
1415
|
+
codeFrame: prettyError.codeFrame,
|
|
1416
|
+
type: getErrorType(prettyError),
|
|
1417
|
+
code: prettyError.code,
|
|
1418
|
+
name: prettyError.name
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1065
1421
|
};
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
confirm,
|
|
1073
|
-
disableExtension: disableExtension$2,
|
|
1074
|
-
dispose: dispose$2,
|
|
1075
|
-
enableExtension,
|
|
1076
|
-
getActiveEditorId,
|
|
1077
|
-
getAllExtensions: getAllExtensions$2,
|
|
1078
|
-
getAllPreferences,
|
|
1079
|
-
getBlob,
|
|
1080
|
-
getChromeVersion,
|
|
1081
|
-
getColorThemeNames,
|
|
1082
|
-
getElectronVersion,
|
|
1083
|
-
getExtension: getExtension$3,
|
|
1084
|
-
getExtensionCommands,
|
|
1085
|
-
getFileHandles,
|
|
1086
|
-
getFileIcon,
|
|
1087
|
-
getFilePathElectron,
|
|
1088
|
-
getFolderIcon,
|
|
1089
|
-
getFolderSize: getFolderSize$1,
|
|
1090
|
-
getIcons,
|
|
1091
|
-
getKeyBindings,
|
|
1092
|
-
getLogsDir,
|
|
1093
|
-
getMarkdownDom,
|
|
1094
|
-
getNodeVersion,
|
|
1095
|
-
getPreference,
|
|
1096
|
-
getRecentlyOpened,
|
|
1097
|
-
getV8Version,
|
|
1098
|
-
getWebViewSecret,
|
|
1099
|
-
getWindowId,
|
|
1100
|
-
getWorkspacePath,
|
|
1101
|
-
handleDebugChange,
|
|
1102
|
-
handleDebugPaused,
|
|
1103
|
-
handleDebugResumed,
|
|
1104
|
-
handleDebugScriptParsed,
|
|
1105
|
-
installExtension,
|
|
1106
|
-
invoke: invoke$2,
|
|
1107
|
-
invokeAndTransfer: invokeAndTransfer$1,
|
|
1108
|
-
openExtensionSearch: openExtensionSearch$2,
|
|
1109
|
-
openExternal,
|
|
1110
|
-
openNativeFolder: openNativeFolder$1,
|
|
1111
|
-
openUri,
|
|
1112
|
-
openUrl: openUrl$2,
|
|
1113
|
-
openWidget,
|
|
1114
|
-
readFile: readFile$2,
|
|
1115
|
-
registerWebViewInterceptor,
|
|
1116
|
-
renderMarkdown: renderMarkdown$1,
|
|
1117
|
-
rerenderEditor,
|
|
1118
|
-
searchFileFetch,
|
|
1119
|
-
searchFileHtml,
|
|
1120
|
-
searchFileMemory,
|
|
1121
|
-
sendMessagePortToEditorWorker,
|
|
1122
|
-
sendMessagePortToErrorWorker,
|
|
1123
|
-
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$2,
|
|
1124
|
-
sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
|
|
1125
|
-
sendMessagePortToMarkdownWorker: sendMessagePortToMarkdownWorker$2,
|
|
1126
|
-
sendMessagePortToRendererProcess,
|
|
1127
|
-
sendMessagePortToSearchProcess,
|
|
1128
|
-
sendMessagePortToSyntaxHighlightingWorker,
|
|
1129
|
-
set: set$6,
|
|
1130
|
-
setAdditionalFocus,
|
|
1131
|
-
setColorTheme: setColorTheme$2,
|
|
1132
|
-
setExtensionsSearchValue: setExtensionsSearchValue$1,
|
|
1133
|
-
setFocus,
|
|
1134
|
-
setWebViewPort,
|
|
1135
|
-
setWorkspacePath,
|
|
1136
|
-
showContextMenu: showContextMenu$1,
|
|
1137
|
-
showErrorDialog,
|
|
1138
|
-
showMessageBox,
|
|
1139
|
-
showSaveFilePicker,
|
|
1140
|
-
uninstallExtension: uninstallExtension$1,
|
|
1141
|
-
unregisterWebViewInterceptor,
|
|
1142
|
-
writeClipBoardImage: writeClipBoardImage$1,
|
|
1143
|
-
writeClipBoardText: writeClipBoardText$1
|
|
1422
|
+
const create$1$1 = (id, error) => {
|
|
1423
|
+
return {
|
|
1424
|
+
jsonrpc: Two,
|
|
1425
|
+
id,
|
|
1426
|
+
error
|
|
1427
|
+
};
|
|
1144
1428
|
};
|
|
1145
|
-
|
|
1146
|
-
const
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
const getRuntimeStatus = async extensionId => {
|
|
1152
|
-
// @ts-ignore
|
|
1153
|
-
const status = await getRuntimeStatus$1(extensionId);
|
|
1154
|
-
// @ts-ignore
|
|
1155
|
-
return status;
|
|
1429
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
1430
|
+
const prettyError = preparePrettyError(error);
|
|
1431
|
+
logError(error, prettyError);
|
|
1432
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
1433
|
+
return create$1$1(id, errorProperty);
|
|
1156
1434
|
};
|
|
1157
|
-
|
|
1158
|
-
const getRuntimeStatusDetails = async extension => {
|
|
1159
|
-
const {
|
|
1160
|
-
activationEvent,
|
|
1161
|
-
status,
|
|
1162
|
-
activationTime,
|
|
1163
|
-
importTime
|
|
1164
|
-
} = await getRuntimeStatus(extension.id);
|
|
1435
|
+
const create$6 = (message, result) => {
|
|
1165
1436
|
return {
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
importTime
|
|
1437
|
+
jsonrpc: Two,
|
|
1438
|
+
id: message.id,
|
|
1439
|
+
result: result ?? null
|
|
1170
1440
|
};
|
|
1171
1441
|
};
|
|
1172
|
-
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1442
|
+
const getSuccessResponse = (message, result) => {
|
|
1443
|
+
const resultProperty = result ?? null;
|
|
1444
|
+
return create$6(message, resultProperty);
|
|
1445
|
+
};
|
|
1446
|
+
const getErrorResponseSimple = (id, error) => {
|
|
1447
|
+
return {
|
|
1448
|
+
jsonrpc: Two,
|
|
1449
|
+
id,
|
|
1450
|
+
error: {
|
|
1451
|
+
code: Custom,
|
|
1452
|
+
// @ts-ignore
|
|
1453
|
+
message: error.message,
|
|
1454
|
+
data: error
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
};
|
|
1458
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1459
|
+
try {
|
|
1460
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
1461
|
+
return getSuccessResponse(message, result);
|
|
1462
|
+
} catch (error) {
|
|
1463
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
1464
|
+
return getErrorResponseSimple(message.id, error);
|
|
1465
|
+
}
|
|
1466
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1179
1467
|
}
|
|
1468
|
+
};
|
|
1469
|
+
const defaultPreparePrettyError = error => {
|
|
1470
|
+
return error;
|
|
1471
|
+
};
|
|
1472
|
+
const defaultLogError = () => {
|
|
1473
|
+
// ignore
|
|
1474
|
+
};
|
|
1475
|
+
const defaultRequiresSocket = () => {
|
|
1180
1476
|
return false;
|
|
1181
1477
|
};
|
|
1478
|
+
const defaultResolve = resolve;
|
|
1182
1479
|
|
|
1183
|
-
|
|
1184
|
-
|
|
1480
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
1481
|
+
const normalizeParams = args => {
|
|
1482
|
+
if (args.length === 1) {
|
|
1483
|
+
const options = args[0];
|
|
1484
|
+
return {
|
|
1485
|
+
ipc: options.ipc,
|
|
1486
|
+
message: options.message,
|
|
1487
|
+
execute: options.execute,
|
|
1488
|
+
resolve: options.resolve || defaultResolve,
|
|
1489
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
1490
|
+
logError: options.logError || defaultLogError,
|
|
1491
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
return {
|
|
1495
|
+
ipc: args[0],
|
|
1496
|
+
message: args[1],
|
|
1497
|
+
execute: args[2],
|
|
1498
|
+
resolve: args[3],
|
|
1499
|
+
preparePrettyError: args[4],
|
|
1500
|
+
logError: args[5],
|
|
1501
|
+
requiresSocket: args[6]
|
|
1502
|
+
};
|
|
1185
1503
|
};
|
|
1186
|
-
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
|
|
1504
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
1505
|
+
const options = normalizeParams(args);
|
|
1506
|
+
const {
|
|
1507
|
+
message,
|
|
1508
|
+
ipc,
|
|
1509
|
+
execute,
|
|
1510
|
+
resolve,
|
|
1511
|
+
preparePrettyError,
|
|
1512
|
+
logError,
|
|
1513
|
+
requiresSocket
|
|
1514
|
+
} = options;
|
|
1515
|
+
if ('id' in message) {
|
|
1516
|
+
if ('method' in message) {
|
|
1517
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1518
|
+
try {
|
|
1519
|
+
ipc.send(response);
|
|
1520
|
+
} catch (error) {
|
|
1521
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1522
|
+
ipc.send(errorResponse);
|
|
1523
|
+
}
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
resolve(message.id, message);
|
|
1527
|
+
return;
|
|
1190
1528
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
}, text(importTime()), {
|
|
1197
|
-
type: Dd,
|
|
1198
|
-
childCount: 1
|
|
1199
|
-
}, text(formattedImportTime), {
|
|
1200
|
-
type: Dt,
|
|
1201
|
-
childCount: 1
|
|
1202
|
-
}, text(activationTime()), {
|
|
1203
|
-
type: Dd,
|
|
1204
|
-
childCount: 1
|
|
1205
|
-
}, text(formattedTime)];
|
|
1529
|
+
if ('method' in message) {
|
|
1530
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
throw new JsonRpcError('unexpected message');
|
|
1206
1534
|
};
|
|
1207
|
-
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
case Activated:
|
|
1217
|
-
return 'activated';
|
|
1218
|
-
case None$1:
|
|
1219
|
-
return 'none';
|
|
1220
|
-
case Activating:
|
|
1221
|
-
return 'Activating';
|
|
1222
|
-
case Error$1:
|
|
1223
|
-
return 'error';
|
|
1224
|
-
case Importing:
|
|
1225
|
-
return 'importing';
|
|
1226
|
-
default:
|
|
1227
|
-
return 'unknown';
|
|
1535
|
+
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
1536
|
+
const {
|
|
1537
|
+
message,
|
|
1538
|
+
promise
|
|
1539
|
+
} = create$2$1(method, params);
|
|
1540
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1541
|
+
ipc.sendAndTransfer(message);
|
|
1542
|
+
} else {
|
|
1543
|
+
ipc.send(message);
|
|
1228
1544
|
}
|
|
1545
|
+
const responseMessage = await promise;
|
|
1546
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
1229
1547
|
};
|
|
1230
|
-
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1233
|
-
childCount: 1,
|
|
1234
|
-
className: 'RuntimeStatusDefinitionListKey'
|
|
1548
|
+
const send = (transport, method, ...params) => {
|
|
1549
|
+
const message = create$4(method, params);
|
|
1550
|
+
transport.send(message);
|
|
1235
1551
|
};
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1238
|
-
className: 'RuntimeStatusDefinitionListValue',
|
|
1239
|
-
childCount: 1
|
|
1552
|
+
const invoke$5 = (ipc, method, ...params) => {
|
|
1553
|
+
return invokeHelper(ipc, method, params, false);
|
|
1240
1554
|
};
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1243
|
-
return [key, text(`Status: `),
|
|
1244
|
-
// i18n
|
|
1245
|
-
value, text(`${statusString}`)];
|
|
1555
|
+
const invokeAndTransfer$4 = (ipc, method, ...params) => {
|
|
1556
|
+
return invokeHelper(ipc, method, params, true);
|
|
1246
1557
|
};
|
|
1247
1558
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
childCount += 4;
|
|
1559
|
+
class CommandNotFoundError extends Error {
|
|
1560
|
+
constructor(command) {
|
|
1561
|
+
super(`Command not found ${command}`);
|
|
1562
|
+
this.name = 'CommandNotFoundError';
|
|
1253
1563
|
}
|
|
1254
|
-
|
|
1564
|
+
}
|
|
1565
|
+
const commands = Object.create(null);
|
|
1566
|
+
const register = commandMap => {
|
|
1567
|
+
Object.assign(commands, commandMap);
|
|
1255
1568
|
};
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1258
|
-
status,
|
|
1259
|
-
activationTime,
|
|
1260
|
-
importTime
|
|
1261
|
-
} = state;
|
|
1262
|
-
const heading = runtimeStatus();
|
|
1263
|
-
const childCount = getChildCount$1(status, activationTime, importTime);
|
|
1264
|
-
return [{
|
|
1265
|
-
type: Div,
|
|
1266
|
-
className: FeatureContent,
|
|
1267
|
-
childCount: 2
|
|
1268
|
-
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
1269
|
-
type: Dl,
|
|
1270
|
-
className: 'RuntimeStatusDefinitionList',
|
|
1271
|
-
childCount
|
|
1272
|
-
}, ...getStatusVirtualDom(status), ...getActivationTimeVirtualDom(activationTime, importTime)];
|
|
1569
|
+
const getCommand = key => {
|
|
1570
|
+
return commands[key];
|
|
1273
1571
|
};
|
|
1274
|
-
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
// TODO watch out for null/undefined/number/string/array
|
|
1281
|
-
return [{
|
|
1282
|
-
type: Text,
|
|
1283
|
-
value: id
|
|
1284
|
-
}, {
|
|
1285
|
-
type: Text,
|
|
1286
|
-
value: label
|
|
1287
|
-
}];
|
|
1572
|
+
const execute = (command, ...args) => {
|
|
1573
|
+
const fn = getCommand(command);
|
|
1574
|
+
if (!fn) {
|
|
1575
|
+
throw new CommandNotFoundError(command);
|
|
1576
|
+
}
|
|
1577
|
+
return fn(...args);
|
|
1288
1578
|
};
|
|
1289
1579
|
|
|
1290
|
-
const
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1580
|
+
const createRpc = ipc => {
|
|
1581
|
+
const rpc = {
|
|
1582
|
+
// @ts-ignore
|
|
1583
|
+
ipc,
|
|
1584
|
+
/**
|
|
1585
|
+
* @deprecated
|
|
1586
|
+
*/
|
|
1587
|
+
send(method, ...params) {
|
|
1588
|
+
send(ipc, method, ...params);
|
|
1589
|
+
},
|
|
1590
|
+
invoke(method, ...params) {
|
|
1591
|
+
return invoke$5(ipc, method, ...params);
|
|
1592
|
+
},
|
|
1593
|
+
invokeAndTransfer(method, ...params) {
|
|
1594
|
+
return invokeAndTransfer$4(ipc, method, ...params);
|
|
1595
|
+
},
|
|
1596
|
+
async dispose() {
|
|
1597
|
+
await ipc?.dispose();
|
|
1598
|
+
}
|
|
1295
1599
|
};
|
|
1600
|
+
return rpc;
|
|
1296
1601
|
};
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
if (!extension || typeof extension !== 'object' || !('settings' in extension)) {
|
|
1300
|
-
return false;
|
|
1301
|
-
}
|
|
1302
|
-
return Array.isArray(extension.settings);
|
|
1602
|
+
const requiresSocket = () => {
|
|
1603
|
+
return false;
|
|
1303
1604
|
};
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
const textId = id$1();
|
|
1307
|
-
const textLabel = label();
|
|
1308
|
-
return {
|
|
1309
|
-
headings: [textId, textLabel],
|
|
1310
|
-
rows
|
|
1311
|
-
};
|
|
1605
|
+
const preparePrettyError = error => {
|
|
1606
|
+
return error;
|
|
1312
1607
|
};
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
const heading = settings();
|
|
1316
|
-
const tableInfo = getSettingsTableEntries(rows);
|
|
1317
|
-
return [{
|
|
1318
|
-
type: Div,
|
|
1319
|
-
className: FeatureContent,
|
|
1320
|
-
childCount: 2
|
|
1321
|
-
}, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
|
|
1608
|
+
const logError = () => {
|
|
1609
|
+
// handled by renderer worker
|
|
1322
1610
|
};
|
|
1323
|
-
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1611
|
+
const handleMessage = event => {
|
|
1612
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1613
|
+
const actualExecute = event?.target?.execute || execute;
|
|
1614
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1326
1615
|
};
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
}
|
|
1334
|
-
const Object$1 = 1;
|
|
1335
|
-
const Number$1 = 2;
|
|
1336
|
-
const Array$1 = 3;
|
|
1337
|
-
const String = 4;
|
|
1338
|
-
const Boolean$1 = 5;
|
|
1339
|
-
const Function = 6;
|
|
1340
|
-
const Null = 7;
|
|
1341
|
-
const Unknown = 8;
|
|
1342
|
-
const getType = value => {
|
|
1343
|
-
switch (typeof value) {
|
|
1344
|
-
case 'number':
|
|
1345
|
-
return Number$1;
|
|
1346
|
-
case 'function':
|
|
1347
|
-
return Function;
|
|
1348
|
-
case 'string':
|
|
1349
|
-
return String;
|
|
1350
|
-
case 'object':
|
|
1351
|
-
if (value === null) {
|
|
1352
|
-
return Null;
|
|
1353
|
-
}
|
|
1354
|
-
if (Array.isArray(value)) {
|
|
1355
|
-
return Array$1;
|
|
1356
|
-
}
|
|
1357
|
-
return Object$1;
|
|
1358
|
-
case 'boolean':
|
|
1359
|
-
return Boolean$1;
|
|
1360
|
-
default:
|
|
1361
|
-
return Unknown;
|
|
1616
|
+
const handleIpc = ipc => {
|
|
1617
|
+
if ('addEventListener' in ipc) {
|
|
1618
|
+
ipc.addEventListener('message', handleMessage);
|
|
1619
|
+
} else if ('on' in ipc) {
|
|
1620
|
+
// deprecated
|
|
1621
|
+
ipc.on('message', handleMessage);
|
|
1362
1622
|
}
|
|
1363
1623
|
};
|
|
1364
|
-
const
|
|
1365
|
-
const
|
|
1366
|
-
if (
|
|
1367
|
-
|
|
1624
|
+
const listen$1 = async (module, options) => {
|
|
1625
|
+
const rawIpc = await module.listen(options);
|
|
1626
|
+
if (module.signal) {
|
|
1627
|
+
module.signal(rawIpc);
|
|
1368
1628
|
}
|
|
1629
|
+
const ipc = module.wrap(rawIpc);
|
|
1630
|
+
return ipc;
|
|
1369
1631
|
};
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
const ActivationEvents = 'ActivationEvents';
|
|
1387
|
-
const Changelog = 'Changelog';
|
|
1388
|
-
const Commands = 'Commands';
|
|
1389
|
-
const Details = 'Details';
|
|
1390
|
-
const Enable = 'Enable';
|
|
1391
|
-
const Disable = 'Disable';
|
|
1392
|
-
const Features = 'Features';
|
|
1393
|
-
const JsonValidation = 'JsonValidation';
|
|
1394
|
-
const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
1395
|
-
const RuntimeStatus = 'RuntimeStatus';
|
|
1396
|
-
const ScrollToTop = 'scrolltotop';
|
|
1397
|
-
const SetColorTheme = 'SetColorTheme';
|
|
1398
|
-
const Settings = 'Settings';
|
|
1399
|
-
const Theme = 'Theme';
|
|
1400
|
-
const Uninstall = 'Uninstall';
|
|
1401
|
-
const WebViews = 'WebViews';
|
|
1402
|
-
|
|
1403
|
-
const getScrollToTopVirtualDom = scrollToTopButtonEnabled => {
|
|
1404
|
-
return [{
|
|
1405
|
-
type: Button$1,
|
|
1406
|
-
className: ScrollToTopButton,
|
|
1407
|
-
childCount: 1,
|
|
1408
|
-
onClick: HandleClickScrollToTop,
|
|
1409
|
-
ariaLabel: scrollToTop(),
|
|
1410
|
-
name: ScrollToTop
|
|
1411
|
-
}, {
|
|
1412
|
-
type: Div,
|
|
1413
|
-
className: 'MaskIcon MaskIconChevronUp',
|
|
1414
|
-
childCount: 0,
|
|
1415
|
-
role: None$2
|
|
1416
|
-
}];
|
|
1632
|
+
const create$5 = async ({
|
|
1633
|
+
commandMap,
|
|
1634
|
+
messagePort
|
|
1635
|
+
}) => {
|
|
1636
|
+
// TODO create a commandMap per rpc instance
|
|
1637
|
+
register(commandMap);
|
|
1638
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1639
|
+
messagePort,
|
|
1640
|
+
isMessagePortOpen: true
|
|
1641
|
+
});
|
|
1642
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1643
|
+
handleIpc(ipc);
|
|
1644
|
+
const rpc = createRpc(ipc);
|
|
1645
|
+
messagePort.start();
|
|
1646
|
+
return rpc;
|
|
1417
1647
|
};
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
newDom[0].childCount++;
|
|
1432
|
-
const extraDom = getScrollToTopVirtualDom();
|
|
1433
|
-
newDom.splice(1, 0, ...extraDom);
|
|
1434
|
-
}
|
|
1435
|
-
return newDom;
|
|
1648
|
+
const create$3 = async ({
|
|
1649
|
+
commandMap,
|
|
1650
|
+
send
|
|
1651
|
+
}) => {
|
|
1652
|
+
const {
|
|
1653
|
+
port1,
|
|
1654
|
+
port2
|
|
1655
|
+
} = new MessageChannel();
|
|
1656
|
+
await send(port1);
|
|
1657
|
+
return create$5({
|
|
1658
|
+
commandMap,
|
|
1659
|
+
messagePort: port2
|
|
1660
|
+
});
|
|
1436
1661
|
};
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1662
|
+
const TransferMessagePortRpcParent = {
|
|
1663
|
+
__proto__: null,
|
|
1664
|
+
create: create$3
|
|
1665
|
+
};
|
|
1666
|
+
const create$2 = async ({
|
|
1667
|
+
commandMap
|
|
1668
|
+
}) => {
|
|
1669
|
+
// TODO create a commandMap per rpc instance
|
|
1670
|
+
register(commandMap);
|
|
1671
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1672
|
+
handleIpc(ipc);
|
|
1673
|
+
const rpc = createRpc(ipc);
|
|
1674
|
+
return rpc;
|
|
1675
|
+
};
|
|
1676
|
+
const WebWorkerRpcClient = {
|
|
1677
|
+
__proto__: null,
|
|
1678
|
+
create: create$2
|
|
1679
|
+
};
|
|
1680
|
+
const createMockRpc = ({
|
|
1681
|
+
commandMap
|
|
1682
|
+
}) => {
|
|
1683
|
+
const invocations = [];
|
|
1684
|
+
const invoke = (method, ...params) => {
|
|
1685
|
+
invocations.push([method, ...params]);
|
|
1686
|
+
const command = commandMap[method];
|
|
1687
|
+
if (!command) {
|
|
1688
|
+
throw new Error(`command ${method} not found`);
|
|
1446
1689
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1690
|
+
return command(...params);
|
|
1691
|
+
};
|
|
1692
|
+
const mockRpc = {
|
|
1693
|
+
invoke,
|
|
1694
|
+
invokeAndTransfer: invoke,
|
|
1695
|
+
invocations
|
|
1696
|
+
};
|
|
1697
|
+
return mockRpc;
|
|
1449
1698
|
};
|
|
1450
1699
|
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1453
|
-
|
|
1700
|
+
const {
|
|
1701
|
+
invoke: invoke$4,
|
|
1702
|
+
invokeAndTransfer: invokeAndTransfer$3,
|
|
1703
|
+
set: set$9,
|
|
1704
|
+
dispose: dispose$5
|
|
1705
|
+
} = create$7(ExtensionHostWorker);
|
|
1706
|
+
const executeReferenceProvider = async (id, offset) => {
|
|
1707
|
+
// @ts-ignore
|
|
1708
|
+
return invoke$4('ExtensionHostReference.executeReferenceProvider', id, offset);
|
|
1454
1709
|
};
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1457
|
-
return
|
|
1710
|
+
const executeFileReferenceProvider = async id => {
|
|
1711
|
+
// @ts-ignore
|
|
1712
|
+
return invoke$4('ExtensionHostReference.executeFileReferenceProvider', id);
|
|
1458
1713
|
};
|
|
1459
|
-
const
|
|
1460
|
-
|
|
1461
|
-
return
|
|
1714
|
+
const getRuntimeStatus$2 = async extensionId => {
|
|
1715
|
+
// @ts-ignore
|
|
1716
|
+
return invoke$4('ExtensionHost.getRuntimeStatus', extensionId);
|
|
1462
1717
|
};
|
|
1463
|
-
const
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
return
|
|
1718
|
+
const registerMockRpc$1 = commandMap => {
|
|
1719
|
+
const mockRpc = createMockRpc({
|
|
1720
|
+
commandMap
|
|
1721
|
+
});
|
|
1722
|
+
set$9(mockRpc);
|
|
1723
|
+
return mockRpc;
|
|
1469
1724
|
};
|
|
1470
1725
|
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1473
|
-
|
|
1726
|
+
const ExtensionHost = {
|
|
1727
|
+
__proto__: null,
|
|
1728
|
+
dispose: dispose$5,
|
|
1729
|
+
executeFileReferenceProvider,
|
|
1730
|
+
executeReferenceProvider,
|
|
1731
|
+
getRuntimeStatus: getRuntimeStatus$2,
|
|
1732
|
+
invoke: invoke$4,
|
|
1733
|
+
invokeAndTransfer: invokeAndTransfer$3,
|
|
1734
|
+
registerMockRpc: registerMockRpc$1,
|
|
1735
|
+
set: set$9
|
|
1474
1736
|
};
|
|
1475
1737
|
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
baseUrl
|
|
1485
|
-
});
|
|
1486
|
-
const themesMarkdownDom = await getMarkdownVirtualDom(rendered);
|
|
1487
|
-
return {
|
|
1488
|
-
themesMarkdownDom
|
|
1489
|
-
};
|
|
1738
|
+
const {
|
|
1739
|
+
invoke: invoke$3,
|
|
1740
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
1741
|
+
set: set$8,
|
|
1742
|
+
dispose: dispose$4
|
|
1743
|
+
} = create$7(FileSystemWorker$1);
|
|
1744
|
+
const remove = async dirent => {
|
|
1745
|
+
return invoke$3('FileSystem.remove', dirent);
|
|
1490
1746
|
};
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
if (!extension || typeof extension !== 'object' || !('colorThemes' in extension)) {
|
|
1494
|
-
return false;
|
|
1495
|
-
}
|
|
1496
|
-
return Array.isArray(extension.colorThemes);
|
|
1747
|
+
const readDirWithFileTypes = async uri => {
|
|
1748
|
+
return invoke$3('FileSystem.readDirWithFileTypes', uri);
|
|
1497
1749
|
};
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
return false;
|
|
1502
|
-
}
|
|
1503
|
-
return Array.isArray(extension.iconThemes);
|
|
1504
|
-
};
|
|
1505
|
-
|
|
1506
|
-
const featureProductIconThemeEnabled = extension => {
|
|
1507
|
-
if (!extension || typeof extension !== 'object' || !('productIconThemes' in extension)) {
|
|
1508
|
-
return false;
|
|
1509
|
-
}
|
|
1510
|
-
return Array.isArray(extension.productIconThemes);
|
|
1750
|
+
const getPathSeparator = async root => {
|
|
1751
|
+
// @ts-ignore
|
|
1752
|
+
return invoke$3('FileSystem.getPathSeparator', root);
|
|
1511
1753
|
};
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
return featureColorThemeEnabled(extension) || featureIconThemeEnabled(extension) || featureProductIconThemeEnabled(extension);
|
|
1754
|
+
const getRealPath = async path => {
|
|
1755
|
+
return invoke$3('FileSystem.getRealPath', path);
|
|
1515
1756
|
};
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
const max = dom.length - 1;
|
|
1519
|
-
let stack = [];
|
|
1520
|
-
for (let i = max; i >= 0; i--) {
|
|
1521
|
-
const element = dom[i];
|
|
1522
|
-
if (element.childCount > 0) {
|
|
1523
|
-
stack = stack.slice(element.childCount);
|
|
1524
|
-
}
|
|
1525
|
-
stack.unshift(element);
|
|
1526
|
-
}
|
|
1527
|
-
return stack.length;
|
|
1757
|
+
const stat = async dirent => {
|
|
1758
|
+
return invoke$3('FileSystem.stat', dirent);
|
|
1528
1759
|
};
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
const childCount = getVirtualDomChildCount(themesDom);
|
|
1532
|
-
const heading = theme();
|
|
1533
|
-
return [{
|
|
1534
|
-
type: Div,
|
|
1535
|
-
className: FeatureContent,
|
|
1536
|
-
childCount: 2
|
|
1537
|
-
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
1538
|
-
type: Div,
|
|
1539
|
-
className: DefaultMarkdown,
|
|
1540
|
-
childCount
|
|
1541
|
-
}, ...themesDom];
|
|
1760
|
+
const createFile = async uri => {
|
|
1761
|
+
return invoke$3('FileSystem.writeFile', uri, '');
|
|
1542
1762
|
};
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
return getFeatureThemesVirtualDom(state.themesMarkdownDom);
|
|
1763
|
+
const readFile$3 = async uri => {
|
|
1764
|
+
return invoke$3('FileSystem.readFile', uri);
|
|
1546
1765
|
};
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
const {
|
|
1550
|
-
id,
|
|
1551
|
-
selector,
|
|
1552
|
-
contentSecurityPolicy,
|
|
1553
|
-
elements
|
|
1554
|
-
} = rawWebView;
|
|
1555
|
-
return {
|
|
1556
|
-
id,
|
|
1557
|
-
selectorString: JSON.stringify(selector),
|
|
1558
|
-
contentSecurityPolicyString: JSON.stringify(contentSecurityPolicy),
|
|
1559
|
-
elementsString: JSON.stringify(elements, null, 2)
|
|
1560
|
-
};
|
|
1766
|
+
const writeFile = async (uri, content) => {
|
|
1767
|
+
return invoke$3('FileSystem.writeFile', uri, content);
|
|
1561
1768
|
};
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
const rawWebViews = extension.webViews || [];
|
|
1565
|
-
return rawWebViews.map(toWebView);
|
|
1769
|
+
const mkdir = async uri => {
|
|
1770
|
+
return invoke$3('FileSystem.mkdir', uri);
|
|
1566
1771
|
};
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
const webViews = getWebViews(extension);
|
|
1570
|
-
return {
|
|
1571
|
-
webViews
|
|
1572
|
-
};
|
|
1772
|
+
const rename = async (oldUri, newUri) => {
|
|
1773
|
+
return invoke$3('FileSystem.rename', oldUri, newUri);
|
|
1573
1774
|
};
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
if (!extension || typeof extension !== 'object' || !('webViews' in extension)) {
|
|
1577
|
-
return false;
|
|
1578
|
-
}
|
|
1579
|
-
return Array.isArray(extension.webViews);
|
|
1775
|
+
const copy = async (oldUri, newUri) => {
|
|
1776
|
+
return invoke$3('FileSystem.copy', oldUri, newUri);
|
|
1580
1777
|
};
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
className: DefinitionListItemHeading,
|
|
1585
|
-
childCount: 1
|
|
1778
|
+
const exists$1 = async uri => {
|
|
1779
|
+
// @ts-ignore
|
|
1780
|
+
return invoke$3('FileSystem.exists', uri);
|
|
1586
1781
|
};
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
childCount: 1
|
|
1782
|
+
const getFolderSize$2 = async uri => {
|
|
1783
|
+
// @ts-ignore
|
|
1784
|
+
return invoke$3('FileSystem.getFolderSize', uri);
|
|
1591
1785
|
};
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
childCount: 2
|
|
1786
|
+
const readFileAsBlob$1 = async uri => {
|
|
1787
|
+
// @ts-ignore
|
|
1788
|
+
return invoke$3('FileSystem.readFileAsBlob', uri);
|
|
1596
1789
|
};
|
|
1597
|
-
const
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
selectorString,
|
|
1601
|
-
contentSecurityPolicyString,
|
|
1602
|
-
elementsString
|
|
1603
|
-
} = webView;
|
|
1604
|
-
const textId = id$1();
|
|
1605
|
-
const textSelector = selector();
|
|
1606
|
-
const textContentSecurityPolicy = contentSecurityPolicy();
|
|
1607
|
-
const textElements = elements();
|
|
1608
|
-
return [{
|
|
1609
|
-
type: Div,
|
|
1610
|
-
className: FeatureWebView,
|
|
1611
|
-
childCount: 5
|
|
1612
|
-
}, item, heading, text(textId), pre, text(id), item, heading, text(textSelector), pre, text(selectorString), item, heading, text(textContentSecurityPolicy), pre, text(contentSecurityPolicyString), item, heading, text(textElements), pre, text(elementsString)];
|
|
1790
|
+
const appendFile = async (uri, text) => {
|
|
1791
|
+
// @ts-ignore
|
|
1792
|
+
return invoke$3('FileSystem.appendFile', uri, text);
|
|
1613
1793
|
};
|
|
1614
1794
|
|
|
1615
|
-
const
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1795
|
+
const FileSystemWorker = {
|
|
1796
|
+
__proto__: null,
|
|
1797
|
+
appendFile,
|
|
1798
|
+
copy,
|
|
1799
|
+
createFile,
|
|
1800
|
+
dispose: dispose$4,
|
|
1801
|
+
exists: exists$1,
|
|
1802
|
+
getFolderSize: getFolderSize$2,
|
|
1803
|
+
getPathSeparator,
|
|
1804
|
+
getRealPath,
|
|
1805
|
+
invoke: invoke$3,
|
|
1806
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
1807
|
+
mkdir,
|
|
1808
|
+
readDirWithFileTypes,
|
|
1809
|
+
readFile: readFile$3,
|
|
1810
|
+
readFileAsBlob: readFileAsBlob$1,
|
|
1811
|
+
remove,
|
|
1812
|
+
rename,
|
|
1813
|
+
set: set$8,
|
|
1814
|
+
stat,
|
|
1815
|
+
writeFile
|
|
1625
1816
|
};
|
|
1626
1817
|
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1818
|
+
const {
|
|
1819
|
+
invoke: invoke$2,
|
|
1820
|
+
invokeAndTransfer: invokeAndTransfer$1,
|
|
1821
|
+
set: set$7,
|
|
1822
|
+
dispose: dispose$3
|
|
1823
|
+
} = create$7(MarkdownWorker$1);
|
|
1824
|
+
const getVirtualDom$1 = async html => {
|
|
1825
|
+
// @ts-ignore
|
|
1826
|
+
return invoke$2('Markdown.getVirtualDom', html);
|
|
1827
|
+
};
|
|
1828
|
+
const render$1 = async (markdown, options) => {
|
|
1829
|
+
// @ts-ignore
|
|
1830
|
+
return invoke$2('Markdown.render', markdown, options);
|
|
1629
1831
|
};
|
|
1630
1832
|
|
|
1631
|
-
const
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
register$1({
|
|
1640
|
-
id: Commands,
|
|
1641
|
-
getLabel: commands$1,
|
|
1642
|
-
isEnabled: featureCommandsEnabled,
|
|
1643
|
-
getDetails: getCommandsDetails,
|
|
1644
|
-
getVirtualDom: getCommandsVirtualDom
|
|
1645
|
-
});
|
|
1646
|
-
register$1({
|
|
1647
|
-
id: Settings,
|
|
1648
|
-
getLabel: settings,
|
|
1649
|
-
isEnabled: featureSettingsEnabled,
|
|
1650
|
-
getDetails: getSettingsDetails,
|
|
1651
|
-
getVirtualDom: getSettingsVirtualDom
|
|
1652
|
-
});
|
|
1653
|
-
register$1({
|
|
1654
|
-
id: JsonValidation,
|
|
1655
|
-
getLabel: jsonValidation,
|
|
1656
|
-
isEnabled: featureJsonValidationEnabled,
|
|
1657
|
-
getDetails: getJsonValidationDetails,
|
|
1658
|
-
getVirtualDom: getJsonValidationVirtualDom
|
|
1659
|
-
});
|
|
1660
|
-
register$1({
|
|
1661
|
-
id: ProgrammingLanguages,
|
|
1662
|
-
getLabel: programmingLanguages,
|
|
1663
|
-
isEnabled: featureProgrammingLanguagesEnabled,
|
|
1664
|
-
getDetails: getProgrammingLanguagesDetails,
|
|
1665
|
-
getVirtualDom: getProgrammingLanguagesVirtualDom
|
|
1666
|
-
});
|
|
1667
|
-
register$1({
|
|
1668
|
-
id: WebViews,
|
|
1669
|
-
getLabel: webViews,
|
|
1670
|
-
isEnabled: featureWebViewsEnabled,
|
|
1671
|
-
getDetails: getWebViewsDetails,
|
|
1672
|
-
getVirtualDom: getWebViewsVirtualDom
|
|
1673
|
-
});
|
|
1674
|
-
register$1({
|
|
1675
|
-
id: ActivationEvents,
|
|
1676
|
-
getLabel: activationEvents,
|
|
1677
|
-
isEnabled: featureActivationEventsEnabled,
|
|
1678
|
-
getDetails: getActivationEventsDetails,
|
|
1679
|
-
getVirtualDom: getActivationEventsVirtualDom
|
|
1680
|
-
});
|
|
1681
|
-
register$1({
|
|
1682
|
-
id: RuntimeStatus,
|
|
1683
|
-
getLabel: runtimeStatus,
|
|
1684
|
-
isEnabled: featureRuntimeStatusEnabled,
|
|
1685
|
-
getDetails: getRuntimeStatusDetails,
|
|
1686
|
-
getVirtualDom: getRuntimeStatusVirtualDom
|
|
1687
|
-
});
|
|
1833
|
+
const MarkdownWorker = {
|
|
1834
|
+
__proto__: null,
|
|
1835
|
+
dispose: dispose$3,
|
|
1836
|
+
getVirtualDom: getVirtualDom$1,
|
|
1837
|
+
invoke: invoke$2,
|
|
1838
|
+
invokeAndTransfer: invokeAndTransfer$1,
|
|
1839
|
+
render: render$1,
|
|
1840
|
+
set: set$7
|
|
1688
1841
|
};
|
|
1689
1842
|
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
return
|
|
1843
|
+
const {
|
|
1844
|
+
invoke: invoke$1,
|
|
1845
|
+
invokeAndTransfer,
|
|
1846
|
+
set: set$6,
|
|
1847
|
+
dispose: dispose$2
|
|
1848
|
+
} = create$7(RendererWorker$1);
|
|
1849
|
+
const searchFileHtml = async uri => {
|
|
1850
|
+
return invoke$1('ExtensionHost.searchFileWithHtml', uri);
|
|
1698
1851
|
};
|
|
1699
|
-
const
|
|
1700
|
-
|
|
1701
|
-
if (message) {
|
|
1702
|
-
return `${message}: ${stringifiedError}`;
|
|
1703
|
-
}
|
|
1704
|
-
return stringifiedError;
|
|
1852
|
+
const getFilePathElectron = async file => {
|
|
1853
|
+
return invoke$1('FileSystemHandle.getFilePathElectron', file);
|
|
1705
1854
|
};
|
|
1706
|
-
const
|
|
1707
|
-
|
|
1708
|
-
return string.indexOf(NewLine$2, startIndex);
|
|
1855
|
+
const showContextMenu$1 = async (x, y, id, ...args) => {
|
|
1856
|
+
return invoke$1('ContextMenu.show', x, y, id, ...args);
|
|
1709
1857
|
};
|
|
1710
|
-
const
|
|
1711
|
-
|
|
1712
|
-
return parent;
|
|
1713
|
-
}
|
|
1714
|
-
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
1715
|
-
const childNewLineIndex = getNewLineIndex$1(child);
|
|
1716
|
-
if (childNewLineIndex === -1) {
|
|
1717
|
-
return parent;
|
|
1718
|
-
}
|
|
1719
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
1720
|
-
const childRest = child.slice(childNewLineIndex);
|
|
1721
|
-
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
1722
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
1723
|
-
return parentFirstLine + childRest;
|
|
1724
|
-
}
|
|
1725
|
-
return child;
|
|
1858
|
+
const getElectronVersion = async () => {
|
|
1859
|
+
return invoke$1('Process.getElectronVersion');
|
|
1726
1860
|
};
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
const combinedMessage = getCombinedMessage(error, message);
|
|
1730
|
-
super(combinedMessage);
|
|
1731
|
-
this.name = 'VError';
|
|
1732
|
-
if (error instanceof Error) {
|
|
1733
|
-
this.stack = mergeStacks(this.stack, error.stack);
|
|
1734
|
-
}
|
|
1735
|
-
if (error.codeFrame) {
|
|
1736
|
-
// @ts-ignore
|
|
1737
|
-
this.codeFrame = error.codeFrame;
|
|
1738
|
-
}
|
|
1739
|
-
if (error.code) {
|
|
1740
|
-
// @ts-ignore
|
|
1741
|
-
this.code = error.code;
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
const isMessagePort = value => {
|
|
1747
|
-
return value && value instanceof MessagePort;
|
|
1861
|
+
const applyBulkReplacement = async bulkEdits => {
|
|
1862
|
+
await invoke$1('BulkReplacement.applyBulkReplacement', bulkEdits);
|
|
1748
1863
|
};
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1864
|
+
const setColorTheme$2 = async id => {
|
|
1865
|
+
// @ts-ignore
|
|
1866
|
+
return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
1751
1867
|
};
|
|
1752
|
-
const
|
|
1753
|
-
return
|
|
1868
|
+
const getNodeVersion = async () => {
|
|
1869
|
+
return invoke$1('Process.getNodeVersion');
|
|
1754
1870
|
};
|
|
1755
|
-
const
|
|
1756
|
-
return
|
|
1871
|
+
const getChromeVersion = async () => {
|
|
1872
|
+
return invoke$1('Process.getChromeVersion');
|
|
1757
1873
|
};
|
|
1758
|
-
const
|
|
1759
|
-
return
|
|
1874
|
+
const getV8Version = async () => {
|
|
1875
|
+
return invoke$1('Process.getV8Version');
|
|
1760
1876
|
};
|
|
1761
|
-
const
|
|
1762
|
-
const
|
|
1763
|
-
|
|
1764
|
-
if (fn(value)) {
|
|
1765
|
-
return true;
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
return false;
|
|
1877
|
+
const getFileHandles = async fileIds => {
|
|
1878
|
+
const files = await invoke$1('FileSystemHandle.getFileHandles', fileIds);
|
|
1879
|
+
return files;
|
|
1769
1880
|
};
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
return;
|
|
1773
|
-
}
|
|
1774
|
-
if (isTransferrable(value)) {
|
|
1775
|
-
transferrables.push(value);
|
|
1776
|
-
return;
|
|
1777
|
-
}
|
|
1778
|
-
if (Array.isArray(value)) {
|
|
1779
|
-
for (const item of value) {
|
|
1780
|
-
walkValue(item, transferrables, isTransferrable);
|
|
1781
|
-
}
|
|
1782
|
-
return;
|
|
1783
|
-
}
|
|
1784
|
-
if (typeof value === 'object') {
|
|
1785
|
-
for (const property of Object.values(value)) {
|
|
1786
|
-
walkValue(property, transferrables, isTransferrable);
|
|
1787
|
-
}
|
|
1788
|
-
return;
|
|
1789
|
-
}
|
|
1881
|
+
const setWorkspacePath = async path => {
|
|
1882
|
+
await invoke$1('Workspace.setPath', path);
|
|
1790
1883
|
};
|
|
1791
|
-
const
|
|
1792
|
-
|
|
1793
|
-
walkValue(value, transferrables, isTransferrable);
|
|
1794
|
-
return transferrables;
|
|
1884
|
+
const registerWebViewInterceptor = async (id, port) => {
|
|
1885
|
+
await invokeAndTransfer('WebView.registerInterceptor', id, port);
|
|
1795
1886
|
};
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1798
|
-
const data = that.getData(...args);
|
|
1799
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
1800
|
-
data
|
|
1801
|
-
}));
|
|
1802
|
-
};
|
|
1803
|
-
that.onMessage(handleMessage);
|
|
1804
|
-
const handleClose = event => {
|
|
1805
|
-
that.dispatchEvent(new Event('close'));
|
|
1806
|
-
};
|
|
1807
|
-
that.onClose(handleClose);
|
|
1887
|
+
const unregisterWebViewInterceptor = async id => {
|
|
1888
|
+
await invoke$1('WebView.unregisterInterceptor', id);
|
|
1808
1889
|
};
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
attachEvents(this);
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1817
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1818
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1819
|
-
const NewLine$1 = '\n';
|
|
1820
|
-
const joinLines$1 = lines => {
|
|
1821
|
-
return lines.join(NewLine$1);
|
|
1890
|
+
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1891
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1892
|
+
// @ts-ignore
|
|
1893
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1822
1894
|
};
|
|
1823
|
-
const
|
|
1824
|
-
const
|
|
1825
|
-
|
|
1826
|
-
|
|
1895
|
+
const sendMessagePortToErrorWorker = async (port, rpcId) => {
|
|
1896
|
+
const command = 'Errors.handleMessagePort';
|
|
1897
|
+
// @ts-ignore
|
|
1898
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1827
1899
|
};
|
|
1828
|
-
const
|
|
1829
|
-
const
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
actualMessage: joinLines$1(lines),
|
|
1833
|
-
rest: []
|
|
1834
|
-
};
|
|
1835
|
-
}
|
|
1836
|
-
let lastIndex = index - 1;
|
|
1837
|
-
while (++lastIndex < lines.length) {
|
|
1838
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
1839
|
-
break;
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
return {
|
|
1843
|
-
actualMessage: lines[index - 1],
|
|
1844
|
-
rest: lines.slice(index, lastIndex)
|
|
1845
|
-
};
|
|
1900
|
+
const sendMessagePortToMarkdownWorker$2 = async (port, rpcId) => {
|
|
1901
|
+
const command = 'Markdown.handleMessagePort';
|
|
1902
|
+
// @ts-ignore
|
|
1903
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
|
|
1846
1904
|
};
|
|
1847
|
-
const
|
|
1848
|
-
|
|
1905
|
+
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1906
|
+
const command = 'IconTheme.handleMessagePort';
|
|
1907
|
+
// @ts-ignore
|
|
1908
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
1849
1909
|
};
|
|
1850
|
-
const
|
|
1851
|
-
const
|
|
1852
|
-
|
|
1853
|
-
|
|
1910
|
+
const sendMessagePortToFileSystemWorker$2 = async (port, rpcId) => {
|
|
1911
|
+
const command = 'FileSystem.handleMessagePort';
|
|
1912
|
+
// @ts-ignore
|
|
1913
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1854
1914
|
};
|
|
1855
|
-
const
|
|
1856
|
-
return
|
|
1915
|
+
const readFile$2 = async uri => {
|
|
1916
|
+
return invoke$1('FileSystem.readFile', uri);
|
|
1857
1917
|
};
|
|
1858
|
-
const
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1862
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
1863
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
1864
|
-
return relevantMessage;
|
|
1918
|
+
const getWebViewSecret = async key => {
|
|
1919
|
+
// @ts-ignore
|
|
1920
|
+
return invoke$1('WebView.getSecret', key);
|
|
1865
1921
|
};
|
|
1866
|
-
const
|
|
1867
|
-
return
|
|
1922
|
+
const setWebViewPort = async (uid, port, origin, portType) => {
|
|
1923
|
+
return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
|
|
1868
1924
|
};
|
|
1869
|
-
const
|
|
1870
|
-
|
|
1871
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1872
|
-
const message = lines[messageIndex];
|
|
1873
|
-
return {
|
|
1874
|
-
message,
|
|
1875
|
-
code: ERR_MODULE_NOT_FOUND
|
|
1876
|
-
};
|
|
1925
|
+
const setFocus = key => {
|
|
1926
|
+
return invoke$1('Focus.setFocus', key);
|
|
1877
1927
|
};
|
|
1878
|
-
const
|
|
1879
|
-
|
|
1880
|
-
return false;
|
|
1881
|
-
}
|
|
1882
|
-
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
1928
|
+
const getFileIcon = async options => {
|
|
1929
|
+
return invoke$1('IconTheme.getFileIcon', options);
|
|
1883
1930
|
};
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1886
|
-
return false;
|
|
1887
|
-
}
|
|
1888
|
-
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
1931
|
+
const getColorThemeNames = async () => {
|
|
1932
|
+
return invoke$1('ColorTheme.getColorThemeNames');
|
|
1889
1933
|
};
|
|
1890
|
-
const
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
1934
|
+
const disableExtension$2 = async id => {
|
|
1935
|
+
// @ts-ignore
|
|
1936
|
+
return invoke$1('ExtensionManagement.disable', id);
|
|
1894
1937
|
};
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1897
|
-
return
|
|
1898
|
-
message: `Incompatible native node module: ${message}`,
|
|
1899
|
-
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
1900
|
-
};
|
|
1938
|
+
const enableExtension$2 = async id => {
|
|
1939
|
+
// @ts-ignore
|
|
1940
|
+
return invoke$1('ExtensionManagement.enable', id);
|
|
1901
1941
|
};
|
|
1902
|
-
const
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
1906
|
-
};
|
|
1942
|
+
const handleDebugChange = async params => {
|
|
1943
|
+
// @ts-ignore
|
|
1944
|
+
return invoke$1('Run And Debug.handleChange', params);
|
|
1907
1945
|
};
|
|
1908
|
-
const
|
|
1909
|
-
|
|
1910
|
-
return getNativeModuleErrorMessage(stderr);
|
|
1911
|
-
}
|
|
1912
|
-
if (isModulesSyntaxError(stderr)) {
|
|
1913
|
-
return getModuleSyntaxError();
|
|
1914
|
-
}
|
|
1915
|
-
if (isModuleNotFoundError(stderr)) {
|
|
1916
|
-
return getModuleNotFoundError(stderr);
|
|
1917
|
-
}
|
|
1918
|
-
const lines = splitLines$1(stderr);
|
|
1919
|
-
const {
|
|
1920
|
-
actualMessage,
|
|
1921
|
-
rest
|
|
1922
|
-
} = getDetails(lines);
|
|
1923
|
-
return {
|
|
1924
|
-
message: actualMessage,
|
|
1925
|
-
code: '',
|
|
1926
|
-
stack: rest
|
|
1927
|
-
};
|
|
1946
|
+
const getFolderIcon = async options => {
|
|
1947
|
+
return invoke$1('IconTheme.getFolderIcon', options);
|
|
1928
1948
|
};
|
|
1929
|
-
|
|
1949
|
+
const closeWidget = async widgetId => {
|
|
1950
|
+
return invoke$1('Viewlet.closeWidget', widgetId);
|
|
1951
|
+
};
|
|
1952
|
+
const sendMessagePortToExtensionHostWorker$2 = async (port, rpcId = 0) => {
|
|
1953
|
+
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1954
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1955
|
+
};
|
|
1956
|
+
const sendMessagePortToSearchProcess = async port => {
|
|
1957
|
+
await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
|
|
1958
|
+
};
|
|
1959
|
+
const confirm = async (message, options) => {
|
|
1930
1960
|
// @ts-ignore
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
// @ts-ignore
|
|
1934
|
-
const {
|
|
1935
|
-
message,
|
|
1936
|
-
code,
|
|
1937
|
-
stack
|
|
1938
|
-
} = getHelpfulChildProcessError(stdout, stderr);
|
|
1939
|
-
const cause = new Error(message);
|
|
1940
|
-
// @ts-ignore
|
|
1941
|
-
cause.code = code;
|
|
1942
|
-
cause.stack = stack;
|
|
1943
|
-
super(cause, betterMessage);
|
|
1944
|
-
} else {
|
|
1945
|
-
super(betterMessage);
|
|
1946
|
-
}
|
|
1947
|
-
// @ts-ignore
|
|
1948
|
-
this.name = 'IpcError';
|
|
1949
|
-
// @ts-ignore
|
|
1950
|
-
this.stdout = stdout;
|
|
1951
|
-
// @ts-ignore
|
|
1952
|
-
this.stderr = stderr;
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
const readyMessage = 'ready';
|
|
1956
|
-
const getData$2 = event => {
|
|
1957
|
-
return event.data;
|
|
1961
|
+
const result = await invoke$1('ConfirmPrompt.prompt', message, options);
|
|
1962
|
+
return result;
|
|
1958
1963
|
};
|
|
1959
|
-
const
|
|
1960
|
-
|
|
1961
|
-
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1962
|
-
throw new TypeError('module is not in web worker scope');
|
|
1963
|
-
}
|
|
1964
|
-
return globalThis;
|
|
1964
|
+
const getRecentlyOpened = async () => {
|
|
1965
|
+
return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
1965
1966
|
};
|
|
1966
|
-
const
|
|
1967
|
-
|
|
1967
|
+
const getKeyBindings = async () => {
|
|
1968
|
+
return invoke$1('KeyBindingsInitial.getKeyBindings');
|
|
1968
1969
|
};
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
return getData$2(event);
|
|
1972
|
-
}
|
|
1973
|
-
send(message) {
|
|
1974
|
-
// @ts-ignore
|
|
1975
|
-
this._rawIpc.postMessage(message);
|
|
1976
|
-
}
|
|
1977
|
-
sendAndTransfer(message) {
|
|
1978
|
-
const transfer = getTransferrables(message);
|
|
1979
|
-
// @ts-ignore
|
|
1980
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1981
|
-
}
|
|
1982
|
-
dispose() {
|
|
1983
|
-
// ignore
|
|
1984
|
-
}
|
|
1985
|
-
onClose(callback) {
|
|
1986
|
-
// ignore
|
|
1987
|
-
}
|
|
1988
|
-
onMessage(callback) {
|
|
1989
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
const wrap$f = global => {
|
|
1993
|
-
return new IpcChildWithModuleWorker(global);
|
|
1970
|
+
const writeClipBoardText$1 = async text => {
|
|
1971
|
+
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
1994
1972
|
};
|
|
1995
|
-
const
|
|
1996
|
-
const {
|
|
1997
|
-
resolve,
|
|
1998
|
-
promise
|
|
1999
|
-
} = Promise.withResolvers();
|
|
2000
|
-
port.addEventListener('message', resolve, {
|
|
2001
|
-
once: true
|
|
2002
|
-
});
|
|
2003
|
-
const event = await promise;
|
|
1973
|
+
const writeClipBoardImage$1 = async blob => {
|
|
2004
1974
|
// @ts-ignore
|
|
2005
|
-
|
|
1975
|
+
await invoke$1('ClipBoard.writeImage', /* text */blob);
|
|
2006
1976
|
};
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
const parentIpc = wrap$f(parentIpcRaw);
|
|
2011
|
-
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
2012
|
-
if (firstMessage.method !== 'initialize') {
|
|
2013
|
-
throw new IpcError('unexpected first message');
|
|
2014
|
-
}
|
|
2015
|
-
const type = firstMessage.params[0];
|
|
2016
|
-
if (type === 'message-port') {
|
|
2017
|
-
parentIpc.send({
|
|
2018
|
-
jsonrpc: '2.0',
|
|
2019
|
-
id: firstMessage.id,
|
|
2020
|
-
result: null
|
|
2021
|
-
});
|
|
2022
|
-
parentIpc.dispose();
|
|
2023
|
-
const port = firstMessage.params[1];
|
|
2024
|
-
return port;
|
|
2025
|
-
}
|
|
2026
|
-
return globalThis;
|
|
1977
|
+
const searchFileMemory = async uri => {
|
|
1978
|
+
// @ts-ignore
|
|
1979
|
+
return invoke$1('ExtensionHost.searchFileWithMemory', uri);
|
|
2027
1980
|
};
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
return getData$2(event);
|
|
2031
|
-
}
|
|
2032
|
-
send(message) {
|
|
2033
|
-
this._rawIpc.postMessage(message);
|
|
2034
|
-
}
|
|
2035
|
-
sendAndTransfer(message) {
|
|
2036
|
-
const transfer = getTransferrables(message);
|
|
2037
|
-
this._rawIpc.postMessage(message, transfer);
|
|
2038
|
-
}
|
|
2039
|
-
dispose() {
|
|
2040
|
-
if (this._rawIpc.close) {
|
|
2041
|
-
this._rawIpc.close();
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2044
|
-
onClose(callback) {
|
|
2045
|
-
// ignore
|
|
2046
|
-
}
|
|
2047
|
-
onMessage(callback) {
|
|
2048
|
-
this._rawIpc.addEventListener('message', callback);
|
|
2049
|
-
this._rawIpc.start();
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
const wrap$e = port => {
|
|
2053
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1981
|
+
const searchFileFetch = async uri => {
|
|
1982
|
+
return invoke$1('ExtensionHost.searchFileWithFetch', uri);
|
|
2054
1983
|
};
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2057
|
-
listen: listen$6,
|
|
2058
|
-
wrap: wrap$e
|
|
1984
|
+
const showMessageBox = async options => {
|
|
1985
|
+
return invoke$1('ElectronDialog.showMessageBox', options);
|
|
2059
1986
|
};
|
|
2060
|
-
const
|
|
2061
|
-
|
|
2062
|
-
emitter.addEventListener(type, callback);
|
|
2063
|
-
} else {
|
|
2064
|
-
emitter.on(type, callback);
|
|
2065
|
-
}
|
|
1987
|
+
const handleDebugResumed = async params => {
|
|
1988
|
+
await invoke$1('Run And Debug.handleResumed', params);
|
|
2066
1989
|
};
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2069
|
-
emitter.removeEventListener(type, callback);
|
|
2070
|
-
} else {
|
|
2071
|
-
emitter.off(type, callback);
|
|
2072
|
-
}
|
|
1990
|
+
const openWidget = async name => {
|
|
1991
|
+
await invoke$1('Viewlet.openWidget', name);
|
|
2073
1992
|
};
|
|
2074
|
-
const
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2077
|
-
promise
|
|
2078
|
-
} = Promise.withResolvers();
|
|
2079
|
-
const listenerMap = Object.create(null);
|
|
2080
|
-
const cleanup = value => {
|
|
2081
|
-
for (const event of Object.keys(eventMap)) {
|
|
2082
|
-
removeListener(eventEmitter, event, listenerMap[event]);
|
|
2083
|
-
}
|
|
2084
|
-
resolve(value);
|
|
2085
|
-
};
|
|
2086
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
2087
|
-
const listener = event => {
|
|
2088
|
-
cleanup({
|
|
2089
|
-
type,
|
|
2090
|
-
event
|
|
2091
|
-
});
|
|
2092
|
-
};
|
|
2093
|
-
addListener(eventEmitter, event, listener);
|
|
2094
|
-
listenerMap[event] = listener;
|
|
2095
|
-
}
|
|
2096
|
-
return promise;
|
|
1993
|
+
const getIcons = async requests => {
|
|
1994
|
+
const icons = await invoke$1('IconTheme.getIcons', requests);
|
|
1995
|
+
return icons;
|
|
2097
1996
|
};
|
|
2098
|
-
const
|
|
2099
|
-
|
|
2100
|
-
messagePort,
|
|
2101
|
-
isMessagePortOpen
|
|
2102
|
-
}) => {
|
|
2103
|
-
if (!isMessagePort(messagePort)) {
|
|
2104
|
-
throw new IpcError('port must be of type MessagePort');
|
|
2105
|
-
}
|
|
2106
|
-
if (isMessagePortOpen) {
|
|
2107
|
-
return messagePort;
|
|
2108
|
-
}
|
|
2109
|
-
const eventPromise = getFirstEvent(messagePort, {
|
|
2110
|
-
message: Message$1
|
|
2111
|
-
});
|
|
2112
|
-
messagePort.start();
|
|
2113
|
-
const {
|
|
2114
|
-
type,
|
|
2115
|
-
event
|
|
2116
|
-
} = await eventPromise;
|
|
2117
|
-
if (type !== Message$1) {
|
|
2118
|
-
throw new IpcError('Failed to wait for ipc message');
|
|
2119
|
-
}
|
|
2120
|
-
if (event.data !== readyMessage) {
|
|
2121
|
-
throw new IpcError('unexpected first message');
|
|
2122
|
-
}
|
|
2123
|
-
return messagePort;
|
|
1997
|
+
const activateByEvent = event => {
|
|
1998
|
+
return invoke$1('ExtensionHostManagement.activateByEvent', event);
|
|
2124
1999
|
};
|
|
2125
|
-
const
|
|
2126
|
-
|
|
2000
|
+
const setAdditionalFocus = focusKey => {
|
|
2001
|
+
// @ts-ignore
|
|
2002
|
+
return invoke$1('Focus.setAdditionalFocus', focusKey);
|
|
2127
2003
|
};
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
this._rawIpc.postMessage(message);
|
|
2132
|
-
}
|
|
2133
|
-
sendAndTransfer(message) {
|
|
2134
|
-
const transfer = getTransferrables(message);
|
|
2135
|
-
this._rawIpc.postMessage(message, transfer);
|
|
2136
|
-
}
|
|
2137
|
-
dispose() {
|
|
2138
|
-
this._rawIpc.close();
|
|
2139
|
-
}
|
|
2140
|
-
onMessage(callback) {
|
|
2141
|
-
this._rawIpc.addEventListener('message', callback);
|
|
2142
|
-
}
|
|
2143
|
-
onClose(callback) {}
|
|
2144
|
-
}
|
|
2145
|
-
const wrap$5 = messagePort => {
|
|
2146
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
2004
|
+
const getActiveEditorId = () => {
|
|
2005
|
+
// @ts-ignore
|
|
2006
|
+
return invoke$1('GetActiveEditor.getActiveEditorId');
|
|
2147
2007
|
};
|
|
2148
|
-
const
|
|
2149
|
-
|
|
2150
|
-
create: create$5$1,
|
|
2151
|
-
signal: signal$1,
|
|
2152
|
-
wrap: wrap$5
|
|
2008
|
+
const getWorkspacePath = () => {
|
|
2009
|
+
return invoke$1('Workspace.getPath');
|
|
2153
2010
|
};
|
|
2154
|
-
|
|
2155
|
-
const
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
jsonrpc: Two,
|
|
2159
|
-
method,
|
|
2160
|
-
params
|
|
2161
|
-
};
|
|
2011
|
+
const sendMessagePortToRendererProcess = async port => {
|
|
2012
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
2013
|
+
// @ts-ignore
|
|
2014
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
|
|
2162
2015
|
};
|
|
2163
|
-
const
|
|
2164
|
-
|
|
2165
|
-
callbacks[id] = fn;
|
|
2016
|
+
const getPreference = async key => {
|
|
2017
|
+
return await invoke$1('Preferences.get', key);
|
|
2166
2018
|
};
|
|
2167
|
-
const
|
|
2168
|
-
return
|
|
2019
|
+
const getAllExtensions$2 = async () => {
|
|
2020
|
+
return invoke$1('ExtensionManagement.getAllExtensions');
|
|
2169
2021
|
};
|
|
2170
|
-
const
|
|
2171
|
-
|
|
2022
|
+
const rerenderEditor = async key => {
|
|
2023
|
+
// @ts-ignore
|
|
2024
|
+
return invoke$1('Editor.rerender', key);
|
|
2172
2025
|
};
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
return ++id;
|
|
2026
|
+
const handleDebugPaused = async params => {
|
|
2027
|
+
await invoke$1('Run And Debug.handlePaused', params);
|
|
2176
2028
|
};
|
|
2177
|
-
const
|
|
2178
|
-
|
|
2179
|
-
const {
|
|
2180
|
-
resolve,
|
|
2181
|
-
promise
|
|
2182
|
-
} = Promise.withResolvers();
|
|
2183
|
-
set$3(id, resolve);
|
|
2184
|
-
return {
|
|
2185
|
-
id,
|
|
2186
|
-
promise
|
|
2187
|
-
};
|
|
2029
|
+
const openUri = async (uri, focus, options) => {
|
|
2030
|
+
await invoke$1('Main.openUri', uri, focus, options);
|
|
2188
2031
|
};
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
} = registerPromise();
|
|
2194
|
-
const message = {
|
|
2195
|
-
jsonrpc: Two,
|
|
2196
|
-
method,
|
|
2197
|
-
params,
|
|
2198
|
-
id
|
|
2199
|
-
};
|
|
2200
|
-
return {
|
|
2201
|
-
message,
|
|
2202
|
-
promise
|
|
2203
|
-
};
|
|
2032
|
+
const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
2033
|
+
await invokeAndTransfer(
|
|
2034
|
+
// @ts-ignore
|
|
2035
|
+
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
|
|
2204
2036
|
};
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
super(message);
|
|
2208
|
-
this.name = 'JsonRpcError';
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
const NewLine = '\n';
|
|
2212
|
-
const DomException = 'DOMException';
|
|
2213
|
-
const ReferenceError$1 = 'ReferenceError';
|
|
2214
|
-
const SyntaxError$1 = 'SyntaxError';
|
|
2215
|
-
const TypeError$1 = 'TypeError';
|
|
2216
|
-
const getErrorConstructor = (message, type) => {
|
|
2217
|
-
if (type) {
|
|
2218
|
-
switch (type) {
|
|
2219
|
-
case DomException:
|
|
2220
|
-
return DOMException;
|
|
2221
|
-
case TypeError$1:
|
|
2222
|
-
return TypeError;
|
|
2223
|
-
case SyntaxError$1:
|
|
2224
|
-
return SyntaxError;
|
|
2225
|
-
case ReferenceError$1:
|
|
2226
|
-
return ReferenceError;
|
|
2227
|
-
default:
|
|
2228
|
-
return Error;
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
if (message.startsWith('TypeError: ')) {
|
|
2232
|
-
return TypeError;
|
|
2233
|
-
}
|
|
2234
|
-
if (message.startsWith('SyntaxError: ')) {
|
|
2235
|
-
return SyntaxError;
|
|
2236
|
-
}
|
|
2237
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
2238
|
-
return ReferenceError;
|
|
2239
|
-
}
|
|
2240
|
-
return Error;
|
|
2037
|
+
const handleDebugScriptParsed = async script => {
|
|
2038
|
+
await invoke$1('Run And Debug.handleScriptParsed', script);
|
|
2241
2039
|
};
|
|
2242
|
-
const
|
|
2243
|
-
|
|
2244
|
-
if (ErrorConstructor === DOMException && name) {
|
|
2245
|
-
return new ErrorConstructor(message, name);
|
|
2246
|
-
}
|
|
2247
|
-
if (ErrorConstructor === Error) {
|
|
2248
|
-
const error = new Error(message);
|
|
2249
|
-
if (name && name !== 'VError') {
|
|
2250
|
-
error.name = name;
|
|
2251
|
-
}
|
|
2252
|
-
return error;
|
|
2253
|
-
}
|
|
2254
|
-
return new ErrorConstructor(message);
|
|
2040
|
+
const getWindowId = async () => {
|
|
2041
|
+
return invoke$1('GetWindowId.getWindowId');
|
|
2255
2042
|
};
|
|
2256
|
-
const
|
|
2257
|
-
|
|
2043
|
+
const getBlob = async uri => {
|
|
2044
|
+
// @ts-ignore
|
|
2045
|
+
return invoke$1('FileSystem.getBlob', uri);
|
|
2258
2046
|
};
|
|
2259
|
-
const
|
|
2260
|
-
return
|
|
2047
|
+
const getExtensionCommands = async () => {
|
|
2048
|
+
return invoke$1('ExtensionHost.getCommands');
|
|
2261
2049
|
};
|
|
2262
|
-
const
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
return currentStack;
|
|
2050
|
+
const showErrorDialog = async errorInfo => {
|
|
2051
|
+
// @ts-ignore
|
|
2052
|
+
await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
|
|
2266
2053
|
};
|
|
2267
|
-
const
|
|
2268
|
-
|
|
2054
|
+
const getFolderSize$1 = async uri => {
|
|
2055
|
+
// @ts-ignore
|
|
2056
|
+
return await invoke$1('FileSystem.getFolderSize', uri);
|
|
2269
2057
|
};
|
|
2270
|
-
const
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
parentStack = error.message + NewLine + parentStack;
|
|
2274
|
-
}
|
|
2275
|
-
return parentStack;
|
|
2058
|
+
const getExtension$3 = async id => {
|
|
2059
|
+
// @ts-ignore
|
|
2060
|
+
return invoke$1('ExtensionManagement.getExtension', id);
|
|
2276
2061
|
};
|
|
2277
|
-
const
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2062
|
+
const getMarkdownDom = async html => {
|
|
2063
|
+
// @ts-ignore
|
|
2064
|
+
return invoke$1('Markdown.getVirtualDom', html);
|
|
2065
|
+
};
|
|
2066
|
+
const renderMarkdown$1 = async (markdown, options) => {
|
|
2067
|
+
// @ts-ignore
|
|
2068
|
+
return invoke$1('Markdown.renderMarkdown', markdown, options);
|
|
2069
|
+
};
|
|
2070
|
+
const openNativeFolder$1 = async uri => {
|
|
2071
|
+
// @ts-ignore
|
|
2072
|
+
await invoke$1('OpenNativeFolder.openNativeFolder', uri);
|
|
2073
|
+
};
|
|
2074
|
+
const uninstallExtension$1 = async id => {
|
|
2075
|
+
return invoke$1('ExtensionManagement.uninstall', id);
|
|
2076
|
+
};
|
|
2077
|
+
const installExtension = async id => {
|
|
2078
|
+
// @ts-ignore
|
|
2079
|
+
return invoke$1('ExtensionManagement.install', id);
|
|
2080
|
+
};
|
|
2081
|
+
const openExtensionSearch$2 = async () => {
|
|
2082
|
+
// @ts-ignore
|
|
2083
|
+
return invoke$1('SideBar.openViewlet', 'Extensions');
|
|
2084
|
+
};
|
|
2085
|
+
const setExtensionsSearchValue$1 = async searchValue => {
|
|
2086
|
+
// @ts-ignore
|
|
2087
|
+
return invoke$1('Extensions.handleInput', searchValue);
|
|
2088
|
+
};
|
|
2089
|
+
const openExternal = async uri => {
|
|
2090
|
+
// @ts-ignore
|
|
2091
|
+
await invoke$1('Open.openExternal', uri);
|
|
2092
|
+
};
|
|
2093
|
+
const openUrl$2 = async uri => {
|
|
2094
|
+
// @ts-ignore
|
|
2095
|
+
await invoke$1('Open.openUrl', uri);
|
|
2096
|
+
};
|
|
2097
|
+
const getAllPreferences = async () => {
|
|
2098
|
+
// @ts-ignore
|
|
2099
|
+
return invoke$1('Preferences.getAll');
|
|
2100
|
+
};
|
|
2101
|
+
const showSaveFilePicker = async () => {
|
|
2102
|
+
// @ts-ignore
|
|
2103
|
+
return invoke$1('FilePicker.showSaveFilePicker');
|
|
2104
|
+
};
|
|
2105
|
+
const getLogsDir = async () => {
|
|
2106
|
+
// @ts-ignore
|
|
2107
|
+
return invoke$1('PlatformPaths.getLogsDir');
|
|
2108
|
+
};
|
|
2109
|
+
const registerMockRpc = commandMap => {
|
|
2110
|
+
const mockRpc = createMockRpc({
|
|
2111
|
+
commandMap
|
|
2112
|
+
});
|
|
2113
|
+
set$6(mockRpc);
|
|
2114
|
+
return mockRpc;
|
|
2115
|
+
};
|
|
2116
|
+
|
|
2117
|
+
const RendererWorker = {
|
|
2118
|
+
__proto__: null,
|
|
2119
|
+
activateByEvent,
|
|
2120
|
+
applyBulkReplacement,
|
|
2121
|
+
closeWidget,
|
|
2122
|
+
confirm,
|
|
2123
|
+
disableExtension: disableExtension$2,
|
|
2124
|
+
dispose: dispose$2,
|
|
2125
|
+
enableExtension: enableExtension$2,
|
|
2126
|
+
getActiveEditorId,
|
|
2127
|
+
getAllExtensions: getAllExtensions$2,
|
|
2128
|
+
getAllPreferences,
|
|
2129
|
+
getBlob,
|
|
2130
|
+
getChromeVersion,
|
|
2131
|
+
getColorThemeNames,
|
|
2132
|
+
getElectronVersion,
|
|
2133
|
+
getExtension: getExtension$3,
|
|
2134
|
+
getExtensionCommands,
|
|
2135
|
+
getFileHandles,
|
|
2136
|
+
getFileIcon,
|
|
2137
|
+
getFilePathElectron,
|
|
2138
|
+
getFolderIcon,
|
|
2139
|
+
getFolderSize: getFolderSize$1,
|
|
2140
|
+
getIcons,
|
|
2141
|
+
getKeyBindings,
|
|
2142
|
+
getLogsDir,
|
|
2143
|
+
getMarkdownDom,
|
|
2144
|
+
getNodeVersion,
|
|
2145
|
+
getPreference,
|
|
2146
|
+
getRecentlyOpened,
|
|
2147
|
+
getV8Version,
|
|
2148
|
+
getWebViewSecret,
|
|
2149
|
+
getWindowId,
|
|
2150
|
+
getWorkspacePath,
|
|
2151
|
+
handleDebugChange,
|
|
2152
|
+
handleDebugPaused,
|
|
2153
|
+
handleDebugResumed,
|
|
2154
|
+
handleDebugScriptParsed,
|
|
2155
|
+
installExtension,
|
|
2156
|
+
invoke: invoke$1,
|
|
2157
|
+
invokeAndTransfer,
|
|
2158
|
+
openExtensionSearch: openExtensionSearch$2,
|
|
2159
|
+
openExternal,
|
|
2160
|
+
openNativeFolder: openNativeFolder$1,
|
|
2161
|
+
openUri,
|
|
2162
|
+
openUrl: openUrl$2,
|
|
2163
|
+
openWidget,
|
|
2164
|
+
readFile: readFile$2,
|
|
2165
|
+
registerMockRpc,
|
|
2166
|
+
registerWebViewInterceptor,
|
|
2167
|
+
renderMarkdown: renderMarkdown$1,
|
|
2168
|
+
rerenderEditor,
|
|
2169
|
+
searchFileFetch,
|
|
2170
|
+
searchFileHtml,
|
|
2171
|
+
searchFileMemory,
|
|
2172
|
+
sendMessagePortToEditorWorker,
|
|
2173
|
+
sendMessagePortToErrorWorker,
|
|
2174
|
+
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$2,
|
|
2175
|
+
sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
|
|
2176
|
+
sendMessagePortToIconThemeWorker,
|
|
2177
|
+
sendMessagePortToMarkdownWorker: sendMessagePortToMarkdownWorker$2,
|
|
2178
|
+
sendMessagePortToRendererProcess,
|
|
2179
|
+
sendMessagePortToSearchProcess,
|
|
2180
|
+
sendMessagePortToSyntaxHighlightingWorker,
|
|
2181
|
+
set: set$6,
|
|
2182
|
+
setAdditionalFocus,
|
|
2183
|
+
setColorTheme: setColorTheme$2,
|
|
2184
|
+
setExtensionsSearchValue: setExtensionsSearchValue$1,
|
|
2185
|
+
setFocus,
|
|
2186
|
+
setWebViewPort,
|
|
2187
|
+
setWorkspacePath,
|
|
2188
|
+
showContextMenu: showContextMenu$1,
|
|
2189
|
+
showErrorDialog,
|
|
2190
|
+
showMessageBox,
|
|
2191
|
+
showSaveFilePicker,
|
|
2192
|
+
uninstallExtension: uninstallExtension$1,
|
|
2193
|
+
unregisterWebViewInterceptor,
|
|
2194
|
+
writeClipBoardImage: writeClipBoardImage$1,
|
|
2195
|
+
writeClipBoardText: writeClipBoardText$1
|
|
2196
|
+
};
|
|
2197
|
+
|
|
2198
|
+
const {
|
|
2199
|
+
set: set$5,
|
|
2200
|
+
getRuntimeStatus: getRuntimeStatus$1
|
|
2201
|
+
} = ExtensionHost;
|
|
2202
|
+
|
|
2203
|
+
const getRuntimeStatus = async extensionId => {
|
|
2204
|
+
// @ts-ignore
|
|
2205
|
+
const status = await getRuntimeStatus$1(extensionId);
|
|
2206
|
+
// @ts-ignore
|
|
2207
|
+
return status;
|
|
2208
|
+
};
|
|
2209
|
+
|
|
2210
|
+
const getRuntimeStatusDetails = async extension => {
|
|
2211
|
+
const {
|
|
2212
|
+
activationEvent,
|
|
2213
|
+
status,
|
|
2214
|
+
activationTime,
|
|
2215
|
+
importTime
|
|
2216
|
+
} = await getRuntimeStatus(extension.id);
|
|
2217
|
+
return {
|
|
2218
|
+
wasActivatedByEvent: activationEvent,
|
|
2219
|
+
activationTime,
|
|
2220
|
+
status,
|
|
2221
|
+
importTime
|
|
2222
|
+
};
|
|
2223
|
+
};
|
|
2224
|
+
|
|
2225
|
+
const featureRuntimeStatusEnabled = extension => {
|
|
2226
|
+
if (!extension || typeof extension !== 'object') {
|
|
2227
|
+
return false;
|
|
2292
2228
|
}
|
|
2293
|
-
if (
|
|
2294
|
-
|
|
2295
|
-
if (error.data) {
|
|
2296
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
2297
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
2298
|
-
} else if (error.data.stack) {
|
|
2299
|
-
restoredError.stack = error.data.stack;
|
|
2300
|
-
}
|
|
2301
|
-
if (error.data.codeFrame) {
|
|
2302
|
-
// @ts-ignore
|
|
2303
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
2304
|
-
}
|
|
2305
|
-
if (error.data.code) {
|
|
2306
|
-
// @ts-ignore
|
|
2307
|
-
restoredError.code = error.data.code;
|
|
2308
|
-
}
|
|
2309
|
-
if (error.data.type) {
|
|
2310
|
-
// @ts-ignore
|
|
2311
|
-
restoredError.name = error.data.type;
|
|
2312
|
-
}
|
|
2313
|
-
} else {
|
|
2314
|
-
if (error.stack) {
|
|
2315
|
-
const lowerStack = restoredError.stack || '';
|
|
2316
|
-
// @ts-ignore
|
|
2317
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
2318
|
-
const parentStack = getParentStack(error);
|
|
2319
|
-
// @ts-ignore
|
|
2320
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
2321
|
-
}
|
|
2322
|
-
if (error.codeFrame) {
|
|
2323
|
-
// @ts-ignore
|
|
2324
|
-
restoredError.codeFrame = error.codeFrame;
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
return restoredError;
|
|
2229
|
+
if ('main' in extension || 'browser' in extension) {
|
|
2230
|
+
return true;
|
|
2328
2231
|
}
|
|
2329
|
-
|
|
2330
|
-
|
|
2232
|
+
return false;
|
|
2233
|
+
};
|
|
2234
|
+
|
|
2235
|
+
const formatTime = time => {
|
|
2236
|
+
return time.toFixed(2) + 'ms';
|
|
2237
|
+
};
|
|
2238
|
+
|
|
2239
|
+
const getActivationTimeVirtualDom = (importTime$1, activationTime$1) => {
|
|
2240
|
+
if (!activationTime$1 && !importTime$1) {
|
|
2241
|
+
return [];
|
|
2331
2242
|
}
|
|
2332
|
-
|
|
2243
|
+
const formattedImportTime = formatTime(importTime$1);
|
|
2244
|
+
const formattedTime = formatTime(activationTime$1);
|
|
2245
|
+
return [{
|
|
2246
|
+
type: Dt,
|
|
2247
|
+
childCount: 1
|
|
2248
|
+
}, text(importTime()), {
|
|
2249
|
+
type: Dd,
|
|
2250
|
+
childCount: 1
|
|
2251
|
+
}, text(formattedImportTime), {
|
|
2252
|
+
type: Dt,
|
|
2253
|
+
childCount: 1
|
|
2254
|
+
}, text(activationTime()), {
|
|
2255
|
+
type: Dd,
|
|
2256
|
+
childCount: 1
|
|
2257
|
+
}, text(formattedTime)];
|
|
2333
2258
|
};
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2259
|
+
|
|
2260
|
+
const None$1 = 0;
|
|
2261
|
+
const Importing = 1;
|
|
2262
|
+
const Activating = 2;
|
|
2263
|
+
const Activated = 3;
|
|
2264
|
+
const Error$1 = 4;
|
|
2265
|
+
|
|
2266
|
+
const getStatusMessage = statusType => {
|
|
2267
|
+
switch (statusType) {
|
|
2268
|
+
case Activated:
|
|
2269
|
+
return 'activated';
|
|
2270
|
+
case None$1:
|
|
2271
|
+
return 'none';
|
|
2272
|
+
case Activating:
|
|
2273
|
+
return 'Activating';
|
|
2274
|
+
case Error$1:
|
|
2275
|
+
return 'error';
|
|
2276
|
+
case Importing:
|
|
2277
|
+
return 'importing';
|
|
2278
|
+
default:
|
|
2279
|
+
return 'unknown';
|
|
2338
2280
|
}
|
|
2339
|
-
|
|
2340
|
-
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2283
|
+
const key = {
|
|
2284
|
+
type: Dt,
|
|
2285
|
+
childCount: 1,
|
|
2286
|
+
className: 'RuntimeStatusDefinitionListKey'
|
|
2287
|
+
};
|
|
2288
|
+
const value = {
|
|
2289
|
+
type: Dd,
|
|
2290
|
+
className: 'RuntimeStatusDefinitionListValue',
|
|
2291
|
+
childCount: 1
|
|
2292
|
+
};
|
|
2293
|
+
const getStatusVirtualDom = status => {
|
|
2294
|
+
const statusString = getStatusMessage(status);
|
|
2295
|
+
return [key, text(`Status: `),
|
|
2296
|
+
// i18n
|
|
2297
|
+
value, text(`${statusString}`)];
|
|
2298
|
+
};
|
|
2299
|
+
|
|
2300
|
+
const getChildCount$1 = (status, activationTime, importTime) => {
|
|
2301
|
+
let childCount = 0;
|
|
2302
|
+
childCount += 2; // status
|
|
2303
|
+
if (importTime || activationTime) {
|
|
2304
|
+
childCount += 4;
|
|
2341
2305
|
}
|
|
2342
|
-
|
|
2306
|
+
return childCount;
|
|
2343
2307
|
};
|
|
2344
|
-
const
|
|
2345
|
-
|
|
2308
|
+
const getRuntimeStatusVirtualDom = state => {
|
|
2309
|
+
const {
|
|
2310
|
+
status,
|
|
2311
|
+
activationTime,
|
|
2312
|
+
importTime
|
|
2313
|
+
} = state;
|
|
2314
|
+
const heading = runtimeStatus();
|
|
2315
|
+
const childCount = getChildCount$1(status, activationTime, importTime);
|
|
2316
|
+
return [{
|
|
2317
|
+
type: Div,
|
|
2318
|
+
className: FeatureContent,
|
|
2319
|
+
childCount: 2
|
|
2320
|
+
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
2321
|
+
type: Dl,
|
|
2322
|
+
className: 'RuntimeStatusDefinitionList',
|
|
2323
|
+
childCount
|
|
2324
|
+
}, ...getStatusVirtualDom(status), ...getActivationTimeVirtualDom(activationTime, importTime)];
|
|
2346
2325
|
};
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2326
|
+
|
|
2327
|
+
const getSettingsTableEntry = setting => {
|
|
2328
|
+
const {
|
|
2329
|
+
id,
|
|
2330
|
+
label
|
|
2331
|
+
} = setting;
|
|
2332
|
+
// TODO watch out for null/undefined/number/string/array
|
|
2333
|
+
return [{
|
|
2334
|
+
type: Text,
|
|
2335
|
+
value: id
|
|
2336
|
+
}, {
|
|
2337
|
+
type: Text,
|
|
2338
|
+
value: label
|
|
2339
|
+
}];
|
|
2340
|
+
};
|
|
2341
|
+
|
|
2342
|
+
const getSettingsDetails = async extension => {
|
|
2343
|
+
const settings = extension.settings || [];
|
|
2344
|
+
const rows = settings.map(getSettingsTableEntry);
|
|
2345
|
+
return {
|
|
2346
|
+
settings: rows
|
|
2347
|
+
};
|
|
2348
|
+
};
|
|
2349
|
+
|
|
2350
|
+
const featureSettingsEnabled = extension => {
|
|
2351
|
+
if (!extension || typeof extension !== 'object' || !('settings' in extension)) {
|
|
2352
|
+
return false;
|
|
2353
2353
|
}
|
|
2354
|
-
|
|
2355
|
-
|
|
2354
|
+
return Array.isArray(extension.settings);
|
|
2355
|
+
};
|
|
2356
|
+
|
|
2357
|
+
const getSettingsTableEntries = rows => {
|
|
2358
|
+
const textId = id$1();
|
|
2359
|
+
const textLabel = label();
|
|
2360
|
+
return {
|
|
2361
|
+
headings: [textId, textLabel],
|
|
2362
|
+
rows
|
|
2363
|
+
};
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2366
|
+
const getFeatureSettingsVirtualDom = rows => {
|
|
2367
|
+
const heading = settings();
|
|
2368
|
+
const tableInfo = getSettingsTableEntries(rows);
|
|
2369
|
+
return [{
|
|
2370
|
+
type: Div,
|
|
2371
|
+
className: FeatureContent,
|
|
2372
|
+
childCount: 2
|
|
2373
|
+
}, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
const getSettingsVirtualDom = state => {
|
|
2377
|
+
return getFeatureSettingsVirtualDom(state.settings);
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2380
|
+
const HandleClickCategory = 'handleClickCategory';
|
|
2381
|
+
const HandleClickDisable = 'handleClickDisable';
|
|
2382
|
+
const HandleClickEnable = 'handleClickEnable';
|
|
2383
|
+
const HandleClickScrollToTop = 'handleClickScrollToTop';
|
|
2384
|
+
const HandleClickSetColorTheme = 'handleClickSetColorTheme';
|
|
2385
|
+
const HandleClickSettings = 'handleClickSettings';
|
|
2386
|
+
const HandleClickSize = 'handleClickSize';
|
|
2387
|
+
const HandleClickUninstall = 'handleClickUninstall';
|
|
2388
|
+
const HandleFeaturesClick = 'handleFeaturesClick';
|
|
2389
|
+
const HandleIconError = 'handleIconError';
|
|
2390
|
+
const HandleImageContextMenu = 'handleImageContextMenu';
|
|
2391
|
+
const HandleReadmeContextMenu = 'handleReadmeContextMenu';
|
|
2392
|
+
const HandleReadmeScroll = 'handleReadmeScroll';
|
|
2393
|
+
const HandleTabsClick = 'handleTabsClick';
|
|
2394
|
+
|
|
2395
|
+
const ActivationEvents = 'ActivationEvents';
|
|
2396
|
+
const Changelog = 'Changelog';
|
|
2397
|
+
const Commands = 'Commands';
|
|
2398
|
+
const Details = 'Details';
|
|
2399
|
+
const Enable = 'Enable';
|
|
2400
|
+
const Disable = 'Disable';
|
|
2401
|
+
const Features = 'Features';
|
|
2402
|
+
const JsonValidation = 'JsonValidation';
|
|
2403
|
+
const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
2404
|
+
const RuntimeStatus = 'RuntimeStatus';
|
|
2405
|
+
const ScrollToTop = 'scrolltotop';
|
|
2406
|
+
const SetColorTheme = 'SetColorTheme';
|
|
2407
|
+
const Settings = 'Settings';
|
|
2408
|
+
const Theme = 'Theme';
|
|
2409
|
+
const Uninstall = 'Uninstall';
|
|
2410
|
+
const WebViews = 'WebViews';
|
|
2411
|
+
|
|
2412
|
+
const getScrollToTopVirtualDom = scrollToTopButtonEnabled => {
|
|
2413
|
+
return [{
|
|
2414
|
+
type: Button$1,
|
|
2415
|
+
className: ScrollToTopButton,
|
|
2416
|
+
childCount: 1,
|
|
2417
|
+
onClick: HandleClickScrollToTop,
|
|
2418
|
+
ariaLabel: scrollToTop(),
|
|
2419
|
+
name: ScrollToTop
|
|
2420
|
+
}, {
|
|
2421
|
+
type: Div,
|
|
2422
|
+
className: 'MaskIcon MaskIconChevronUp',
|
|
2423
|
+
childCount: 0,
|
|
2424
|
+
role: None$2
|
|
2425
|
+
}];
|
|
2356
2426
|
};
|
|
2357
|
-
|
|
2358
|
-
const
|
|
2359
|
-
|
|
2360
|
-
|
|
2427
|
+
|
|
2428
|
+
const {
|
|
2429
|
+
set: set$4,
|
|
2430
|
+
getVirtualDom,
|
|
2431
|
+
render
|
|
2432
|
+
} = MarkdownWorker;
|
|
2433
|
+
|
|
2434
|
+
const getMarkdownVirtualDom = async (html, options) => {
|
|
2435
|
+
string(html);
|
|
2436
|
+
const dom = await getVirtualDom(html);
|
|
2437
|
+
if (options?.scrollToTopEnabled) {
|
|
2438
|
+
const [firstNode, ...rest] = dom;
|
|
2439
|
+
const extraDom = getScrollToTopVirtualDom();
|
|
2440
|
+
return [{
|
|
2441
|
+
...firstNode,
|
|
2442
|
+
onScroll: HandleReadmeScroll,
|
|
2443
|
+
childCount: firstNode.childCount + 1
|
|
2444
|
+
}, ...extraDom, ...rest];
|
|
2361
2445
|
}
|
|
2362
|
-
|
|
2363
|
-
|
|
2446
|
+
return dom;
|
|
2447
|
+
};
|
|
2448
|
+
|
|
2449
|
+
const getThemeItemMarkdown = (heading, items) => {
|
|
2450
|
+
let markdown = '';
|
|
2451
|
+
if (items.length > 0) {
|
|
2452
|
+
markdown += `### ${heading}`;
|
|
2453
|
+
markdown += '\n\n';
|
|
2454
|
+
for (const item of items) {
|
|
2455
|
+
markdown += `- ${item.label}`;
|
|
2456
|
+
markdown += '\n';
|
|
2457
|
+
}
|
|
2364
2458
|
}
|
|
2365
|
-
return
|
|
2459
|
+
return markdown;
|
|
2366
2460
|
};
|
|
2367
|
-
|
|
2368
|
-
|
|
2461
|
+
|
|
2462
|
+
const getColorThemeMarkdown = themes => {
|
|
2463
|
+
const heading = 'Color Themes';
|
|
2464
|
+
return getThemeItemMarkdown(heading, themes);
|
|
2369
2465
|
};
|
|
2370
|
-
const
|
|
2371
|
-
const
|
|
2372
|
-
|
|
2373
|
-
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
2374
|
-
return stackString.slice(newLineIndex + 1);
|
|
2375
|
-
}
|
|
2376
|
-
return stackString;
|
|
2466
|
+
const getIconThemeMarkdown = iconThemes => {
|
|
2467
|
+
const heading = 'File Icon Themes';
|
|
2468
|
+
return getThemeItemMarkdown(heading, iconThemes);
|
|
2377
2469
|
};
|
|
2378
|
-
const
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
code: MethodNotFound,
|
|
2382
|
-
message: error.message,
|
|
2383
|
-
data: error.stack
|
|
2384
|
-
};
|
|
2385
|
-
}
|
|
2386
|
-
return {
|
|
2387
|
-
code: Custom,
|
|
2388
|
-
message: prettyError.message,
|
|
2389
|
-
data: {
|
|
2390
|
-
stack: getStack(prettyError),
|
|
2391
|
-
codeFrame: prettyError.codeFrame,
|
|
2392
|
-
type: getErrorType(prettyError),
|
|
2393
|
-
code: prettyError.code,
|
|
2394
|
-
name: prettyError.name
|
|
2395
|
-
}
|
|
2396
|
-
};
|
|
2470
|
+
const getProductIconThemeMarkdown = iconThemes => {
|
|
2471
|
+
const heading = 'Product Icon Themes';
|
|
2472
|
+
return getThemeItemMarkdown(heading, iconThemes);
|
|
2397
2473
|
};
|
|
2398
|
-
const
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2474
|
+
const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
|
|
2475
|
+
let markdown = '';
|
|
2476
|
+
markdown += getColorThemeMarkdown(themes);
|
|
2477
|
+
markdown += getIconThemeMarkdown(iconThemes);
|
|
2478
|
+
markdown += getProductIconThemeMarkdown(productIconThemes);
|
|
2479
|
+
return markdown;
|
|
2404
2480
|
};
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
const
|
|
2409
|
-
|
|
2481
|
+
|
|
2482
|
+
const hash = async content => {
|
|
2483
|
+
const sourceBytes = new TextEncoder().encode(content);
|
|
2484
|
+
const digest = await crypto.subtle.digest('SHA-256', sourceBytes);
|
|
2485
|
+
const resultBytes = [...new Uint8Array(digest)];
|
|
2486
|
+
return resultBytes.map(x => x.toString(16).padStart(2, '0')).join('');
|
|
2410
2487
|
};
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2488
|
+
|
|
2489
|
+
// TODO pass application name from renderer worker to not hardcode it
|
|
2490
|
+
const bucketName = 'markdown-cache';
|
|
2491
|
+
const cachedCaches = Object.create(null);
|
|
2492
|
+
const noopCache = {
|
|
2493
|
+
async match() {
|
|
2494
|
+
return undefined;
|
|
2495
|
+
},
|
|
2496
|
+
async put() {}
|
|
2417
2497
|
};
|
|
2418
|
-
const
|
|
2419
|
-
|
|
2420
|
-
return
|
|
2498
|
+
const supportsStorageBuckets = () => {
|
|
2499
|
+
// @ts-ignore
|
|
2500
|
+
return Boolean(navigator.storageBuckets);
|
|
2421
2501
|
};
|
|
2422
|
-
const
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2502
|
+
const getCacheInternal = async cacheName => {
|
|
2503
|
+
if (!supportsStorageBuckets()) {
|
|
2504
|
+
return noopCache;
|
|
2505
|
+
}
|
|
2506
|
+
const twoWeeks = 14 * 24 * 60 * 60 * 1000;
|
|
2507
|
+
// @ts-ignore
|
|
2508
|
+
const bucket = await navigator.storageBuckets.open(bucketName, {
|
|
2509
|
+
quota: 20 * 1024 * 1024,
|
|
2510
|
+
// 20MB
|
|
2511
|
+
expires: Date.now() + twoWeeks
|
|
2512
|
+
});
|
|
2513
|
+
const cache = await bucket.caches.open(cacheName);
|
|
2514
|
+
return cache;
|
|
2515
|
+
};
|
|
2516
|
+
const getCache = cacheName => {
|
|
2517
|
+
if (!(cacheName in cachedCaches)) {
|
|
2518
|
+
cachedCaches[cacheName] = getCacheInternal(cacheName);
|
|
2519
|
+
}
|
|
2520
|
+
return cachedCaches[cacheName];
|
|
2521
|
+
};
|
|
2522
|
+
|
|
2523
|
+
// TODO pass application name from renderer worker to not hardcode it
|
|
2524
|
+
const cacheName = 'lvce-editor/markdown-cache';
|
|
2525
|
+
const has = async key => {
|
|
2526
|
+
const cache = await getCache(cacheName);
|
|
2527
|
+
const response = await cache.match(key);
|
|
2528
|
+
return Boolean(response);
|
|
2529
|
+
};
|
|
2530
|
+
const get$1 = async key => {
|
|
2531
|
+
const cache = await getCache(cacheName);
|
|
2532
|
+
const response = await cache.match(key);
|
|
2533
|
+
const text = await response?.text();
|
|
2534
|
+
return text || '';
|
|
2535
|
+
};
|
|
2536
|
+
const set$3 = async (key, value) => {
|
|
2537
|
+
const cache = await getCache(cacheName);
|
|
2538
|
+
await cache.put(key, new Response(value, {
|
|
2539
|
+
headers: {
|
|
2540
|
+
'Content-Type': 'application/markdown',
|
|
2541
|
+
'Content-Length': `${value.length}`
|
|
2431
2542
|
}
|
|
2432
|
-
};
|
|
2543
|
+
}));
|
|
2433
2544
|
};
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2545
|
+
|
|
2546
|
+
const renderMarkdownCached = async (markdown, options = {}) => {
|
|
2547
|
+
const markdownHash = await hash(markdown); // TODO hash options also
|
|
2548
|
+
const cacheKey = `/markdown/${markdownHash}`;
|
|
2549
|
+
const hasItem = await has(cacheKey);
|
|
2550
|
+
if (hasItem) {
|
|
2551
|
+
const value = await get$1(cacheKey);
|
|
2552
|
+
return value; // TODO validate if it's valid
|
|
2443
2553
|
}
|
|
2554
|
+
const html = await render(markdown, options);
|
|
2555
|
+
await set$3(cacheKey, html);
|
|
2556
|
+
return html;
|
|
2444
2557
|
};
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
// ignore
|
|
2450
|
-
};
|
|
2451
|
-
const defaultRequiresSocket = () => {
|
|
2452
|
-
return false;
|
|
2558
|
+
|
|
2559
|
+
const renderMarkdown = async (markdown, options = {}) => {
|
|
2560
|
+
const html = await renderMarkdownCached(markdown, options);
|
|
2561
|
+
return html;
|
|
2453
2562
|
};
|
|
2454
|
-
const defaultResolve = resolve;
|
|
2455
2563
|
|
|
2456
|
-
|
|
2457
|
-
const
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
2468
|
-
};
|
|
2469
|
-
}
|
|
2564
|
+
const getThemeDetails = async (extension, baseUrl) => {
|
|
2565
|
+
const {
|
|
2566
|
+
colorThemes,
|
|
2567
|
+
iconThemes,
|
|
2568
|
+
productIconThemes
|
|
2569
|
+
} = extension;
|
|
2570
|
+
const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
|
|
2571
|
+
const rendered = await renderMarkdown(markdown, {
|
|
2572
|
+
baseUrl
|
|
2573
|
+
});
|
|
2574
|
+
const themesMarkdownDom = await getMarkdownVirtualDom(rendered);
|
|
2470
2575
|
return {
|
|
2471
|
-
|
|
2472
|
-
message: args[1],
|
|
2473
|
-
execute: args[2],
|
|
2474
|
-
resolve: args[3],
|
|
2475
|
-
preparePrettyError: args[4],
|
|
2476
|
-
logError: args[5],
|
|
2477
|
-
requiresSocket: args[6]
|
|
2576
|
+
themesMarkdownDom
|
|
2478
2577
|
};
|
|
2479
2578
|
};
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
ipc,
|
|
2485
|
-
execute,
|
|
2486
|
-
resolve,
|
|
2487
|
-
preparePrettyError,
|
|
2488
|
-
logError,
|
|
2489
|
-
requiresSocket
|
|
2490
|
-
} = options;
|
|
2491
|
-
if ('id' in message) {
|
|
2492
|
-
if ('method' in message) {
|
|
2493
|
-
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
2494
|
-
try {
|
|
2495
|
-
ipc.send(response);
|
|
2496
|
-
} catch (error) {
|
|
2497
|
-
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2498
|
-
ipc.send(errorResponse);
|
|
2499
|
-
}
|
|
2500
|
-
return;
|
|
2501
|
-
}
|
|
2502
|
-
resolve(message.id, message);
|
|
2503
|
-
return;
|
|
2504
|
-
}
|
|
2505
|
-
if ('method' in message) {
|
|
2506
|
-
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
2507
|
-
return;
|
|
2579
|
+
|
|
2580
|
+
const featureColorThemeEnabled = extension => {
|
|
2581
|
+
if (!extension || typeof extension !== 'object' || !('colorThemes' in extension)) {
|
|
2582
|
+
return false;
|
|
2508
2583
|
}
|
|
2509
|
-
|
|
2584
|
+
return Array.isArray(extension.colorThemes);
|
|
2510
2585
|
};
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
} = create$2$1(method, params);
|
|
2516
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
2517
|
-
ipc.sendAndTransfer(message);
|
|
2518
|
-
} else {
|
|
2519
|
-
ipc.send(message);
|
|
2586
|
+
|
|
2587
|
+
const featureIconThemeEnabled = extension => {
|
|
2588
|
+
if (!extension || typeof extension !== 'object' || !('iconThemes' in extension)) {
|
|
2589
|
+
return false;
|
|
2520
2590
|
}
|
|
2521
|
-
|
|
2522
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
2523
|
-
};
|
|
2524
|
-
const send = (transport, method, ...params) => {
|
|
2525
|
-
const message = create$4(method, params);
|
|
2526
|
-
transport.send(message);
|
|
2527
|
-
};
|
|
2528
|
-
const invoke$1 = (ipc, method, ...params) => {
|
|
2529
|
-
return invokeHelper(ipc, method, params, false);
|
|
2530
|
-
};
|
|
2531
|
-
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
2532
|
-
return invokeHelper(ipc, method, params, true);
|
|
2591
|
+
return Array.isArray(extension.iconThemes);
|
|
2533
2592
|
};
|
|
2534
2593
|
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
this.name = 'CommandNotFoundError';
|
|
2594
|
+
const featureProductIconThemeEnabled = extension => {
|
|
2595
|
+
if (!extension || typeof extension !== 'object' || !('productIconThemes' in extension)) {
|
|
2596
|
+
return false;
|
|
2539
2597
|
}
|
|
2540
|
-
|
|
2541
|
-
const commands = Object.create(null);
|
|
2542
|
-
const register = commandMap => {
|
|
2543
|
-
Object.assign(commands, commandMap);
|
|
2598
|
+
return Array.isArray(extension.productIconThemes);
|
|
2544
2599
|
};
|
|
2545
|
-
|
|
2546
|
-
|
|
2600
|
+
|
|
2601
|
+
const featureThemeEnabled = extension => {
|
|
2602
|
+
return featureColorThemeEnabled(extension) || featureIconThemeEnabled(extension) || featureProductIconThemeEnabled(extension);
|
|
2547
2603
|
};
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2604
|
+
|
|
2605
|
+
const getVirtualDomChildCount = dom => {
|
|
2606
|
+
const max = dom.length - 1;
|
|
2607
|
+
let stack = [];
|
|
2608
|
+
for (let i = max; i >= 0; i--) {
|
|
2609
|
+
const element = dom[i];
|
|
2610
|
+
if (element.childCount > 0) {
|
|
2611
|
+
stack = stack.slice(element.childCount);
|
|
2612
|
+
}
|
|
2613
|
+
stack.unshift(element);
|
|
2552
2614
|
}
|
|
2553
|
-
return
|
|
2615
|
+
return stack.length;
|
|
2554
2616
|
};
|
|
2555
2617
|
|
|
2556
|
-
const
|
|
2557
|
-
const
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
},
|
|
2569
|
-
invokeAndTransfer(method, ...params) {
|
|
2570
|
-
return invokeAndTransfer(ipc, method, ...params);
|
|
2571
|
-
},
|
|
2572
|
-
async dispose() {
|
|
2573
|
-
await ipc?.dispose();
|
|
2574
|
-
}
|
|
2575
|
-
};
|
|
2576
|
-
return rpc;
|
|
2618
|
+
const getFeatureThemesVirtualDom = themesDom => {
|
|
2619
|
+
const childCount = getVirtualDomChildCount(themesDom);
|
|
2620
|
+
const heading = theme();
|
|
2621
|
+
return [{
|
|
2622
|
+
type: Div,
|
|
2623
|
+
className: FeatureContent,
|
|
2624
|
+
childCount: 2
|
|
2625
|
+
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
2626
|
+
type: Div,
|
|
2627
|
+
className: DefaultMarkdown,
|
|
2628
|
+
childCount
|
|
2629
|
+
}, ...themesDom];
|
|
2577
2630
|
};
|
|
2578
|
-
|
|
2579
|
-
|
|
2631
|
+
|
|
2632
|
+
const getThemeVirtualDom = state => {
|
|
2633
|
+
return getFeatureThemesVirtualDom(state.themesMarkdownDom);
|
|
2580
2634
|
};
|
|
2581
|
-
|
|
2582
|
-
|
|
2635
|
+
|
|
2636
|
+
const toWebView = rawWebView => {
|
|
2637
|
+
const {
|
|
2638
|
+
id,
|
|
2639
|
+
selector,
|
|
2640
|
+
contentSecurityPolicy,
|
|
2641
|
+
elements
|
|
2642
|
+
} = rawWebView;
|
|
2643
|
+
return {
|
|
2644
|
+
id,
|
|
2645
|
+
selectorString: JSON.stringify(selector),
|
|
2646
|
+
contentSecurityPolicyString: JSON.stringify(contentSecurityPolicy),
|
|
2647
|
+
elementsString: JSON.stringify(elements, null, 2)
|
|
2648
|
+
};
|
|
2583
2649
|
};
|
|
2584
|
-
|
|
2585
|
-
|
|
2650
|
+
|
|
2651
|
+
const getWebViews = extension => {
|
|
2652
|
+
const rawWebViews = extension.webViews || [];
|
|
2653
|
+
return rawWebViews.map(toWebView);
|
|
2586
2654
|
};
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
const
|
|
2590
|
-
return
|
|
2655
|
+
|
|
2656
|
+
const getWebViewsDetails = async extension => {
|
|
2657
|
+
const webViews = getWebViews(extension);
|
|
2658
|
+
return {
|
|
2659
|
+
webViews
|
|
2660
|
+
};
|
|
2591
2661
|
};
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
// deprecated
|
|
2597
|
-
ipc.on('message', handleMessage);
|
|
2662
|
+
|
|
2663
|
+
const featureWebViewsEnabled = extension => {
|
|
2664
|
+
if (!extension || typeof extension !== 'object' || !('webViews' in extension)) {
|
|
2665
|
+
return false;
|
|
2598
2666
|
}
|
|
2667
|
+
return Array.isArray(extension.webViews);
|
|
2599
2668
|
};
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
const ipc = module.wrap(rawIpc);
|
|
2606
|
-
return ipc;
|
|
2669
|
+
|
|
2670
|
+
const heading = {
|
|
2671
|
+
type: H2,
|
|
2672
|
+
className: DefinitionListItemHeading,
|
|
2673
|
+
childCount: 1
|
|
2607
2674
|
};
|
|
2608
|
-
const
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
// TODO create a commandMap per rpc instance
|
|
2613
|
-
register(commandMap);
|
|
2614
|
-
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2615
|
-
messagePort,
|
|
2616
|
-
isMessagePortOpen: true
|
|
2617
|
-
});
|
|
2618
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2619
|
-
handleIpc(ipc);
|
|
2620
|
-
const rpc = createRpc(ipc);
|
|
2621
|
-
messagePort.start();
|
|
2622
|
-
return rpc;
|
|
2675
|
+
const pre = {
|
|
2676
|
+
type: Pre,
|
|
2677
|
+
className: DefinitionListItemValue,
|
|
2678
|
+
childCount: 1
|
|
2623
2679
|
};
|
|
2624
|
-
const
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2680
|
+
const item = {
|
|
2681
|
+
type: Div,
|
|
2682
|
+
className: DefinitionListItem,
|
|
2683
|
+
childCount: 2
|
|
2684
|
+
};
|
|
2685
|
+
const getWebViewVirtualDom = webView => {
|
|
2628
2686
|
const {
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2687
|
+
id,
|
|
2688
|
+
selectorString,
|
|
2689
|
+
contentSecurityPolicyString,
|
|
2690
|
+
elementsString
|
|
2691
|
+
} = webView;
|
|
2692
|
+
const textId = id$1();
|
|
2693
|
+
const textSelector = selector();
|
|
2694
|
+
const textContentSecurityPolicy = contentSecurityPolicy();
|
|
2695
|
+
const textElements = elements();
|
|
2696
|
+
return [{
|
|
2697
|
+
type: Div,
|
|
2698
|
+
className: FeatureWebView,
|
|
2699
|
+
childCount: 5
|
|
2700
|
+
}, item, heading, text(textId), pre, text(id), item, heading, text(textSelector), pre, text(selectorString), item, heading, text(textContentSecurityPolicy), pre, text(contentSecurityPolicyString), item, heading, text(textElements), pre, text(elementsString)];
|
|
2637
2701
|
};
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2702
|
+
|
|
2703
|
+
const getFeatureWebViewsVirtualDom = webViews$1 => {
|
|
2704
|
+
const heading = webViews();
|
|
2705
|
+
return [{
|
|
2706
|
+
type: Div,
|
|
2707
|
+
className: FeatureContent,
|
|
2708
|
+
childCount: 2
|
|
2709
|
+
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
2710
|
+
type: Div,
|
|
2711
|
+
childCount: webViews$1.length
|
|
2712
|
+
}, ...webViews$1.flatMap(getWebViewVirtualDom)];
|
|
2641
2713
|
};
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
// TODO create a commandMap per rpc instance
|
|
2646
|
-
register(commandMap);
|
|
2647
|
-
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
2648
|
-
handleIpc(ipc);
|
|
2649
|
-
const rpc = createRpc(ipc);
|
|
2650
|
-
return rpc;
|
|
2714
|
+
|
|
2715
|
+
const getWebViewsVirtualDom = state => {
|
|
2716
|
+
return getFeatureWebViewsVirtualDom(state.webViews);
|
|
2651
2717
|
};
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2718
|
+
|
|
2719
|
+
const registerAllFeatures = () => {
|
|
2720
|
+
register$1({
|
|
2721
|
+
id: Theme,
|
|
2722
|
+
getLabel: theme,
|
|
2723
|
+
isEnabled: featureThemeEnabled,
|
|
2724
|
+
getDetails: getThemeDetails,
|
|
2725
|
+
getVirtualDom: getThemeVirtualDom
|
|
2726
|
+
});
|
|
2727
|
+
register$1({
|
|
2728
|
+
id: Commands,
|
|
2729
|
+
getLabel: commands$1,
|
|
2730
|
+
isEnabled: featureCommandsEnabled,
|
|
2731
|
+
getDetails: getCommandsDetails,
|
|
2732
|
+
getVirtualDom: getCommandsVirtualDom
|
|
2733
|
+
});
|
|
2734
|
+
register$1({
|
|
2735
|
+
id: Settings,
|
|
2736
|
+
getLabel: settings,
|
|
2737
|
+
isEnabled: featureSettingsEnabled,
|
|
2738
|
+
getDetails: getSettingsDetails,
|
|
2739
|
+
getVirtualDom: getSettingsVirtualDom
|
|
2740
|
+
});
|
|
2741
|
+
register$1({
|
|
2742
|
+
id: JsonValidation,
|
|
2743
|
+
getLabel: jsonValidation,
|
|
2744
|
+
isEnabled: featureJsonValidationEnabled,
|
|
2745
|
+
getDetails: getJsonValidationDetails,
|
|
2746
|
+
getVirtualDom: getJsonValidationVirtualDom
|
|
2747
|
+
});
|
|
2748
|
+
register$1({
|
|
2749
|
+
id: ProgrammingLanguages,
|
|
2750
|
+
getLabel: programmingLanguages,
|
|
2751
|
+
isEnabled: featureProgrammingLanguagesEnabled,
|
|
2752
|
+
getDetails: getProgrammingLanguagesDetails,
|
|
2753
|
+
getVirtualDom: getProgrammingLanguagesVirtualDom
|
|
2754
|
+
});
|
|
2755
|
+
register$1({
|
|
2756
|
+
id: WebViews,
|
|
2757
|
+
getLabel: webViews,
|
|
2758
|
+
isEnabled: featureWebViewsEnabled,
|
|
2759
|
+
getDetails: getWebViewsDetails,
|
|
2760
|
+
getVirtualDom: getWebViewsVirtualDom
|
|
2761
|
+
});
|
|
2762
|
+
register$1({
|
|
2763
|
+
id: ActivationEvents,
|
|
2764
|
+
getLabel: activationEvents,
|
|
2765
|
+
isEnabled: featureActivationEventsEnabled,
|
|
2766
|
+
getDetails: getActivationEventsDetails,
|
|
2767
|
+
getVirtualDom: getActivationEventsVirtualDom
|
|
2768
|
+
});
|
|
2769
|
+
register$1({
|
|
2770
|
+
id: RuntimeStatus,
|
|
2771
|
+
getLabel: runtimeStatus,
|
|
2772
|
+
isEnabled: featureRuntimeStatusEnabled,
|
|
2773
|
+
getDetails: getRuntimeStatusDetails,
|
|
2774
|
+
getVirtualDom: getRuntimeStatusVirtualDom
|
|
2775
|
+
});
|
|
2655
2776
|
};
|
|
2656
2777
|
|
|
2657
2778
|
const toCommandId = key => {
|
|
@@ -2740,6 +2861,7 @@ const terminate = () => {
|
|
|
2740
2861
|
|
|
2741
2862
|
const {
|
|
2742
2863
|
disableExtension: disableExtension$1,
|
|
2864
|
+
enableExtension: enableExtension$1,
|
|
2743
2865
|
getAllExtensions: getAllExtensions$1,
|
|
2744
2866
|
getExtension: getExtension$2,
|
|
2745
2867
|
openExtensionSearch: openExtensionSearch$1,
|
|
@@ -3095,6 +3217,14 @@ const handleClickDisable = async state => {
|
|
|
3095
3217
|
return updateExtensionStatus(state, disableExtension);
|
|
3096
3218
|
};
|
|
3097
3219
|
|
|
3220
|
+
const enableExtension = id => {
|
|
3221
|
+
return enableExtension$1(id);
|
|
3222
|
+
};
|
|
3223
|
+
|
|
3224
|
+
const handleClickEnable = async state => {
|
|
3225
|
+
return updateExtensionStatus(state, enableExtension);
|
|
3226
|
+
};
|
|
3227
|
+
|
|
3098
3228
|
const selectFeature = async (state, name) => {
|
|
3099
3229
|
if (!name) {
|
|
3100
3230
|
return state;
|
|
@@ -3250,7 +3380,6 @@ const isEnoentError = error => {
|
|
|
3250
3380
|
return error && error.code === ENOENT;
|
|
3251
3381
|
};
|
|
3252
3382
|
|
|
3253
|
-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
3254
3383
|
const error = async error => {
|
|
3255
3384
|
// TODO send message to error worker or log worker
|
|
3256
3385
|
// @ts-ignore
|
|
@@ -3459,6 +3588,7 @@ const initializeMarkdownWorker = async () => {
|
|
|
3459
3588
|
};
|
|
3460
3589
|
|
|
3461
3590
|
const initialize = async () => {
|
|
3591
|
+
// TODO load markdown worker only when needed
|
|
3462
3592
|
await Promise.all([initializeMarkdownWorker(), initializeFileSystemWorker(), initializeExtensionHostWorker()]);
|
|
3463
3593
|
};
|
|
3464
3594
|
|
|
@@ -3711,7 +3841,7 @@ const log10 = numberOrBigInt => {
|
|
|
3711
3841
|
return Math.log10(numberOrBigInt);
|
|
3712
3842
|
}
|
|
3713
3843
|
const string = numberOrBigInt.toString(10);
|
|
3714
|
-
return string.length + Math.log10(
|
|
3844
|
+
return string.length + Math.log10(`0.${string.slice(0, 15)}`);
|
|
3715
3845
|
};
|
|
3716
3846
|
const log = numberOrBigInt => {
|
|
3717
3847
|
if (typeof numberOrBigInt === 'number') {
|
|
@@ -3727,6 +3857,36 @@ const divide = (numberOrBigInt, divisor) => {
|
|
|
3727
3857
|
const remainder = numberOrBigInt % BigInt(divisor);
|
|
3728
3858
|
return Number(integerPart) + Number(remainder) / divisor;
|
|
3729
3859
|
};
|
|
3860
|
+
const applyFixedWidth = (result, fixedWidth) => {
|
|
3861
|
+
if (fixedWidth === undefined) {
|
|
3862
|
+
return result;
|
|
3863
|
+
}
|
|
3864
|
+
if (typeof fixedWidth !== 'number' || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) {
|
|
3865
|
+
throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
|
|
3866
|
+
}
|
|
3867
|
+
if (fixedWidth === 0) {
|
|
3868
|
+
return result;
|
|
3869
|
+
}
|
|
3870
|
+
return result.length < fixedWidth ? result.padStart(fixedWidth, ' ') : result;
|
|
3871
|
+
};
|
|
3872
|
+
const buildLocaleOptions = options => {
|
|
3873
|
+
const {
|
|
3874
|
+
minimumFractionDigits,
|
|
3875
|
+
maximumFractionDigits
|
|
3876
|
+
} = options;
|
|
3877
|
+
if (minimumFractionDigits === undefined && maximumFractionDigits === undefined) {
|
|
3878
|
+
return undefined;
|
|
3879
|
+
}
|
|
3880
|
+
return {
|
|
3881
|
+
...(minimumFractionDigits !== undefined && {
|
|
3882
|
+
minimumFractionDigits
|
|
3883
|
+
}),
|
|
3884
|
+
...(maximumFractionDigits !== undefined && {
|
|
3885
|
+
maximumFractionDigits
|
|
3886
|
+
}),
|
|
3887
|
+
roundingMode: 'trunc'
|
|
3888
|
+
};
|
|
3889
|
+
};
|
|
3730
3890
|
function prettyBytes(number, options) {
|
|
3731
3891
|
if (typeof number !== 'bigint' && !Number.isFinite(number)) {
|
|
3732
3892
|
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
@@ -3735,43 +3895,40 @@ function prettyBytes(number, options) {
|
|
|
3735
3895
|
bits: false,
|
|
3736
3896
|
binary: false,
|
|
3737
3897
|
space: true,
|
|
3898
|
+
nonBreakingSpace: false,
|
|
3738
3899
|
...options
|
|
3739
3900
|
};
|
|
3740
3901
|
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
3741
|
-
const separator = options.space ? ' ' : '';
|
|
3742
|
-
|
|
3743
|
-
|
|
3902
|
+
const separator = options.space ? options.nonBreakingSpace ? '\u00A0' : ' ' : '';
|
|
3903
|
+
|
|
3904
|
+
// Handle signed zero case
|
|
3905
|
+
const isZero = typeof number === 'number' ? number === 0 : number === 0n;
|
|
3906
|
+
if (options.signed && isZero) {
|
|
3907
|
+
const result = ` 0${separator}${UNITS[0]}`;
|
|
3908
|
+
return applyFixedWidth(result, options.fixedWidth);
|
|
3744
3909
|
}
|
|
3745
3910
|
const isNegative = number < 0;
|
|
3746
3911
|
const prefix = isNegative ? '-' : options.signed ? '+' : '';
|
|
3747
3912
|
if (isNegative) {
|
|
3748
3913
|
number = -number;
|
|
3749
3914
|
}
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
localeOptions = {
|
|
3753
|
-
minimumFractionDigits: options.minimumFractionDigits
|
|
3754
|
-
};
|
|
3755
|
-
}
|
|
3756
|
-
if (options.maximumFractionDigits !== undefined) {
|
|
3757
|
-
localeOptions = {
|
|
3758
|
-
maximumFractionDigits: options.maximumFractionDigits,
|
|
3759
|
-
...localeOptions
|
|
3760
|
-
};
|
|
3761
|
-
}
|
|
3915
|
+
const localeOptions = buildLocaleOptions(options);
|
|
3916
|
+
let result;
|
|
3762
3917
|
if (number < 1) {
|
|
3763
3918
|
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
3764
|
-
|
|
3765
|
-
}
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3919
|
+
result = prefix + numberString + separator + UNITS[0];
|
|
3920
|
+
} else {
|
|
3921
|
+
const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
|
|
3922
|
+
number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
|
|
3923
|
+
if (!localeOptions) {
|
|
3924
|
+
const minPrecision = Math.max(3, Math.floor(number).toString().length);
|
|
3925
|
+
number = number.toPrecision(minPrecision);
|
|
3926
|
+
}
|
|
3927
|
+
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
3928
|
+
const unit = UNITS[exponent];
|
|
3929
|
+
result = prefix + numberString + separator + unit;
|
|
3771
3930
|
}
|
|
3772
|
-
|
|
3773
|
-
const unit = UNITS[exponent];
|
|
3774
|
-
return prefix + numberString + separator + unit;
|
|
3931
|
+
return applyFixedWidth(result, options.fixedWidth);
|
|
3775
3932
|
}
|
|
3776
3933
|
|
|
3777
3934
|
const getDisplaySize = size => {
|
|
@@ -4645,6 +4802,7 @@ const commandMap = {
|
|
|
4645
4802
|
'ExtensionDetail.getMenus': getMenus,
|
|
4646
4803
|
'ExtensionDetail.handleClickCategory': wrapCommand(handleClickCategory),
|
|
4647
4804
|
'ExtensionDetail.handleClickDisable': wrapCommand(handleClickDisable),
|
|
4805
|
+
'ExtensionDetail.handleClickEnable': wrapCommand(handleClickEnable),
|
|
4648
4806
|
'ExtensionDetail.handleClickScrollToTop': wrapCommand(handleClickScrollToTop),
|
|
4649
4807
|
'ExtensionDetail.handleClickSetColorTheme': wrapCommand(handleClickSetColorTheme),
|
|
4650
4808
|
'ExtensionDetail.handleClickSettings': wrapCommand(handleClickSettings),
|