@lvce-editor/extension-search-view 1.3.0 → 1.4.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/extensionSearchViewWorkerMain.js +150 -122
- package/package.json +1 -1
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const commands = Object.create(null);
|
|
2
|
-
const registerCommand = (key, fn) => {
|
|
3
|
-
commands[key] = fn;
|
|
4
|
-
};
|
|
5
2
|
const register = commandMap => {
|
|
6
|
-
|
|
7
|
-
registerCommand(key, value);
|
|
8
|
-
}
|
|
3
|
+
Object.assign(commands, commandMap);
|
|
9
4
|
};
|
|
10
5
|
const getCommand = key => {
|
|
11
6
|
return commands[key];
|
|
@@ -74,13 +69,13 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
|
74
69
|
return finalDeltaY;
|
|
75
70
|
};
|
|
76
71
|
|
|
77
|
-
|
|
72
|
+
class AssertionError extends Error {
|
|
78
73
|
constructor(message) {
|
|
79
74
|
super(message);
|
|
80
75
|
this.name = 'AssertionError';
|
|
81
76
|
}
|
|
82
|
-
}
|
|
83
|
-
const getType
|
|
77
|
+
}
|
|
78
|
+
const getType = value => {
|
|
84
79
|
switch (typeof value) {
|
|
85
80
|
case 'number':
|
|
86
81
|
return 'number';
|
|
@@ -102,17 +97,17 @@ const getType$2 = value => {
|
|
|
102
97
|
return 'unknown';
|
|
103
98
|
}
|
|
104
99
|
};
|
|
105
|
-
const number
|
|
106
|
-
const type = getType
|
|
100
|
+
const number = value => {
|
|
101
|
+
const type = getType(value);
|
|
107
102
|
if (type !== 'number') {
|
|
108
|
-
throw new AssertionError
|
|
103
|
+
throw new AssertionError('expected value to be of type number');
|
|
109
104
|
}
|
|
110
105
|
};
|
|
111
106
|
|
|
112
107
|
const getListHeight$1 = (itemsLength, itemHeight, maxHeight) => {
|
|
113
|
-
number
|
|
114
|
-
number
|
|
115
|
-
number
|
|
108
|
+
number(itemsLength);
|
|
109
|
+
number(itemHeight);
|
|
110
|
+
number(maxHeight);
|
|
116
111
|
if (itemsLength === 0) {
|
|
117
112
|
return itemHeight;
|
|
118
113
|
}
|
|
@@ -340,10 +335,10 @@ const getExtensions = async (extensions, parsedValue) => {
|
|
|
340
335
|
|
|
341
336
|
const normalizeLine$1 = line => {
|
|
342
337
|
if (line.startsWith('Error: ')) {
|
|
343
|
-
return line.slice(
|
|
338
|
+
return line.slice('Error: '.length);
|
|
344
339
|
}
|
|
345
340
|
if (line.startsWith('VError: ')) {
|
|
346
|
-
return line.slice(
|
|
341
|
+
return line.slice('VError: '.length);
|
|
347
342
|
}
|
|
348
343
|
return line;
|
|
349
344
|
};
|
|
@@ -469,6 +464,63 @@ const clearSearchResults = state => {
|
|
|
469
464
|
return handleInput(state, '');
|
|
470
465
|
};
|
|
471
466
|
|
|
467
|
+
const Enter = 3;
|
|
468
|
+
const Space = 9;
|
|
469
|
+
const PageUp = 10;
|
|
470
|
+
const PageDown = 11;
|
|
471
|
+
const End = 255;
|
|
472
|
+
const Home = 12;
|
|
473
|
+
const UpArrow = 14;
|
|
474
|
+
const DownArrow = 16;
|
|
475
|
+
|
|
476
|
+
const CtrlCmd = 1 << 11 >>> 0;
|
|
477
|
+
|
|
478
|
+
const FocusExtensions = 15;
|
|
479
|
+
|
|
480
|
+
const getKeyBindings = () => {
|
|
481
|
+
return [{
|
|
482
|
+
key: Home,
|
|
483
|
+
command: 'Extensions.focusFirst',
|
|
484
|
+
when: FocusExtensions
|
|
485
|
+
}, {
|
|
486
|
+
key: End,
|
|
487
|
+
command: 'Extensions.focusLast',
|
|
488
|
+
when: FocusExtensions
|
|
489
|
+
}, {
|
|
490
|
+
key: PageUp,
|
|
491
|
+
command: 'Extensions.focusPreviousPage',
|
|
492
|
+
when: FocusExtensions
|
|
493
|
+
}, {
|
|
494
|
+
key: PageDown,
|
|
495
|
+
command: 'Extensions.focusNextPage',
|
|
496
|
+
when: FocusExtensions
|
|
497
|
+
}, {
|
|
498
|
+
key: UpArrow,
|
|
499
|
+
command: 'Extensions.focusPrevious',
|
|
500
|
+
when: FocusExtensions
|
|
501
|
+
}, {
|
|
502
|
+
key: DownArrow,
|
|
503
|
+
command: 'Extensions.focusNext',
|
|
504
|
+
when: FocusExtensions
|
|
505
|
+
}, {
|
|
506
|
+
key: Space,
|
|
507
|
+
command: 'Extensions.handleClickCurrentButKeepFocus',
|
|
508
|
+
when: FocusExtensions
|
|
509
|
+
}, {
|
|
510
|
+
key: Enter,
|
|
511
|
+
command: 'Extensions.handleClickCurrent',
|
|
512
|
+
when: FocusExtensions
|
|
513
|
+
}, {
|
|
514
|
+
key: CtrlCmd | Space,
|
|
515
|
+
command: 'Extensions.toggleSuggest',
|
|
516
|
+
when: FocusExtensions
|
|
517
|
+
}, {
|
|
518
|
+
key: CtrlCmd | DownArrow,
|
|
519
|
+
command: 'Extensions.scrollDown',
|
|
520
|
+
when: FocusExtensions
|
|
521
|
+
}];
|
|
522
|
+
};
|
|
523
|
+
|
|
472
524
|
const Button = 1;
|
|
473
525
|
|
|
474
526
|
const ExtensionActions = 'ExtensionActions';
|
|
@@ -790,67 +842,33 @@ const doRender = (oldState, newState) => {
|
|
|
790
842
|
};
|
|
791
843
|
|
|
792
844
|
const commandMap = {
|
|
793
|
-
'SearchExtensions.
|
|
845
|
+
'SearchExtensions.clearSearchResults': clearSearchResults,
|
|
846
|
+
'SearchExtensions.getKeyBindings': getKeyBindings,
|
|
794
847
|
'SearchExtensions.render': doRender,
|
|
795
|
-
'SearchExtensions.
|
|
848
|
+
'SearchExtensions.searchExtensions': searchExtensions
|
|
796
849
|
};
|
|
797
850
|
|
|
798
851
|
const Two = '2.0';
|
|
799
|
-
|
|
800
|
-
constructor(message) {
|
|
801
|
-
super(message);
|
|
802
|
-
this.name = 'AssertionError';
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
const getType$1 = value => {
|
|
806
|
-
switch (typeof value) {
|
|
807
|
-
case 'number':
|
|
808
|
-
return 'number';
|
|
809
|
-
case 'function':
|
|
810
|
-
return 'function';
|
|
811
|
-
case 'string':
|
|
812
|
-
return 'string';
|
|
813
|
-
case 'object':
|
|
814
|
-
if (value === null) {
|
|
815
|
-
return 'null';
|
|
816
|
-
}
|
|
817
|
-
if (Array.isArray(value)) {
|
|
818
|
-
return 'array';
|
|
819
|
-
}
|
|
820
|
-
return 'object';
|
|
821
|
-
case 'boolean':
|
|
822
|
-
return 'boolean';
|
|
823
|
-
default:
|
|
824
|
-
return 'unknown';
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
const number = value => {
|
|
828
|
-
const type = getType$1(value);
|
|
829
|
-
if (type !== 'number') {
|
|
830
|
-
throw new AssertionError('expected value to be of type number');
|
|
831
|
-
}
|
|
832
|
-
};
|
|
833
|
-
const state$1 = {
|
|
852
|
+
const state = {
|
|
834
853
|
callbacks: Object.create(null)
|
|
835
854
|
};
|
|
836
855
|
const get = id => {
|
|
837
|
-
return state
|
|
856
|
+
return state.callbacks[id];
|
|
838
857
|
};
|
|
839
858
|
const remove = id => {
|
|
840
|
-
delete state
|
|
859
|
+
delete state.callbacks[id];
|
|
841
860
|
};
|
|
842
861
|
const warn = (...args) => {
|
|
843
862
|
console.warn(...args);
|
|
844
863
|
};
|
|
845
|
-
const resolve = (id,
|
|
846
|
-
number(id);
|
|
864
|
+
const resolve = (id, response) => {
|
|
847
865
|
const fn = get(id);
|
|
848
866
|
if (!fn) {
|
|
849
|
-
console.log(
|
|
867
|
+
console.log(response);
|
|
850
868
|
warn(`callback ${id} may already be disposed`);
|
|
851
869
|
return;
|
|
852
870
|
}
|
|
853
|
-
fn(
|
|
871
|
+
fn(response);
|
|
854
872
|
remove(id);
|
|
855
873
|
};
|
|
856
874
|
class JsonRpcError extends Error {
|
|
@@ -862,7 +880,7 @@ class JsonRpcError extends Error {
|
|
|
862
880
|
const MethodNotFound = -32601;
|
|
863
881
|
const Custom = -32001;
|
|
864
882
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
865
|
-
const
|
|
883
|
+
const getErrorType = prettyError => {
|
|
866
884
|
if (prettyError && prettyError.type) {
|
|
867
885
|
return prettyError.type;
|
|
868
886
|
}
|
|
@@ -885,7 +903,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
885
903
|
data: {
|
|
886
904
|
stack: prettyError.stack,
|
|
887
905
|
codeFrame: prettyError.codeFrame,
|
|
888
|
-
type:
|
|
906
|
+
type: getErrorType(prettyError),
|
|
889
907
|
code: prettyError.code,
|
|
890
908
|
name: prettyError.name
|
|
891
909
|
}
|
|
@@ -933,32 +951,42 @@ const defaultRequiresSocket = () => {
|
|
|
933
951
|
return false;
|
|
934
952
|
};
|
|
935
953
|
const defaultResolve = resolve;
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
let execute;
|
|
940
|
-
let preparePrettyError;
|
|
941
|
-
let logError;
|
|
942
|
-
let resolve;
|
|
943
|
-
let requiresSocket;
|
|
954
|
+
|
|
955
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
956
|
+
const normalizeParams = args => {
|
|
944
957
|
if (args.length === 1) {
|
|
945
|
-
const
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
message = args[1];
|
|
956
|
-
execute = args[2];
|
|
957
|
-
resolve = args[3];
|
|
958
|
-
preparePrettyError = args[4];
|
|
959
|
-
logError = args[5];
|
|
960
|
-
requiresSocket = args[6];
|
|
958
|
+
const options = args[0];
|
|
959
|
+
return {
|
|
960
|
+
ipc: options.ipc,
|
|
961
|
+
message: options.message,
|
|
962
|
+
execute: options.execute,
|
|
963
|
+
resolve: options.resolve || defaultResolve,
|
|
964
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
965
|
+
logError: options.logError || defaultLogError,
|
|
966
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
967
|
+
};
|
|
961
968
|
}
|
|
969
|
+
return {
|
|
970
|
+
ipc: args[0],
|
|
971
|
+
message: args[1],
|
|
972
|
+
execute: args[2],
|
|
973
|
+
resolve: args[3],
|
|
974
|
+
preparePrettyError: args[4],
|
|
975
|
+
logError: args[5],
|
|
976
|
+
requiresSocket: args[6]
|
|
977
|
+
};
|
|
978
|
+
};
|
|
979
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
980
|
+
const options = normalizeParams(args);
|
|
981
|
+
const {
|
|
982
|
+
message,
|
|
983
|
+
ipc,
|
|
984
|
+
execute,
|
|
985
|
+
resolve,
|
|
986
|
+
preparePrettyError,
|
|
987
|
+
logError,
|
|
988
|
+
requiresSocket
|
|
989
|
+
} = options;
|
|
962
990
|
if ('id' in message) {
|
|
963
991
|
if ('method' in message) {
|
|
964
992
|
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
@@ -1016,6 +1044,27 @@ const Auto = () => {
|
|
|
1016
1044
|
const getData$1 = event => {
|
|
1017
1045
|
return event.data;
|
|
1018
1046
|
};
|
|
1047
|
+
const attachEvents = that => {
|
|
1048
|
+
const handleMessage = (...args) => {
|
|
1049
|
+
const data = that.getData(...args);
|
|
1050
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
1051
|
+
data
|
|
1052
|
+
}));
|
|
1053
|
+
};
|
|
1054
|
+
that.onMessage(handleMessage);
|
|
1055
|
+
const handleClose = event => {
|
|
1056
|
+
that.dispatchEvent(new Event('close'));
|
|
1057
|
+
};
|
|
1058
|
+
that.onClose(handleClose);
|
|
1059
|
+
};
|
|
1060
|
+
class Ipc extends EventTarget {
|
|
1061
|
+
constructor(rawIpc) {
|
|
1062
|
+
super();
|
|
1063
|
+
this._rawIpc = rawIpc;
|
|
1064
|
+
attachEvents(this);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
const readyMessage = 'ready';
|
|
1019
1068
|
const walkValue = (value, transferrables, isTransferrable) => {
|
|
1020
1069
|
if (!value) {
|
|
1021
1070
|
return;
|
|
@@ -1066,35 +1115,14 @@ const getTransferrables = value => {
|
|
|
1066
1115
|
walkValue(value, transferrables, isTransferrable);
|
|
1067
1116
|
return transferrables;
|
|
1068
1117
|
};
|
|
1069
|
-
const
|
|
1070
|
-
const handleMessage = (...args) => {
|
|
1071
|
-
const data = that.getData(...args);
|
|
1072
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
1073
|
-
data
|
|
1074
|
-
}));
|
|
1075
|
-
};
|
|
1076
|
-
that.onMessage(handleMessage);
|
|
1077
|
-
const handleClose = event => {
|
|
1078
|
-
that.dispatchEvent(new Event('close'));
|
|
1079
|
-
};
|
|
1080
|
-
that.onClose(handleClose);
|
|
1081
|
-
};
|
|
1082
|
-
class Ipc extends EventTarget {
|
|
1083
|
-
constructor(rawIpc) {
|
|
1084
|
-
super();
|
|
1085
|
-
this._rawIpc = rawIpc;
|
|
1086
|
-
attachEvents(this);
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
const readyMessage = 'ready';
|
|
1090
|
-
const listen$4 = () => {
|
|
1118
|
+
const listen$2 = () => {
|
|
1091
1119
|
// @ts-ignore
|
|
1092
1120
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1093
1121
|
throw new TypeError('module is not in web worker scope');
|
|
1094
1122
|
}
|
|
1095
1123
|
return globalThis;
|
|
1096
1124
|
};
|
|
1097
|
-
const signal$
|
|
1125
|
+
const signal$2 = global => {
|
|
1098
1126
|
global.postMessage(readyMessage);
|
|
1099
1127
|
};
|
|
1100
1128
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -1120,14 +1148,14 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
1120
1148
|
this._rawIpc.addEventListener('message', callback);
|
|
1121
1149
|
}
|
|
1122
1150
|
}
|
|
1123
|
-
const wrap$
|
|
1151
|
+
const wrap$5 = global => {
|
|
1124
1152
|
return new IpcChildWithModuleWorker(global);
|
|
1125
1153
|
};
|
|
1126
1154
|
const IpcChildWithModuleWorker$1 = {
|
|
1127
1155
|
__proto__: null,
|
|
1128
|
-
listen: listen$
|
|
1129
|
-
signal: signal$
|
|
1130
|
-
wrap: wrap$
|
|
1156
|
+
listen: listen$2,
|
|
1157
|
+
signal: signal$2,
|
|
1158
|
+
wrap: wrap$5
|
|
1131
1159
|
};
|
|
1132
1160
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1133
1161
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
@@ -1244,10 +1272,10 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
1244
1272
|
};
|
|
1245
1273
|
const normalizeLine = line => {
|
|
1246
1274
|
if (line.startsWith('Error: ')) {
|
|
1247
|
-
return line.slice(
|
|
1275
|
+
return line.slice('Error: '.length);
|
|
1248
1276
|
}
|
|
1249
1277
|
if (line.startsWith('VError: ')) {
|
|
1250
|
-
return line.slice(
|
|
1278
|
+
return line.slice('VError: '.length);
|
|
1251
1279
|
}
|
|
1252
1280
|
return line;
|
|
1253
1281
|
};
|
|
@@ -1345,10 +1373,10 @@ const waitForFirstMessage = async port => {
|
|
|
1345
1373
|
// @ts-ignore
|
|
1346
1374
|
return event.data;
|
|
1347
1375
|
};
|
|
1348
|
-
const listen$
|
|
1349
|
-
const parentIpcRaw = listen$
|
|
1350
|
-
signal$
|
|
1351
|
-
const parentIpc = wrap$
|
|
1376
|
+
const listen$1$1 = async () => {
|
|
1377
|
+
const parentIpcRaw = listen$2();
|
|
1378
|
+
signal$2(parentIpcRaw);
|
|
1379
|
+
const parentIpc = wrap$5(parentIpcRaw);
|
|
1352
1380
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
1353
1381
|
if (firstMessage.method !== 'initialize') {
|
|
1354
1382
|
throw new IpcError('unexpected first message');
|
|
@@ -1393,13 +1421,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
1393
1421
|
this._rawIpc.start();
|
|
1394
1422
|
}
|
|
1395
1423
|
}
|
|
1396
|
-
const wrap$
|
|
1424
|
+
const wrap$4 = port => {
|
|
1397
1425
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1398
1426
|
};
|
|
1399
1427
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
1400
1428
|
__proto__: null,
|
|
1401
|
-
listen: listen$
|
|
1402
|
-
wrap: wrap$
|
|
1429
|
+
listen: listen$1$1,
|
|
1430
|
+
wrap: wrap$4
|
|
1403
1431
|
};
|
|
1404
1432
|
|
|
1405
1433
|
const getModule = method => {
|