@lvce-editor/output-view 1.9.0 → 1.11.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/outputViewWorkerMain.js +190 -21
- package/package.json +1 -1
|
@@ -54,6 +54,49 @@ class VError extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
class AssertionError extends Error {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(message);
|
|
60
|
+
this.name = 'AssertionError';
|
|
61
|
+
}
|
|
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;
|
|
71
|
+
const getType = value => {
|
|
72
|
+
switch (typeof value) {
|
|
73
|
+
case 'number':
|
|
74
|
+
return Number$1;
|
|
75
|
+
case 'function':
|
|
76
|
+
return Function;
|
|
77
|
+
case 'string':
|
|
78
|
+
return String;
|
|
79
|
+
case 'object':
|
|
80
|
+
if (value === null) {
|
|
81
|
+
return Null;
|
|
82
|
+
}
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
return Array$1;
|
|
85
|
+
}
|
|
86
|
+
return Object$1;
|
|
87
|
+
case 'boolean':
|
|
88
|
+
return Boolean$1;
|
|
89
|
+
default:
|
|
90
|
+
return Unknown;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const number = value => {
|
|
94
|
+
const type = getType(value);
|
|
95
|
+
if (type !== Number$1) {
|
|
96
|
+
throw new AssertionError('expected value to be of type number');
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
57
100
|
const isMessagePort = value => {
|
|
58
101
|
return value && value instanceof MessagePort;
|
|
59
102
|
};
|
|
@@ -478,7 +521,7 @@ const set$5 = (id, fn) => {
|
|
|
478
521
|
const get$2 = id => {
|
|
479
522
|
return callbacks[id];
|
|
480
523
|
};
|
|
481
|
-
const remove = id => {
|
|
524
|
+
const remove$1 = id => {
|
|
482
525
|
delete callbacks[id];
|
|
483
526
|
};
|
|
484
527
|
let id = 0;
|
|
@@ -663,7 +706,7 @@ const resolve = (id, response) => {
|
|
|
663
706
|
return;
|
|
664
707
|
}
|
|
665
708
|
fn(response);
|
|
666
|
-
remove(id);
|
|
709
|
+
remove$1(id);
|
|
667
710
|
};
|
|
668
711
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
669
712
|
const getErrorType = prettyError => {
|
|
@@ -1066,9 +1109,11 @@ const {
|
|
|
1066
1109
|
wrapGetter
|
|
1067
1110
|
} = create$2();
|
|
1068
1111
|
|
|
1069
|
-
const create$1 = (id, uri, x, y, width, height, platform) => {
|
|
1112
|
+
const create$1 = (id, uri, x, y, width, height, platform, parentId) => {
|
|
1113
|
+
number(parentId);
|
|
1070
1114
|
const state = {
|
|
1071
1115
|
uid: id,
|
|
1116
|
+
parentId,
|
|
1072
1117
|
uri,
|
|
1073
1118
|
focusedIndex: -2,
|
|
1074
1119
|
message: '',
|
|
@@ -1096,19 +1141,24 @@ const create$1 = (id, uri, x, y, width, height, platform) => {
|
|
|
1096
1141
|
set$4(id, state, state);
|
|
1097
1142
|
};
|
|
1098
1143
|
|
|
1099
|
-
const isEqual$
|
|
1144
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1100
1145
|
return newState.inputSource === User || oldState.filterValue === newState.filterValue;
|
|
1101
1146
|
};
|
|
1102
1147
|
|
|
1148
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1149
|
+
return oldState.selectedOption === newState.selectedOption && oldState.listItems === newState.listItems;
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1103
1152
|
const isEqual = (oldState, newState) => {
|
|
1104
|
-
return oldState.
|
|
1153
|
+
return oldState.selectedOption === newState.selectedOption;
|
|
1105
1154
|
};
|
|
1106
1155
|
|
|
1107
1156
|
const RenderItems = 1;
|
|
1108
1157
|
const RenderFilterValue = 2;
|
|
1158
|
+
const RenderSelectedItem = 3;
|
|
1109
1159
|
|
|
1110
|
-
const modules = [isEqual, isEqual$
|
|
1111
|
-
const numbers = [RenderItems, RenderFilterValue];
|
|
1160
|
+
const modules = [isEqual$1, isEqual$2, isEqual];
|
|
1161
|
+
const numbers = [RenderItems, RenderFilterValue, RenderSelectedItem];
|
|
1112
1162
|
|
|
1113
1163
|
const diff = (oldState, newState) => {
|
|
1114
1164
|
const diffResult = [];
|
|
@@ -1294,20 +1344,84 @@ const ExtensionHost = {
|
|
|
1294
1344
|
};
|
|
1295
1345
|
const {
|
|
1296
1346
|
invoke: invoke$7,
|
|
1297
|
-
|
|
1347
|
+
invokeAndTransfer: invokeAndTransfer$7,
|
|
1348
|
+
set: set$7,
|
|
1349
|
+
dispose: dispose$7
|
|
1350
|
+
} = create(FileSystemWorker$1);
|
|
1351
|
+
const remove = async dirent => {
|
|
1352
|
+
return invoke$7('FileSystem.remove', dirent);
|
|
1353
|
+
};
|
|
1354
|
+
const readDirWithFileTypes = async uri => {
|
|
1355
|
+
return invoke$7('FileSystem.readDirWithFileTypes', uri);
|
|
1356
|
+
};
|
|
1357
|
+
const getPathSeparator = async root => {
|
|
1358
|
+
// @ts-ignore
|
|
1359
|
+
return invoke$7('FileSystem.getPathSeparator', root);
|
|
1360
|
+
};
|
|
1361
|
+
const getRealPath = async path => {
|
|
1362
|
+
return invoke$7('FileSystem.getRealPath', path);
|
|
1363
|
+
};
|
|
1364
|
+
const stat = async dirent => {
|
|
1365
|
+
return invoke$7('FileSystem.stat', dirent);
|
|
1366
|
+
};
|
|
1367
|
+
const createFile = async uri => {
|
|
1368
|
+
return invoke$7('FileSystem.writeFile', uri, '');
|
|
1369
|
+
};
|
|
1298
1370
|
const readFile$1 = async uri => {
|
|
1299
1371
|
return invoke$7('FileSystem.readFile', uri);
|
|
1300
1372
|
};
|
|
1301
1373
|
const writeFile$1 = async (uri, content) => {
|
|
1302
1374
|
return invoke$7('FileSystem.writeFile', uri, content);
|
|
1303
1375
|
};
|
|
1376
|
+
const mkdir = async uri => {
|
|
1377
|
+
return invoke$7('FileSystem.mkdir', uri);
|
|
1378
|
+
};
|
|
1379
|
+
const rename = async (oldUri, newUri) => {
|
|
1380
|
+
return invoke$7('FileSystem.rename', oldUri, newUri);
|
|
1381
|
+
};
|
|
1382
|
+
const copy = async (oldUri, newUri) => {
|
|
1383
|
+
return invoke$7('FileSystem.copy', oldUri, newUri);
|
|
1384
|
+
};
|
|
1385
|
+
const exists = async uri => {
|
|
1386
|
+
// @ts-ignore
|
|
1387
|
+
return invoke$7('FileSystem.exists', uri);
|
|
1388
|
+
};
|
|
1389
|
+
const getFolderSize$1 = async uri => {
|
|
1390
|
+
// @ts-ignore
|
|
1391
|
+
return invoke$7('FileSystem.getFolderSize', uri);
|
|
1392
|
+
};
|
|
1393
|
+
const readFileAsBlob = async uri => {
|
|
1394
|
+
// @ts-ignore
|
|
1395
|
+
return invoke$7('FileSystem.readFileAsBlob', uri);
|
|
1396
|
+
};
|
|
1397
|
+
const appendFile = async (uri, text) => {
|
|
1398
|
+
// @ts-ignore
|
|
1399
|
+
return invoke$7('FileSystem.appendFile', uri, text);
|
|
1400
|
+
};
|
|
1304
1401
|
const FileSystemWorker = {
|
|
1305
1402
|
__proto__: null,
|
|
1403
|
+
appendFile,
|
|
1404
|
+
copy,
|
|
1405
|
+
createFile,
|
|
1406
|
+
dispose: dispose$7,
|
|
1407
|
+
exists,
|
|
1408
|
+
getFolderSize: getFolderSize$1,
|
|
1409
|
+
getPathSeparator,
|
|
1410
|
+
getRealPath,
|
|
1411
|
+
invoke: invoke$7,
|
|
1412
|
+
invokeAndTransfer: invokeAndTransfer$7,
|
|
1413
|
+
mkdir,
|
|
1414
|
+
readDirWithFileTypes,
|
|
1306
1415
|
readFile: readFile$1,
|
|
1416
|
+
readFileAsBlob,
|
|
1417
|
+
remove,
|
|
1418
|
+
rename,
|
|
1307
1419
|
set: set$7,
|
|
1420
|
+
stat,
|
|
1308
1421
|
writeFile: writeFile$1
|
|
1309
1422
|
};
|
|
1310
1423
|
const {
|
|
1424
|
+
invoke: invoke$3,
|
|
1311
1425
|
invokeAndTransfer: invokeAndTransfer$3,
|
|
1312
1426
|
set: set$3} = create(RendererWorker$1);
|
|
1313
1427
|
const sendMessagePortToFileSystemWorker$2 = async (port, rpcId) => {
|
|
@@ -1319,8 +1433,12 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
|
1319
1433
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1320
1434
|
await invokeAndTransfer$3('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1321
1435
|
};
|
|
1436
|
+
const activateByEvent$1 = event => {
|
|
1437
|
+
return invoke$3('ExtensionHostManagement.activateByEvent', event);
|
|
1438
|
+
};
|
|
1322
1439
|
const RendererWorker = {
|
|
1323
1440
|
__proto__: null,
|
|
1441
|
+
activateByEvent: activateByEvent$1,
|
|
1324
1442
|
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
|
|
1325
1443
|
sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
|
|
1326
1444
|
set: set$3};
|
|
@@ -1445,9 +1563,10 @@ const handleFilterInput = async (state, value) => {
|
|
|
1445
1563
|
};
|
|
1446
1564
|
};
|
|
1447
1565
|
|
|
1448
|
-
const
|
|
1566
|
+
const selectChannel = async (state, id) => {
|
|
1449
1567
|
const {
|
|
1450
|
-
options
|
|
1568
|
+
options,
|
|
1569
|
+
filterValue
|
|
1451
1570
|
} = state;
|
|
1452
1571
|
const matchingOption = options.find(option => option.id === id);
|
|
1453
1572
|
if (!matchingOption) {
|
|
@@ -1459,18 +1578,27 @@ const handleSelect = async (state, id) => {
|
|
|
1459
1578
|
error,
|
|
1460
1579
|
code
|
|
1461
1580
|
} = await loadLines(matchingOption.uri);
|
|
1581
|
+
const filteredItems = filterItems(lines, filterValue);
|
|
1462
1582
|
return {
|
|
1463
1583
|
...state,
|
|
1464
|
-
listItems: lines,
|
|
1465
1584
|
error,
|
|
1466
|
-
errorCode: code
|
|
1585
|
+
errorCode: code,
|
|
1586
|
+
listItems: lines,
|
|
1587
|
+
filteredItems,
|
|
1588
|
+
selectedOption: id
|
|
1467
1589
|
};
|
|
1468
1590
|
};
|
|
1469
1591
|
|
|
1592
|
+
const handleSelect = async (state, id) => {
|
|
1593
|
+
return selectChannel(state, id);
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1470
1596
|
const {
|
|
1471
1597
|
sendMessagePortToExtensionHostWorker,
|
|
1472
1598
|
sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1,
|
|
1473
|
-
set: set$1
|
|
1599
|
+
set: set$1,
|
|
1600
|
+
activateByEvent
|
|
1601
|
+
} = RendererWorker;
|
|
1474
1602
|
|
|
1475
1603
|
const sendMessagePortToExtensionHostWorker2 = async port => {
|
|
1476
1604
|
await sendMessagePortToExtensionHostWorker(port);
|
|
@@ -1547,17 +1675,25 @@ const loadButtons = () => {
|
|
|
1547
1675
|
}];
|
|
1548
1676
|
};
|
|
1549
1677
|
|
|
1678
|
+
const error = error => {
|
|
1679
|
+
console.error(error);
|
|
1680
|
+
};
|
|
1681
|
+
|
|
1550
1682
|
const getExtensionOptions = async () => {
|
|
1551
1683
|
try {
|
|
1684
|
+
// TODO make api more declarative:
|
|
1685
|
+
// output channels are registered in extension manifest
|
|
1686
|
+
// only downside: it might show channels for extensions that are not active
|
|
1687
|
+
await activateByEvent('onOutput');
|
|
1552
1688
|
// @ts-ignore
|
|
1553
|
-
const channels = await invoke('
|
|
1689
|
+
const channels = await invoke('Output.getEnabledProviders');
|
|
1554
1690
|
return channels;
|
|
1555
|
-
} catch {
|
|
1691
|
+
} catch (error$1) {
|
|
1692
|
+
error(error$1);
|
|
1556
1693
|
return [];
|
|
1557
1694
|
}
|
|
1558
1695
|
};
|
|
1559
1696
|
|
|
1560
|
-
// TODO load options from extensions
|
|
1561
1697
|
const loadOptions = async platform => {
|
|
1562
1698
|
const extensionOptions = await getExtensionOptions();
|
|
1563
1699
|
if (platform === Web) {
|
|
@@ -1574,6 +1710,28 @@ const loadOptions = async platform => {
|
|
|
1574
1710
|
}, ...extensionOptions];
|
|
1575
1711
|
};
|
|
1576
1712
|
|
|
1713
|
+
const watchCallbacks = Object.create(null);
|
|
1714
|
+
const registerWatchCallback = (id, fn) => {
|
|
1715
|
+
watchCallbacks[id] = fn;
|
|
1716
|
+
};
|
|
1717
|
+
const executeWatchCallBack = id => {
|
|
1718
|
+
watchCallbacks[id]();
|
|
1719
|
+
};
|
|
1720
|
+
|
|
1721
|
+
const setupChangeListener = async uri => {
|
|
1722
|
+
try {
|
|
1723
|
+
const watchId = Math.random();
|
|
1724
|
+
registerWatchCallback(watchId, () => {
|
|
1725
|
+
// TODO
|
|
1726
|
+
// console.log('channel changed')
|
|
1727
|
+
});
|
|
1728
|
+
// @ts-ignore
|
|
1729
|
+
await FileSystemWorker.invoke(/* OutputChannel.open */'FileSystem.watchFile', watchId, /* path */uri);
|
|
1730
|
+
} catch {
|
|
1731
|
+
// ignore
|
|
1732
|
+
}
|
|
1733
|
+
};
|
|
1734
|
+
|
|
1577
1735
|
const isString = value => {
|
|
1578
1736
|
return typeof value === 'string';
|
|
1579
1737
|
};
|
|
@@ -1605,6 +1763,7 @@ const loadContent = async (state, savedState) => {
|
|
|
1605
1763
|
error,
|
|
1606
1764
|
code
|
|
1607
1765
|
} = await loadLines(uri);
|
|
1766
|
+
await setupChangeListener(uri);
|
|
1608
1767
|
const buttons = loadButtons();
|
|
1609
1768
|
return {
|
|
1610
1769
|
...state,
|
|
@@ -1769,12 +1928,20 @@ const renderItems = (oldState, newState) => {
|
|
|
1769
1928
|
return ['Viewlet.setDom2', dom];
|
|
1770
1929
|
};
|
|
1771
1930
|
|
|
1931
|
+
const renderSelectedItem = (oldState, newState) => {
|
|
1932
|
+
const value = newState.selectedOption;
|
|
1933
|
+
const name = Output$2;
|
|
1934
|
+
return ['Viewlet.setValueByName', newState.parentId, name, value];
|
|
1935
|
+
};
|
|
1936
|
+
|
|
1772
1937
|
const getRenderer = diffType => {
|
|
1773
1938
|
switch (diffType) {
|
|
1774
1939
|
case RenderItems:
|
|
1775
1940
|
return renderItems;
|
|
1776
1941
|
case RenderFilterValue:
|
|
1777
1942
|
return renderFilterValue;
|
|
1943
|
+
case RenderSelectedItem:
|
|
1944
|
+
return renderSelectedItem;
|
|
1778
1945
|
default:
|
|
1779
1946
|
throw new Error('unknown renderer');
|
|
1780
1947
|
}
|
|
@@ -1948,11 +2115,17 @@ const commandMap = {
|
|
|
1948
2115
|
'Output.closeFindWidget': wrapCommand(closeFindWidget),
|
|
1949
2116
|
'Output.create': create$1,
|
|
1950
2117
|
'Output.diff2': diff2,
|
|
2118
|
+
'Output.executeWatchCallback': executeWatchCallBack,
|
|
1951
2119
|
'Output.focusIndex': wrapCommand(focusIndex),
|
|
2120
|
+
'Output.getActions': getActions,
|
|
1952
2121
|
'Output.getCommandIds': getCommandIds,
|
|
1953
2122
|
'Output.getKeyBindings': getKeyBindings,
|
|
2123
|
+
'Output.handleButtonClick': wrapCommand(handleButtonClick),
|
|
1954
2124
|
'Output.handleData': wrapCommand(handleData),
|
|
1955
2125
|
'Output.handleError': wrapCommand(handleError),
|
|
2126
|
+
'Output.selectChannel': wrapCommand(selectChannel),
|
|
2127
|
+
'Output.handleFilterInput': wrapCommand(handleFilterInput),
|
|
2128
|
+
'Output.handleSelect': wrapCommand(handleSelect),
|
|
1956
2129
|
'Output.initialize': initialize,
|
|
1957
2130
|
'Output.loadContent2': wrapCommand(loadContent),
|
|
1958
2131
|
'Output.openFindWidget': wrapCommand(openFindWidget),
|
|
@@ -1962,11 +2135,7 @@ const commandMap = {
|
|
|
1962
2135
|
'Output.resize': resize,
|
|
1963
2136
|
'Output.saveState': saveState,
|
|
1964
2137
|
'Output.setOutputChannel': wrapCommand(setOutputChannel),
|
|
1965
|
-
'Output.
|
|
1966
|
-
'Output.terminate': terminate,
|
|
1967
|
-
'Output.handleSelect': wrapCommand(handleSelect),
|
|
1968
|
-
'Output.handleFilterInput': wrapCommand(handleFilterInput),
|
|
1969
|
-
'Output.handleButtonClick': wrapCommand(handleButtonClick)
|
|
2138
|
+
'Output.terminate': terminate
|
|
1970
2139
|
};
|
|
1971
2140
|
|
|
1972
2141
|
const listen = async () => {
|