@lvce-editor/extension-host-worker 1.11.0 → 1.12.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/extensionHostWorkerMain.js +95 -150
- package/package.json +1 -1
|
@@ -30,13 +30,13 @@ const getJson = async url => {
|
|
|
30
30
|
throw new DepecratedError(`vscode.getJson is deprecated, use createNodeRpc instead`);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
class AssertionError extends Error {
|
|
34
34
|
constructor(message) {
|
|
35
35
|
super(message);
|
|
36
36
|
this.name = 'AssertionError';
|
|
37
37
|
}
|
|
38
|
-
}
|
|
39
|
-
const getType$
|
|
38
|
+
}
|
|
39
|
+
const getType$1 = value => {
|
|
40
40
|
switch (typeof value) {
|
|
41
41
|
case 'number':
|
|
42
42
|
return 'number';
|
|
@@ -59,39 +59,37 @@ const getType$2 = value => {
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
const object = value => {
|
|
62
|
-
const type = getType$
|
|
62
|
+
const type = getType$1(value);
|
|
63
63
|
if (type !== 'object') {
|
|
64
|
-
throw new AssertionError
|
|
64
|
+
throw new AssertionError('expected value to be of type object');
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
const number
|
|
68
|
-
const type = getType$
|
|
67
|
+
const number = value => {
|
|
68
|
+
const type = getType$1(value);
|
|
69
69
|
if (type !== 'number') {
|
|
70
|
-
throw new AssertionError
|
|
70
|
+
throw new AssertionError('expected value to be of type number');
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
const array = value => {
|
|
74
|
-
const type = getType$
|
|
74
|
+
const type = getType$1(value);
|
|
75
75
|
if (type !== 'array') {
|
|
76
|
-
throw new AssertionError
|
|
76
|
+
throw new AssertionError('expected value to be of type array');
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
const string = value => {
|
|
80
|
-
const type = getType$
|
|
80
|
+
const type = getType$1(value);
|
|
81
81
|
if (type !== 'string') {
|
|
82
|
-
throw new AssertionError
|
|
82
|
+
throw new AssertionError('expected value to be of type string');
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
const fn = value => {
|
|
86
|
-
const type = getType$
|
|
86
|
+
const type = getType$1(value);
|
|
87
87
|
if (type !== 'function') {
|
|
88
|
-
throw new AssertionError
|
|
88
|
+
throw new AssertionError('expected value to be of type function');
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
const state$9 = {
|
|
93
|
-
/** @type{any[]} */
|
|
94
|
-
onDidOpenEditorListeners: [],
|
|
95
93
|
/** @type{any[]} */
|
|
96
94
|
onWillChangeEditorListeners: [],
|
|
97
95
|
/** @type{any[]} */
|
|
@@ -287,7 +285,7 @@ const getSyntheticChanges = (textDocument, changes) => {
|
|
|
287
285
|
return syntheticChanges;
|
|
288
286
|
};
|
|
289
287
|
const syncIncremental = (textDocumentId, changes) => {
|
|
290
|
-
number
|
|
288
|
+
number(textDocumentId);
|
|
291
289
|
array(changes);
|
|
292
290
|
const textDocument = getDocument(textDocumentId);
|
|
293
291
|
if (!textDocument) {
|
|
@@ -332,10 +330,10 @@ class NoProviderFoundError extends Error {
|
|
|
332
330
|
|
|
333
331
|
const normalizeLine$1 = line => {
|
|
334
332
|
if (line.startsWith('Error: ')) {
|
|
335
|
-
return line.slice(
|
|
333
|
+
return line.slice('Error: '.length);
|
|
336
334
|
}
|
|
337
335
|
if (line.startsWith('VError: ')) {
|
|
338
|
-
return line.slice(
|
|
336
|
+
return line.slice('VError: '.length);
|
|
339
337
|
}
|
|
340
338
|
return line;
|
|
341
339
|
};
|
|
@@ -386,7 +384,7 @@ let VError$1 = class VError extends Error {
|
|
|
386
384
|
}
|
|
387
385
|
};
|
|
388
386
|
|
|
389
|
-
const getType
|
|
387
|
+
const getType = value => {
|
|
390
388
|
switch (typeof value) {
|
|
391
389
|
case 'number':
|
|
392
390
|
return 'number';
|
|
@@ -417,7 +415,7 @@ const validateResultObject = (result, resultShape) => {
|
|
|
417
415
|
for (const [key, value] of Object.entries(resultShape.properties)) {
|
|
418
416
|
// @ts-ignore
|
|
419
417
|
const expectedType = value.type;
|
|
420
|
-
const actualType = getType
|
|
418
|
+
const actualType = getType(result[key]);
|
|
421
419
|
if (expectedType !== actualType) {
|
|
422
420
|
return `item.${key} must be of type ${expectedType}`;
|
|
423
421
|
}
|
|
@@ -426,7 +424,7 @@ const validateResultObject = (result, resultShape) => {
|
|
|
426
424
|
};
|
|
427
425
|
const validateResultArray = (result, resultShape) => {
|
|
428
426
|
for (const item of result) {
|
|
429
|
-
const actualType = getType
|
|
427
|
+
const actualType = getType(item);
|
|
430
428
|
const expectedType = resultShape.items.type;
|
|
431
429
|
if (actualType !== expectedType) {
|
|
432
430
|
return `expected result to be of type ${expectedType} but was of type ${actualType}`;
|
|
@@ -447,7 +445,7 @@ const getPreviewString = item => {
|
|
|
447
445
|
return `"${item}"`;
|
|
448
446
|
};
|
|
449
447
|
const getPreview = item => {
|
|
450
|
-
const type = getType
|
|
448
|
+
const type = getType(item);
|
|
451
449
|
switch (type) {
|
|
452
450
|
case 'object':
|
|
453
451
|
return getPreviewObject();
|
|
@@ -460,7 +458,7 @@ const getPreview = item => {
|
|
|
460
458
|
}
|
|
461
459
|
};
|
|
462
460
|
const validate = (item, schema) => {
|
|
463
|
-
const actualType = getType
|
|
461
|
+
const actualType = getType(item);
|
|
464
462
|
const expectedType = schema.type;
|
|
465
463
|
if (actualType !== expectedType) {
|
|
466
464
|
if (schema.allowUndefined && (item === undefined || item === null)) {
|
|
@@ -621,9 +619,7 @@ const String = 'string';
|
|
|
621
619
|
|
|
622
620
|
const {
|
|
623
621
|
registerBraceCompletionProvider,
|
|
624
|
-
executeBraceCompletionProvider
|
|
625
|
-
reset: reset$9
|
|
626
|
-
} = create$9({
|
|
622
|
+
executeBraceCompletionProvider} = create$9({
|
|
627
623
|
name: 'BraceCompletion',
|
|
628
624
|
resultShape: {
|
|
629
625
|
type: Boolean
|
|
@@ -684,7 +680,7 @@ const getCommandDisplay = command => {
|
|
|
684
680
|
}
|
|
685
681
|
return '';
|
|
686
682
|
};
|
|
687
|
-
const registerCommand
|
|
683
|
+
const registerCommand = command => {
|
|
688
684
|
try {
|
|
689
685
|
if (!command) {
|
|
690
686
|
if (command === null) {
|
|
@@ -766,57 +762,21 @@ const create$4$1 = (method, params) => {
|
|
|
766
762
|
params
|
|
767
763
|
};
|
|
768
764
|
};
|
|
769
|
-
|
|
770
|
-
constructor(message) {
|
|
771
|
-
super(message);
|
|
772
|
-
this.name = 'AssertionError';
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
const getType = value => {
|
|
776
|
-
switch (typeof value) {
|
|
777
|
-
case 'number':
|
|
778
|
-
return 'number';
|
|
779
|
-
case 'function':
|
|
780
|
-
return 'function';
|
|
781
|
-
case 'string':
|
|
782
|
-
return 'string';
|
|
783
|
-
case 'object':
|
|
784
|
-
if (value === null) {
|
|
785
|
-
return 'null';
|
|
786
|
-
}
|
|
787
|
-
if (Array.isArray(value)) {
|
|
788
|
-
return 'array';
|
|
789
|
-
}
|
|
790
|
-
return 'object';
|
|
791
|
-
case 'boolean':
|
|
792
|
-
return 'boolean';
|
|
793
|
-
default:
|
|
794
|
-
return 'unknown';
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
const number = value => {
|
|
798
|
-
const type = getType(value);
|
|
799
|
-
if (type !== 'number') {
|
|
800
|
-
throw new AssertionError('expected value to be of type number');
|
|
801
|
-
}
|
|
802
|
-
};
|
|
803
|
-
const state$1$1 = {
|
|
765
|
+
const state$6 = {
|
|
804
766
|
callbacks: Object.create(null)
|
|
805
767
|
};
|
|
806
768
|
const set$4 = (id, fn) => {
|
|
807
|
-
state$
|
|
769
|
+
state$6.callbacks[id] = fn;
|
|
808
770
|
};
|
|
809
771
|
const get$4 = id => {
|
|
810
|
-
return state$
|
|
772
|
+
return state$6.callbacks[id];
|
|
811
773
|
};
|
|
812
774
|
const remove = id => {
|
|
813
|
-
delete state$
|
|
814
|
-
};
|
|
815
|
-
const state$6 = {
|
|
816
|
-
id: 0
|
|
775
|
+
delete state$6.callbacks[id];
|
|
817
776
|
};
|
|
777
|
+
let id = 0;
|
|
818
778
|
const create$3$1 = () => {
|
|
819
|
-
return ++
|
|
779
|
+
return ++id;
|
|
820
780
|
};
|
|
821
781
|
const warn = (...args) => {
|
|
822
782
|
console.warn(...args);
|
|
@@ -833,15 +793,14 @@ const registerPromise = () => {
|
|
|
833
793
|
promise
|
|
834
794
|
};
|
|
835
795
|
};
|
|
836
|
-
const resolve = (id,
|
|
837
|
-
number(id);
|
|
796
|
+
const resolve = (id, response) => {
|
|
838
797
|
const fn = get$4(id);
|
|
839
798
|
if (!fn) {
|
|
840
|
-
console.log(
|
|
799
|
+
console.log(response);
|
|
841
800
|
warn(`callback ${id} may already be disposed`);
|
|
842
801
|
return;
|
|
843
802
|
}
|
|
844
|
-
fn(
|
|
803
|
+
fn(response);
|
|
845
804
|
remove(id);
|
|
846
805
|
};
|
|
847
806
|
const create$2$1 = (method, params) => {
|
|
@@ -1063,32 +1022,42 @@ const defaultRequiresSocket = () => {
|
|
|
1063
1022
|
return false;
|
|
1064
1023
|
};
|
|
1065
1024
|
const defaultResolve = resolve;
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
let execute;
|
|
1070
|
-
let preparePrettyError;
|
|
1071
|
-
let logError;
|
|
1072
|
-
let resolve;
|
|
1073
|
-
let requiresSocket;
|
|
1025
|
+
|
|
1026
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
1027
|
+
const normalizeParams = args => {
|
|
1074
1028
|
if (args.length === 1) {
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
message = args[1];
|
|
1086
|
-
execute = args[2];
|
|
1087
|
-
resolve = args[3];
|
|
1088
|
-
preparePrettyError = args[4];
|
|
1089
|
-
logError = args[5];
|
|
1090
|
-
requiresSocket = args[6];
|
|
1029
|
+
const options = args[0];
|
|
1030
|
+
return {
|
|
1031
|
+
ipc: options.ipc,
|
|
1032
|
+
message: options.message,
|
|
1033
|
+
execute: options.execute,
|
|
1034
|
+
resolve: options.resolve || defaultResolve,
|
|
1035
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
1036
|
+
logError: options.logError || defaultLogError,
|
|
1037
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
1038
|
+
};
|
|
1091
1039
|
}
|
|
1040
|
+
return {
|
|
1041
|
+
ipc: args[0],
|
|
1042
|
+
message: args[1],
|
|
1043
|
+
execute: args[2],
|
|
1044
|
+
resolve: args[3],
|
|
1045
|
+
preparePrettyError: args[4],
|
|
1046
|
+
logError: args[5],
|
|
1047
|
+
requiresSocket: args[6]
|
|
1048
|
+
};
|
|
1049
|
+
};
|
|
1050
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
1051
|
+
const options = normalizeParams(args);
|
|
1052
|
+
const {
|
|
1053
|
+
message,
|
|
1054
|
+
ipc,
|
|
1055
|
+
execute,
|
|
1056
|
+
resolve,
|
|
1057
|
+
preparePrettyError,
|
|
1058
|
+
logError,
|
|
1059
|
+
requiresSocket
|
|
1060
|
+
} = options;
|
|
1092
1061
|
if ('id' in message) {
|
|
1093
1062
|
if ('method' in message) {
|
|
1094
1063
|
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
@@ -1109,39 +1078,33 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
1109
1078
|
}
|
|
1110
1079
|
throw new JsonRpcError('unexpected message');
|
|
1111
1080
|
};
|
|
1112
|
-
const
|
|
1113
|
-
const message = create$4$1(method, params);
|
|
1114
|
-
transport.send(message);
|
|
1115
|
-
};
|
|
1116
|
-
const invoke$1 = async (ipc, method, ...params) => {
|
|
1081
|
+
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
1117
1082
|
const {
|
|
1118
1083
|
message,
|
|
1119
1084
|
promise
|
|
1120
1085
|
} = create$2$1(method, params);
|
|
1121
|
-
ipc.
|
|
1086
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1087
|
+
ipc.sendAndTransfer(message);
|
|
1088
|
+
} else {
|
|
1089
|
+
ipc.send(message);
|
|
1090
|
+
}
|
|
1122
1091
|
const responseMessage = await promise;
|
|
1123
|
-
|
|
1124
|
-
return result;
|
|
1092
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
1125
1093
|
};
|
|
1126
|
-
const
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
ipc
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
return
|
|
1094
|
+
const send$1 = (transport, method, ...params) => {
|
|
1095
|
+
const message = create$4$1(method, params);
|
|
1096
|
+
transport.send(message);
|
|
1097
|
+
};
|
|
1098
|
+
const invoke$1 = (ipc, method, ...params) => {
|
|
1099
|
+
return invokeHelper(ipc, method, params, false);
|
|
1100
|
+
};
|
|
1101
|
+
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
1102
|
+
return invokeHelper(ipc, method, params, true);
|
|
1135
1103
|
};
|
|
1136
1104
|
|
|
1137
1105
|
const commands = Object.create(null);
|
|
1138
|
-
const registerCommand = (key, fn) => {
|
|
1139
|
-
commands[key] = fn;
|
|
1140
|
-
};
|
|
1141
1106
|
const register$1 = commandMap => {
|
|
1142
|
-
|
|
1143
|
-
registerCommand(key, value);
|
|
1144
|
-
}
|
|
1107
|
+
Object.assign(commands, commandMap);
|
|
1145
1108
|
};
|
|
1146
1109
|
const getCommand = key => {
|
|
1147
1110
|
return commands[key];
|
|
@@ -1325,9 +1288,7 @@ const setPauseOnExceptions = async (protocol, value) => {
|
|
|
1325
1288
|
|
|
1326
1289
|
const {
|
|
1327
1290
|
registerDefinitionProvider,
|
|
1328
|
-
executeDefinitionProvider
|
|
1329
|
-
reset: reset$8
|
|
1330
|
-
} = create$9({
|
|
1291
|
+
executeDefinitionProvider} = create$9({
|
|
1331
1292
|
name: 'Definition',
|
|
1332
1293
|
resultShape: {
|
|
1333
1294
|
allowUndefined: true,
|
|
@@ -1448,9 +1409,7 @@ const getPathSeparator = protocol => {
|
|
|
1448
1409
|
|
|
1449
1410
|
const {
|
|
1450
1411
|
registerFormattingProvider,
|
|
1451
|
-
executeFormattingProvider
|
|
1452
|
-
reset: reset$7
|
|
1453
|
-
} = create$9({
|
|
1412
|
+
executeFormattingProvider} = create$9({
|
|
1454
1413
|
name: 'Formatting',
|
|
1455
1414
|
executeKey: 'format',
|
|
1456
1415
|
resultShape: {
|
|
@@ -1510,9 +1469,7 @@ const getPosition = (textDocument, offset) => {
|
|
|
1510
1469
|
|
|
1511
1470
|
const {
|
|
1512
1471
|
registerHoverProvider,
|
|
1513
|
-
executeHoverProvider
|
|
1514
|
-
reset: reset$6
|
|
1515
|
-
} = create$9({
|
|
1472
|
+
executeHoverProvider} = create$9({
|
|
1516
1473
|
name: 'Hover',
|
|
1517
1474
|
resultShape: {
|
|
1518
1475
|
allowUndefined: true,
|
|
@@ -1523,9 +1480,7 @@ const {
|
|
|
1523
1480
|
|
|
1524
1481
|
const {
|
|
1525
1482
|
registerImplementationProvider,
|
|
1526
|
-
executeImplementationProvider
|
|
1527
|
-
reset: reset$5
|
|
1528
|
-
} = create$9({
|
|
1483
|
+
executeImplementationProvider} = create$9({
|
|
1529
1484
|
name: 'Implementation',
|
|
1530
1485
|
resultShape: {
|
|
1531
1486
|
type: Array$1,
|
|
@@ -1637,9 +1592,7 @@ const showQuickPick = async ({
|
|
|
1637
1592
|
const {
|
|
1638
1593
|
registerReferenceProvider,
|
|
1639
1594
|
executeReferenceProvider,
|
|
1640
|
-
executefileReferenceProvider
|
|
1641
|
-
reset: reset$4
|
|
1642
|
-
} = create$9({
|
|
1595
|
+
executefileReferenceProvider} = create$9({
|
|
1643
1596
|
name: 'Reference',
|
|
1644
1597
|
resultShape: {
|
|
1645
1598
|
type: Array$1,
|
|
@@ -1664,9 +1617,7 @@ const {
|
|
|
1664
1617
|
const {
|
|
1665
1618
|
registerRenameProvider,
|
|
1666
1619
|
executeRenameProvider,
|
|
1667
|
-
executeprepareRenameProvider
|
|
1668
|
-
reset: reset$3
|
|
1669
|
-
} = create$9({
|
|
1620
|
+
executeprepareRenameProvider} = create$9({
|
|
1670
1621
|
name: 'Rename',
|
|
1671
1622
|
resultShape: {
|
|
1672
1623
|
type: Object$1,
|
|
@@ -1823,9 +1774,7 @@ const createRpc = ({
|
|
|
1823
1774
|
|
|
1824
1775
|
const {
|
|
1825
1776
|
registerSelectionProvider,
|
|
1826
|
-
executeSelectionProvider
|
|
1827
|
-
reset: reset$2
|
|
1828
|
-
} = create$9({
|
|
1777
|
+
executeSelectionProvider} = create$9({
|
|
1829
1778
|
name: 'Selection',
|
|
1830
1779
|
resultShape: {
|
|
1831
1780
|
allowUndefined: true,
|
|
@@ -1931,9 +1880,7 @@ const getEnabledProviderIds = async (scheme, root) => {
|
|
|
1931
1880
|
|
|
1932
1881
|
const {
|
|
1933
1882
|
registerTabCompletionProvider,
|
|
1934
|
-
executeTabCompletionProvider
|
|
1935
|
-
reset: reset$1
|
|
1936
|
-
} = create$9({
|
|
1883
|
+
executeTabCompletionProvider} = create$9({
|
|
1937
1884
|
name: 'TabCompletion',
|
|
1938
1885
|
resultShape: {
|
|
1939
1886
|
type: Object$1,
|
|
@@ -1961,7 +1908,7 @@ const executeTextSearchProvider = async (scheme, query) => {
|
|
|
1961
1908
|
try {
|
|
1962
1909
|
const textSearchProvider = state$2.textSearchProviders[scheme];
|
|
1963
1910
|
if (!textSearchProvider) {
|
|
1964
|
-
throw new Error(`
|
|
1911
|
+
throw new Error(`No text search provider for ${scheme} found`);
|
|
1965
1912
|
}
|
|
1966
1913
|
const results = await textSearchProvider.provideTextSearchResults(query);
|
|
1967
1914
|
return results;
|
|
@@ -1972,9 +1919,7 @@ const executeTextSearchProvider = async (scheme, query) => {
|
|
|
1972
1919
|
|
|
1973
1920
|
const {
|
|
1974
1921
|
registerTypeDefinitionProvider,
|
|
1975
|
-
executeTypeDefinitionProvider
|
|
1976
|
-
reset
|
|
1977
|
-
} = create$9({
|
|
1922
|
+
executeTypeDefinitionProvider} = create$9({
|
|
1978
1923
|
name: 'TypeDefinition',
|
|
1979
1924
|
resultShape: {
|
|
1980
1925
|
allowUndefined: true,
|
|
@@ -2256,7 +2201,7 @@ const api = {
|
|
|
2256
2201
|
// Code Action
|
|
2257
2202
|
registerCodeActionsProvider: registerCodeActionProvider,
|
|
2258
2203
|
// Command
|
|
2259
|
-
registerCommand: registerCommand
|
|
2204
|
+
registerCommand: registerCommand,
|
|
2260
2205
|
executeCommand: executeCommand,
|
|
2261
2206
|
// Completion
|
|
2262
2207
|
registerCompletionProvider: registerCompletionProvider,
|
package/package.json
CHANGED