@lvce-editor/extension-detail-view 3.21.0 → 3.23.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.
|
@@ -60,31 +60,39 @@ class AssertionError extends Error {
|
|
|
60
60
|
this.name = 'AssertionError';
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
const Object$1 = 1;
|
|
64
|
+
const Number$1 = 2;
|
|
65
|
+
const Array$1 = 3;
|
|
66
|
+
const String = 4;
|
|
67
|
+
const Boolean$1 = 5;
|
|
68
|
+
const Function = 6;
|
|
69
|
+
const Null = 7;
|
|
70
|
+
const Unknown = 8;
|
|
63
71
|
const getType = value => {
|
|
64
72
|
switch (typeof value) {
|
|
65
73
|
case 'number':
|
|
66
|
-
return
|
|
74
|
+
return Number$1;
|
|
67
75
|
case 'function':
|
|
68
|
-
return
|
|
76
|
+
return Function;
|
|
69
77
|
case 'string':
|
|
70
|
-
return
|
|
78
|
+
return String;
|
|
71
79
|
case 'object':
|
|
72
80
|
if (value === null) {
|
|
73
|
-
return
|
|
81
|
+
return Null;
|
|
74
82
|
}
|
|
75
83
|
if (Array.isArray(value)) {
|
|
76
|
-
return
|
|
84
|
+
return Array$1;
|
|
77
85
|
}
|
|
78
|
-
return
|
|
86
|
+
return Object$1;
|
|
79
87
|
case 'boolean':
|
|
80
|
-
return
|
|
88
|
+
return Boolean$1;
|
|
81
89
|
default:
|
|
82
|
-
return
|
|
90
|
+
return Unknown;
|
|
83
91
|
}
|
|
84
92
|
};
|
|
85
93
|
const string = value => {
|
|
86
94
|
const type = getType(value);
|
|
87
|
-
if (type !==
|
|
95
|
+
if (type !== String) {
|
|
88
96
|
throw new AssertionError('expected value to be of type string');
|
|
89
97
|
}
|
|
90
98
|
};
|
|
@@ -338,22 +346,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
338
346
|
const wrap$f = global => {
|
|
339
347
|
return new IpcChildWithModuleWorker(global);
|
|
340
348
|
};
|
|
341
|
-
const withResolvers = () => {
|
|
342
|
-
let _resolve;
|
|
343
|
-
const promise = new Promise(resolve => {
|
|
344
|
-
_resolve = resolve;
|
|
345
|
-
});
|
|
346
|
-
return {
|
|
347
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
348
|
-
resolve: _resolve,
|
|
349
|
-
promise
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
349
|
const waitForFirstMessage = async port => {
|
|
353
350
|
const {
|
|
354
351
|
resolve,
|
|
355
352
|
promise
|
|
356
|
-
} = withResolvers();
|
|
353
|
+
} = Promise.withResolvers();
|
|
357
354
|
port.addEventListener('message', resolve, {
|
|
358
355
|
once: true
|
|
359
356
|
});
|
|
@@ -434,11 +431,11 @@ const remove = id => {
|
|
|
434
431
|
delete callbacks[id];
|
|
435
432
|
};
|
|
436
433
|
let id$1 = 0;
|
|
437
|
-
const create$3 = () => {
|
|
434
|
+
const create$3$1 = () => {
|
|
438
435
|
return ++id$1;
|
|
439
436
|
};
|
|
440
437
|
const registerPromise = () => {
|
|
441
|
-
const id = create$3();
|
|
438
|
+
const id = create$3$1();
|
|
442
439
|
const {
|
|
443
440
|
resolve,
|
|
444
441
|
promise
|
|
@@ -516,6 +513,16 @@ const constructError = (message, type, name) => {
|
|
|
516
513
|
}
|
|
517
514
|
return new ErrorConstructor(message);
|
|
518
515
|
};
|
|
516
|
+
const joinLines = lines => {
|
|
517
|
+
return lines.join(NewLine);
|
|
518
|
+
};
|
|
519
|
+
const splitLines = lines => {
|
|
520
|
+
return lines.split(NewLine);
|
|
521
|
+
};
|
|
522
|
+
const getCurrentStack = () => {
|
|
523
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
524
|
+
return currentStack;
|
|
525
|
+
};
|
|
519
526
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
520
527
|
return string.indexOf(NewLine, startIndex);
|
|
521
528
|
};
|
|
@@ -526,19 +533,16 @@ const getParentStack = error => {
|
|
|
526
533
|
}
|
|
527
534
|
return parentStack;
|
|
528
535
|
};
|
|
529
|
-
const joinLines = lines => {
|
|
530
|
-
return lines.join(NewLine);
|
|
531
|
-
};
|
|
532
536
|
const MethodNotFound = -32601;
|
|
533
537
|
const Custom = -32001;
|
|
534
|
-
const splitLines = lines => {
|
|
535
|
-
return lines.split(NewLine);
|
|
536
|
-
};
|
|
537
538
|
const restoreJsonRpcError = error => {
|
|
539
|
+
const currentStack = getCurrentStack();
|
|
538
540
|
if (error && error instanceof Error) {
|
|
541
|
+
if (typeof error.stack === 'string') {
|
|
542
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
543
|
+
}
|
|
539
544
|
return error;
|
|
540
545
|
}
|
|
541
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
|
|
542
546
|
if (error && error.code && error.code === MethodNotFound) {
|
|
543
547
|
const restoredError = new JsonRpcError(error.message);
|
|
544
548
|
const parentStack = getParentStack(error);
|
|
@@ -619,6 +623,17 @@ const getErrorType = prettyError => {
|
|
|
619
623
|
}
|
|
620
624
|
return undefined;
|
|
621
625
|
};
|
|
626
|
+
const isAlreadyStack = line => {
|
|
627
|
+
return line.trim().startsWith('at ');
|
|
628
|
+
};
|
|
629
|
+
const getStack = prettyError => {
|
|
630
|
+
const stackString = prettyError.stack || '';
|
|
631
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
632
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
633
|
+
return stackString.slice(newLineIndex + 1);
|
|
634
|
+
}
|
|
635
|
+
return stackString;
|
|
636
|
+
};
|
|
622
637
|
const getErrorProperty = (error, prettyError) => {
|
|
623
638
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
624
639
|
return {
|
|
@@ -631,7 +646,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
631
646
|
code: Custom,
|
|
632
647
|
message: prettyError.message,
|
|
633
648
|
data: {
|
|
634
|
-
stack: prettyError
|
|
649
|
+
stack: getStack(prettyError),
|
|
635
650
|
codeFrame: prettyError.codeFrame,
|
|
636
651
|
type: getErrorType(prettyError),
|
|
637
652
|
code: prettyError.code,
|
|
@@ -639,18 +654,18 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
639
654
|
}
|
|
640
655
|
};
|
|
641
656
|
};
|
|
642
|
-
const create$1$1 = (
|
|
657
|
+
const create$1$1 = (id, error) => {
|
|
643
658
|
return {
|
|
644
659
|
jsonrpc: Two,
|
|
645
|
-
id
|
|
660
|
+
id,
|
|
646
661
|
error
|
|
647
662
|
};
|
|
648
663
|
};
|
|
649
|
-
const getErrorResponse = (
|
|
664
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
650
665
|
const prettyError = preparePrettyError(error);
|
|
651
666
|
logError(error, prettyError);
|
|
652
667
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
653
|
-
return create$1$1(
|
|
668
|
+
return create$1$1(id, errorProperty);
|
|
654
669
|
};
|
|
655
670
|
const create$5 = (message, result) => {
|
|
656
671
|
return {
|
|
@@ -663,12 +678,27 @@ const getSuccessResponse = (message, result) => {
|
|
|
663
678
|
const resultProperty = result ?? null;
|
|
664
679
|
return create$5(message, resultProperty);
|
|
665
680
|
};
|
|
681
|
+
const getErrorResponseSimple = (id, error) => {
|
|
682
|
+
return {
|
|
683
|
+
jsonrpc: Two,
|
|
684
|
+
id,
|
|
685
|
+
error: {
|
|
686
|
+
code: Custom,
|
|
687
|
+
// @ts-ignore
|
|
688
|
+
message: error.message,
|
|
689
|
+
data: error
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
};
|
|
666
693
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
667
694
|
try {
|
|
668
695
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
669
696
|
return getSuccessResponse(message, result);
|
|
670
697
|
} catch (error) {
|
|
671
|
-
|
|
698
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
699
|
+
return getErrorResponseSimple(message.id, error);
|
|
700
|
+
}
|
|
701
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
672
702
|
}
|
|
673
703
|
};
|
|
674
704
|
const defaultPreparePrettyError = error => {
|
|
@@ -723,7 +753,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
723
753
|
try {
|
|
724
754
|
ipc.send(response);
|
|
725
755
|
} catch (error) {
|
|
726
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
756
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
727
757
|
ipc.send(errorResponse);
|
|
728
758
|
}
|
|
729
759
|
return;
|
|
@@ -828,7 +858,7 @@ const listen$1 = async (module, options) => {
|
|
|
828
858
|
const ipc = module.wrap(rawIpc);
|
|
829
859
|
return ipc;
|
|
830
860
|
};
|
|
831
|
-
const create$
|
|
861
|
+
const create$3 = async ({
|
|
832
862
|
commandMap
|
|
833
863
|
}) => {
|
|
834
864
|
// TODO create a commandMap per rpc instance
|
|
@@ -840,12 +870,12 @@ const create$2 = async ({
|
|
|
840
870
|
};
|
|
841
871
|
const WebWorkerRpcClient = {
|
|
842
872
|
__proto__: null,
|
|
843
|
-
create: create$
|
|
873
|
+
create: create$3
|
|
844
874
|
};
|
|
845
875
|
|
|
846
876
|
const assetDir = '';
|
|
847
877
|
|
|
848
|
-
const create$
|
|
878
|
+
const create$2 = () => {
|
|
849
879
|
const states = Object.create(null);
|
|
850
880
|
return {
|
|
851
881
|
get(uid) {
|
|
@@ -886,6 +916,20 @@ const create$1 = () => {
|
|
|
886
916
|
};
|
|
887
917
|
};
|
|
888
918
|
return wrapped;
|
|
919
|
+
},
|
|
920
|
+
diff(uid, modules, numbers) {
|
|
921
|
+
const {
|
|
922
|
+
oldState,
|
|
923
|
+
newState
|
|
924
|
+
} = states[uid];
|
|
925
|
+
const diffResult = [];
|
|
926
|
+
for (let i = 0; i < modules.length; i++) {
|
|
927
|
+
const fn = modules[i];
|
|
928
|
+
if (!fn(oldState, newState)) {
|
|
929
|
+
diffResult.push(numbers[i]);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
return diffResult;
|
|
889
933
|
}
|
|
890
934
|
};
|
|
891
935
|
};
|
|
@@ -895,9 +939,9 @@ const {
|
|
|
895
939
|
set: set$1,
|
|
896
940
|
dispose: dispose$1,
|
|
897
941
|
wrapCommand
|
|
898
|
-
} = create$
|
|
942
|
+
} = create$2();
|
|
899
943
|
|
|
900
|
-
const create = (uid, uri, x, y, width, height, platform, assetDir$1) => {
|
|
944
|
+
const create$1 = (uid, uri, x, y, width, height, platform, assetDir$1) => {
|
|
901
945
|
const state = {
|
|
902
946
|
description: '',
|
|
903
947
|
iconSrc: '',
|
|
@@ -1131,20 +1175,52 @@ const handleClickFeatures = async (state, name) => {
|
|
|
1131
1175
|
return selectFeature(state, name);
|
|
1132
1176
|
};
|
|
1133
1177
|
|
|
1134
|
-
const RendererWorker = 1;
|
|
1135
|
-
|
|
1136
1178
|
const rpcs = Object.create(null);
|
|
1137
|
-
const set = (id, rpc) => {
|
|
1179
|
+
const set$g = (id, rpc) => {
|
|
1138
1180
|
rpcs[id] = rpc;
|
|
1139
1181
|
};
|
|
1140
1182
|
const get = id => {
|
|
1141
1183
|
return rpcs[id];
|
|
1142
1184
|
};
|
|
1143
1185
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1186
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1187
|
+
|
|
1188
|
+
const create = rpcId => {
|
|
1189
|
+
return {
|
|
1190
|
+
// @ts-ignore
|
|
1191
|
+
invoke(method, ...params) {
|
|
1192
|
+
const rpc = get(rpcId);
|
|
1193
|
+
// @ts-ignore
|
|
1194
|
+
return rpc.invoke(method, ...params);
|
|
1195
|
+
},
|
|
1196
|
+
// @ts-ignore
|
|
1197
|
+
invokeAndTransfer(method, ...params) {
|
|
1198
|
+
const rpc = get(rpcId);
|
|
1199
|
+
// @ts-ignore
|
|
1200
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1201
|
+
},
|
|
1202
|
+
set(rpc) {
|
|
1203
|
+
set$g(rpcId, rpc);
|
|
1204
|
+
},
|
|
1205
|
+
async dispose() {
|
|
1206
|
+
const rpc = get(rpcId);
|
|
1207
|
+
await rpc.dispose();
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1147
1210
|
};
|
|
1211
|
+
const RendererWorker$1 = 1;
|
|
1212
|
+
const {
|
|
1213
|
+
invoke: invoke$4,
|
|
1214
|
+
set: set$3} = create(RendererWorker$1);
|
|
1215
|
+
const RendererWorker = {
|
|
1216
|
+
__proto__: null,
|
|
1217
|
+
invoke: invoke$4,
|
|
1218
|
+
set: set$3};
|
|
1219
|
+
|
|
1220
|
+
const {
|
|
1221
|
+
invoke,
|
|
1222
|
+
set
|
|
1223
|
+
} = RendererWorker;
|
|
1148
1224
|
|
|
1149
1225
|
const handleClickSize = async state => {
|
|
1150
1226
|
const {
|
|
@@ -1245,6 +1321,7 @@ const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
|
|
|
1245
1321
|
};
|
|
1246
1322
|
|
|
1247
1323
|
const renderMarkdown = async (markdown, options = {}) => {
|
|
1324
|
+
// @ts-ignore todo
|
|
1248
1325
|
const html = await invoke('Markdown.renderMarkdown', markdown, options);
|
|
1249
1326
|
return html;
|
|
1250
1327
|
};
|
|
@@ -1362,6 +1439,7 @@ const getExtension$1 = async (id, platform) => {
|
|
|
1362
1439
|
};
|
|
1363
1440
|
|
|
1364
1441
|
const getExtensionNew = async id => {
|
|
1442
|
+
// @ts-ignore todo
|
|
1365
1443
|
return invoke('ExtensionManagement.getExtension', id);
|
|
1366
1444
|
};
|
|
1367
1445
|
const getExtension = async (id, platform) => {
|
|
@@ -1439,6 +1517,7 @@ const getFolderSize = async uri => {
|
|
|
1439
1517
|
throw new VError(`uri is required`);
|
|
1440
1518
|
}
|
|
1441
1519
|
try {
|
|
1520
|
+
// @ts-ignore todo
|
|
1442
1521
|
return await invoke('FileSystem.getFolderSize', uri);
|
|
1443
1522
|
} catch {
|
|
1444
1523
|
return 0;
|
|
@@ -1667,8 +1746,29 @@ const toLocaleString = (number, locale, options) => {
|
|
|
1667
1746
|
}
|
|
1668
1747
|
return result;
|
|
1669
1748
|
};
|
|
1749
|
+
const log10 = numberOrBigInt => {
|
|
1750
|
+
if (typeof numberOrBigInt === 'number') {
|
|
1751
|
+
return Math.log10(numberOrBigInt);
|
|
1752
|
+
}
|
|
1753
|
+
const string = numberOrBigInt.toString(10);
|
|
1754
|
+
return string.length + Math.log10('0.' + string.slice(0, 15));
|
|
1755
|
+
};
|
|
1756
|
+
const log = numberOrBigInt => {
|
|
1757
|
+
if (typeof numberOrBigInt === 'number') {
|
|
1758
|
+
return Math.log(numberOrBigInt);
|
|
1759
|
+
}
|
|
1760
|
+
return log10(numberOrBigInt) * Math.log(10);
|
|
1761
|
+
};
|
|
1762
|
+
const divide = (numberOrBigInt, divisor) => {
|
|
1763
|
+
if (typeof numberOrBigInt === 'number') {
|
|
1764
|
+
return numberOrBigInt / divisor;
|
|
1765
|
+
}
|
|
1766
|
+
const integerPart = numberOrBigInt / BigInt(divisor);
|
|
1767
|
+
const remainder = numberOrBigInt % BigInt(divisor);
|
|
1768
|
+
return Number(integerPart) + Number(remainder) / divisor;
|
|
1769
|
+
};
|
|
1670
1770
|
function prettyBytes(number, options) {
|
|
1671
|
-
if (!Number.isFinite(number)) {
|
|
1771
|
+
if (typeof number !== 'bigint' && !Number.isFinite(number)) {
|
|
1672
1772
|
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
1673
1773
|
}
|
|
1674
1774
|
options = {
|
|
@@ -1679,7 +1779,7 @@ function prettyBytes(number, options) {
|
|
|
1679
1779
|
};
|
|
1680
1780
|
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
1681
1781
|
const separator = options.space ? ' ' : '';
|
|
1682
|
-
if (options.signed && number === 0) {
|
|
1782
|
+
if (options.signed && (typeof number === 'number' ? number === 0 : number === 0n)) {
|
|
1683
1783
|
return ` 0${separator}${UNITS[0]}`;
|
|
1684
1784
|
}
|
|
1685
1785
|
const isNegative = number < 0;
|
|
@@ -1703,8 +1803,8 @@ function prettyBytes(number, options) {
|
|
|
1703
1803
|
const numberString = toLocaleString(number, options.locale, localeOptions);
|
|
1704
1804
|
return prefix + numberString + separator + UNITS[0];
|
|
1705
1805
|
}
|
|
1706
|
-
const exponent = Math.min(Math.floor(options.binary ?
|
|
1707
|
-
number
|
|
1806
|
+
const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
|
|
1807
|
+
number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
|
|
1708
1808
|
if (!localeOptions) {
|
|
1709
1809
|
number = number.toPrecision(3);
|
|
1710
1810
|
}
|
|
@@ -1932,6 +2032,7 @@ const getInstallationEntries = (displaySize, extensionId, extensionVersion) => {
|
|
|
1932
2032
|
|
|
1933
2033
|
const getMarkdownVirtualDom = async html => {
|
|
1934
2034
|
string(html);
|
|
2035
|
+
// @ts-ignore todo
|
|
1935
2036
|
const dom = await invoke('Markdown.getVirtualDom', html);
|
|
1936
2037
|
return dom;
|
|
1937
2038
|
};
|
|
@@ -2599,7 +2700,7 @@ const terminate = () => {
|
|
|
2599
2700
|
};
|
|
2600
2701
|
|
|
2601
2702
|
const commandMap = {
|
|
2602
|
-
'ExtensionDetail.create': create,
|
|
2703
|
+
'ExtensionDetail.create': create$1,
|
|
2603
2704
|
'ExtensionDetail.diff2': diff2,
|
|
2604
2705
|
'ExtensionDetail.dispose': dispose,
|
|
2605
2706
|
'ExtensionDetail.getCommandIds': getCommandIds,
|
|
@@ -2623,7 +2724,7 @@ const listen = async () => {
|
|
|
2623
2724
|
const rpc = await WebWorkerRpcClient.create({
|
|
2624
2725
|
commandMap: commandMap
|
|
2625
2726
|
});
|
|
2626
|
-
set(
|
|
2727
|
+
set(rpc);
|
|
2627
2728
|
};
|
|
2628
2729
|
|
|
2629
2730
|
const main = async () => {
|