@lvce-editor/extension-search-view 3.5.0 → 3.7.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,37 +60,45 @@ 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 object = value => {
|
|
86
94
|
const type = getType(value);
|
|
87
|
-
if (type !==
|
|
95
|
+
if (type !== Object$1) {
|
|
88
96
|
throw new AssertionError('expected value to be of type object');
|
|
89
97
|
}
|
|
90
98
|
};
|
|
91
99
|
const number = value => {
|
|
92
100
|
const type = getType(value);
|
|
93
|
-
if (type !==
|
|
101
|
+
if (type !== Number$1) {
|
|
94
102
|
throw new AssertionError('expected value to be of type number');
|
|
95
103
|
}
|
|
96
104
|
};
|
|
@@ -344,22 +352,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
344
352
|
const wrap$f = global => {
|
|
345
353
|
return new IpcChildWithModuleWorker(global);
|
|
346
354
|
};
|
|
347
|
-
const withResolvers = () => {
|
|
348
|
-
let _resolve;
|
|
349
|
-
const promise = new Promise(resolve => {
|
|
350
|
-
_resolve = resolve;
|
|
351
|
-
});
|
|
352
|
-
return {
|
|
353
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
354
|
-
resolve: _resolve,
|
|
355
|
-
promise
|
|
356
|
-
};
|
|
357
|
-
};
|
|
358
355
|
const waitForFirstMessage = async port => {
|
|
359
356
|
const {
|
|
360
357
|
resolve,
|
|
361
358
|
promise
|
|
362
|
-
} = withResolvers();
|
|
359
|
+
} = Promise.withResolvers();
|
|
363
360
|
port.addEventListener('message', resolve, {
|
|
364
361
|
once: true
|
|
365
362
|
});
|
|
@@ -440,11 +437,11 @@ const remove = id => {
|
|
|
440
437
|
delete callbacks[id];
|
|
441
438
|
};
|
|
442
439
|
let id = 0;
|
|
443
|
-
const create$3 = () => {
|
|
440
|
+
const create$3$1 = () => {
|
|
444
441
|
return ++id;
|
|
445
442
|
};
|
|
446
443
|
const registerPromise = () => {
|
|
447
|
-
const id = create$3();
|
|
444
|
+
const id = create$3$1();
|
|
448
445
|
const {
|
|
449
446
|
resolve,
|
|
450
447
|
promise
|
|
@@ -522,6 +519,16 @@ const constructError = (message, type, name) => {
|
|
|
522
519
|
}
|
|
523
520
|
return new ErrorConstructor(message);
|
|
524
521
|
};
|
|
522
|
+
const joinLines = lines => {
|
|
523
|
+
return lines.join(NewLine);
|
|
524
|
+
};
|
|
525
|
+
const splitLines = lines => {
|
|
526
|
+
return lines.split(NewLine);
|
|
527
|
+
};
|
|
528
|
+
const getCurrentStack = () => {
|
|
529
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
530
|
+
return currentStack;
|
|
531
|
+
};
|
|
525
532
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
526
533
|
return string.indexOf(NewLine, startIndex);
|
|
527
534
|
};
|
|
@@ -532,19 +539,16 @@ const getParentStack = error => {
|
|
|
532
539
|
}
|
|
533
540
|
return parentStack;
|
|
534
541
|
};
|
|
535
|
-
const joinLines = lines => {
|
|
536
|
-
return lines.join(NewLine);
|
|
537
|
-
};
|
|
538
542
|
const MethodNotFound = -32601;
|
|
539
543
|
const Custom = -32001;
|
|
540
|
-
const splitLines = lines => {
|
|
541
|
-
return lines.split(NewLine);
|
|
542
|
-
};
|
|
543
544
|
const restoreJsonRpcError = error => {
|
|
545
|
+
const currentStack = getCurrentStack();
|
|
544
546
|
if (error && error instanceof Error) {
|
|
547
|
+
if (typeof error.stack === 'string') {
|
|
548
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
549
|
+
}
|
|
545
550
|
return error;
|
|
546
551
|
}
|
|
547
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
|
|
548
552
|
if (error && error.code && error.code === MethodNotFound) {
|
|
549
553
|
const restoredError = new JsonRpcError(error.message);
|
|
550
554
|
const parentStack = getParentStack(error);
|
|
@@ -625,6 +629,17 @@ const getErrorType = prettyError => {
|
|
|
625
629
|
}
|
|
626
630
|
return undefined;
|
|
627
631
|
};
|
|
632
|
+
const isAlreadyStack = line => {
|
|
633
|
+
return line.trim().startsWith('at ');
|
|
634
|
+
};
|
|
635
|
+
const getStack = prettyError => {
|
|
636
|
+
const stackString = prettyError.stack || '';
|
|
637
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
638
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
639
|
+
return stackString.slice(newLineIndex + 1);
|
|
640
|
+
}
|
|
641
|
+
return stackString;
|
|
642
|
+
};
|
|
628
643
|
const getErrorProperty = (error, prettyError) => {
|
|
629
644
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
630
645
|
return {
|
|
@@ -637,7 +652,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
637
652
|
code: Custom,
|
|
638
653
|
message: prettyError.message,
|
|
639
654
|
data: {
|
|
640
|
-
stack: prettyError
|
|
655
|
+
stack: getStack(prettyError),
|
|
641
656
|
codeFrame: prettyError.codeFrame,
|
|
642
657
|
type: getErrorType(prettyError),
|
|
643
658
|
code: prettyError.code,
|
|
@@ -645,18 +660,18 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
645
660
|
}
|
|
646
661
|
};
|
|
647
662
|
};
|
|
648
|
-
const create$1$1 = (
|
|
663
|
+
const create$1$1 = (id, error) => {
|
|
649
664
|
return {
|
|
650
665
|
jsonrpc: Two,
|
|
651
|
-
id
|
|
666
|
+
id,
|
|
652
667
|
error
|
|
653
668
|
};
|
|
654
669
|
};
|
|
655
|
-
const getErrorResponse = (
|
|
670
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
656
671
|
const prettyError = preparePrettyError(error);
|
|
657
672
|
logError(error, prettyError);
|
|
658
673
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
659
|
-
return create$1$1(
|
|
674
|
+
return create$1$1(id, errorProperty);
|
|
660
675
|
};
|
|
661
676
|
const create$5 = (message, result) => {
|
|
662
677
|
return {
|
|
@@ -669,12 +684,27 @@ const getSuccessResponse = (message, result) => {
|
|
|
669
684
|
const resultProperty = result ?? null;
|
|
670
685
|
return create$5(message, resultProperty);
|
|
671
686
|
};
|
|
687
|
+
const getErrorResponseSimple = (id, error) => {
|
|
688
|
+
return {
|
|
689
|
+
jsonrpc: Two,
|
|
690
|
+
id,
|
|
691
|
+
error: {
|
|
692
|
+
code: Custom,
|
|
693
|
+
// @ts-ignore
|
|
694
|
+
message: error.message,
|
|
695
|
+
data: error
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
};
|
|
672
699
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
673
700
|
try {
|
|
674
701
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
675
702
|
return getSuccessResponse(message, result);
|
|
676
703
|
} catch (error) {
|
|
677
|
-
|
|
704
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
705
|
+
return getErrorResponseSimple(message.id, error);
|
|
706
|
+
}
|
|
707
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
678
708
|
}
|
|
679
709
|
};
|
|
680
710
|
const defaultPreparePrettyError = error => {
|
|
@@ -729,7 +759,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
729
759
|
try {
|
|
730
760
|
ipc.send(response);
|
|
731
761
|
} catch (error) {
|
|
732
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
762
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
733
763
|
ipc.send(errorResponse);
|
|
734
764
|
}
|
|
735
765
|
return;
|
|
@@ -834,7 +864,7 @@ const listen$1 = async (module, options) => {
|
|
|
834
864
|
const ipc = module.wrap(rawIpc);
|
|
835
865
|
return ipc;
|
|
836
866
|
};
|
|
837
|
-
const create$
|
|
867
|
+
const create$3 = async ({
|
|
838
868
|
commandMap
|
|
839
869
|
}) => {
|
|
840
870
|
// TODO create a commandMap per rpc instance
|
|
@@ -846,7 +876,7 @@ const create$2 = async ({
|
|
|
846
876
|
};
|
|
847
877
|
const WebWorkerRpcClient = {
|
|
848
878
|
__proto__: null,
|
|
849
|
-
create: create$
|
|
879
|
+
create: create$3
|
|
850
880
|
};
|
|
851
881
|
|
|
852
882
|
const handleError = (error, notify = true, prefix = '') => {
|
|
@@ -1127,7 +1157,7 @@ const closeSuggest = state => {
|
|
|
1127
1157
|
return state;
|
|
1128
1158
|
};
|
|
1129
1159
|
|
|
1130
|
-
const create$
|
|
1160
|
+
const create$2 = () => {
|
|
1131
1161
|
const states = Object.create(null);
|
|
1132
1162
|
return {
|
|
1133
1163
|
get(uid) {
|
|
@@ -1168,6 +1198,20 @@ const create$1 = () => {
|
|
|
1168
1198
|
};
|
|
1169
1199
|
};
|
|
1170
1200
|
return wrapped;
|
|
1201
|
+
},
|
|
1202
|
+
diff(uid, modules, numbers) {
|
|
1203
|
+
const {
|
|
1204
|
+
oldState,
|
|
1205
|
+
newState
|
|
1206
|
+
} = states[uid];
|
|
1207
|
+
const diffResult = [];
|
|
1208
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1209
|
+
const fn = modules[i];
|
|
1210
|
+
if (!fn(oldState, newState)) {
|
|
1211
|
+
diffResult.push(numbers[i]);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
return diffResult;
|
|
1171
1215
|
}
|
|
1172
1216
|
};
|
|
1173
1217
|
};
|
|
@@ -1177,9 +1221,9 @@ const {
|
|
|
1177
1221
|
set: set$1,
|
|
1178
1222
|
dispose: dispose$1,
|
|
1179
1223
|
wrapCommand
|
|
1180
|
-
} = create$
|
|
1224
|
+
} = create$2();
|
|
1181
1225
|
|
|
1182
|
-
const create = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
1226
|
+
const create$1 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
1183
1227
|
const state = {
|
|
1184
1228
|
allExtensions: [],
|
|
1185
1229
|
assetDir,
|
|
@@ -1536,21 +1580,52 @@ const handleBlur = state => {
|
|
|
1536
1580
|
return state;
|
|
1537
1581
|
};
|
|
1538
1582
|
|
|
1539
|
-
const RendererWorker = 1;
|
|
1540
|
-
|
|
1541
1583
|
const rpcs = Object.create(null);
|
|
1542
|
-
const set = (id, rpc) => {
|
|
1584
|
+
const set$g = (id, rpc) => {
|
|
1543
1585
|
rpcs[id] = rpc;
|
|
1544
1586
|
};
|
|
1545
1587
|
const get = id => {
|
|
1546
1588
|
return rpcs[id];
|
|
1547
1589
|
};
|
|
1548
1590
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
return
|
|
1591
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1592
|
+
|
|
1593
|
+
const create = rpcId => {
|
|
1594
|
+
return {
|
|
1595
|
+
// @ts-ignore
|
|
1596
|
+
invoke(method, ...params) {
|
|
1597
|
+
const rpc = get(rpcId);
|
|
1598
|
+
// @ts-ignore
|
|
1599
|
+
return rpc.invoke(method, ...params);
|
|
1600
|
+
},
|
|
1601
|
+
// @ts-ignore
|
|
1602
|
+
invokeAndTransfer(method, ...params) {
|
|
1603
|
+
const rpc = get(rpcId);
|
|
1604
|
+
// @ts-ignore
|
|
1605
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1606
|
+
},
|
|
1607
|
+
set(rpc) {
|
|
1608
|
+
set$g(rpcId, rpc);
|
|
1609
|
+
},
|
|
1610
|
+
async dispose() {
|
|
1611
|
+
const rpc = get(rpcId);
|
|
1612
|
+
await rpc.dispose();
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1553
1615
|
};
|
|
1616
|
+
const RendererWorker$1 = 1;
|
|
1617
|
+
const {
|
|
1618
|
+
invoke: invoke$4,
|
|
1619
|
+
set: set$3} = create(RendererWorker$1);
|
|
1620
|
+
const RendererWorker = {
|
|
1621
|
+
__proto__: null,
|
|
1622
|
+
invoke: invoke$4,
|
|
1623
|
+
set: set$3};
|
|
1624
|
+
|
|
1625
|
+
const {
|
|
1626
|
+
invoke,
|
|
1627
|
+
set
|
|
1628
|
+
} = RendererWorker;
|
|
1554
1629
|
|
|
1555
1630
|
const openUri = async uri => {
|
|
1556
1631
|
return invoke('Main.openUri', uri);
|
|
@@ -1789,6 +1864,7 @@ const getAllExtensions$1 = async platform => {
|
|
|
1789
1864
|
if (platform === Web) {
|
|
1790
1865
|
return [];
|
|
1791
1866
|
}
|
|
1867
|
+
// @ts-ignore todo
|
|
1792
1868
|
return invoke('ExtensionManagement.getAllExtensions');
|
|
1793
1869
|
};
|
|
1794
1870
|
|
|
@@ -2421,7 +2497,7 @@ const toggleSuggest = state => {
|
|
|
2421
2497
|
const commandMap = {
|
|
2422
2498
|
'SearchExtensions.clearSearchResults': wrapCommand(clearSearchResults),
|
|
2423
2499
|
'SearchExtensions.closeSuggest': wrapCommand(closeSuggest),
|
|
2424
|
-
'SearchExtensions.create': create,
|
|
2500
|
+
'SearchExtensions.create': create$1,
|
|
2425
2501
|
'SearchExtensions.diff2': diff2,
|
|
2426
2502
|
'SearchExtensions.dispose': dispose,
|
|
2427
2503
|
'SearchExtensions.focusFirst': wrapCommand(focusFirst),
|
|
@@ -2471,7 +2547,7 @@ const listen = async () => {
|
|
|
2471
2547
|
const rpc = await WebWorkerRpcClient.create({
|
|
2472
2548
|
commandMap: commandMap
|
|
2473
2549
|
});
|
|
2474
|
-
set(
|
|
2550
|
+
set(rpc);
|
|
2475
2551
|
};
|
|
2476
2552
|
|
|
2477
2553
|
const main = async () => {
|