@lvce-editor/extension-detail-view 7.1.0 → 7.2.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/extensionDetailViewWorkerMain.js +1557 -1565
- package/package.json +1 -1
|
@@ -283,10 +283,7 @@ const getActivationEventsDetails = async extension => {
|
|
|
283
283
|
};
|
|
284
284
|
|
|
285
285
|
const hasProperty = (object, key) => {
|
|
286
|
-
|
|
287
|
-
return false;
|
|
288
|
-
}
|
|
289
|
-
return true;
|
|
286
|
+
return !!object && typeof object === 'object' && key in object;
|
|
290
287
|
};
|
|
291
288
|
|
|
292
289
|
const featureActivationEventsEnabled = extension => {
|
|
@@ -591,7 +588,6 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
591
588
|
patches.push({
|
|
592
589
|
type: NavigateParent
|
|
593
590
|
});
|
|
594
|
-
currentChildIndex = -1;
|
|
595
591
|
}
|
|
596
592
|
// Add remove patches in reverse order (highest index first)
|
|
597
593
|
// This ensures indices remain valid as we remove
|
|
@@ -1443,1771 +1439,1771 @@ const string = value => {
|
|
|
1443
1439
|
}
|
|
1444
1440
|
};
|
|
1445
1441
|
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
super(`Command not found ${command}`);
|
|
1449
|
-
this.name = 'CommandNotFoundError';
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
const commands = Object.create(null);
|
|
1453
|
-
const register = commandMap => {
|
|
1454
|
-
Object.assign(commands, commandMap);
|
|
1442
|
+
const isMessagePort = value => {
|
|
1443
|
+
return value && value instanceof MessagePort;
|
|
1455
1444
|
};
|
|
1456
|
-
const
|
|
1457
|
-
return
|
|
1445
|
+
const isMessagePortMain = value => {
|
|
1446
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
1458
1447
|
};
|
|
1459
|
-
const
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1448
|
+
const isOffscreenCanvas = value => {
|
|
1449
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
1450
|
+
};
|
|
1451
|
+
const isInstanceOf = (value, constructorName) => {
|
|
1452
|
+
return value?.constructor?.name === constructorName;
|
|
1453
|
+
};
|
|
1454
|
+
const isSocket = value => {
|
|
1455
|
+
return isInstanceOf(value, 'Socket');
|
|
1456
|
+
};
|
|
1457
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
1458
|
+
const isTransferrable = value => {
|
|
1459
|
+
for (const fn of transferrables) {
|
|
1460
|
+
if (fn(value)) {
|
|
1461
|
+
return true;
|
|
1462
|
+
}
|
|
1463
1463
|
}
|
|
1464
|
-
return
|
|
1464
|
+
return false;
|
|
1465
1465
|
};
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1466
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
1467
|
+
if (!value) {
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
if (isTransferrable(value)) {
|
|
1471
|
+
transferrables.push(value);
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
if (Array.isArray(value)) {
|
|
1475
|
+
for (const item of value) {
|
|
1476
|
+
walkValue(item, transferrables, isTransferrable);
|
|
1476
1477
|
}
|
|
1477
|
-
return
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
if (typeof value === 'object') {
|
|
1481
|
+
for (const property of Object.values(value)) {
|
|
1482
|
+
walkValue(property, transferrables, isTransferrable);
|
|
1483
|
+
}
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
const getTransferrables = value => {
|
|
1488
|
+
const transferrables = [];
|
|
1489
|
+
walkValue(value, transferrables, isTransferrable);
|
|
1490
|
+
return transferrables;
|
|
1491
|
+
};
|
|
1492
|
+
const attachEvents = that => {
|
|
1493
|
+
const handleMessage = (...args) => {
|
|
1494
|
+
const data = that.getData(...args);
|
|
1495
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
1496
|
+
data
|
|
1497
|
+
}));
|
|
1478
1498
|
};
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
invokeAndTransfer: invoke
|
|
1499
|
+
that.onMessage(handleMessage);
|
|
1500
|
+
const handleClose = event => {
|
|
1501
|
+
that.dispatchEvent(new Event('close'));
|
|
1483
1502
|
};
|
|
1484
|
-
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
const rpcs = Object.create(null);
|
|
1488
|
-
const set$a = (id, rpc) => {
|
|
1489
|
-
rpcs[id] = rpc;
|
|
1503
|
+
that.onClose(handleClose);
|
|
1490
1504
|
};
|
|
1491
|
-
|
|
1492
|
-
|
|
1505
|
+
class Ipc extends EventTarget {
|
|
1506
|
+
constructor(rawIpc) {
|
|
1507
|
+
super();
|
|
1508
|
+
this._rawIpc = rawIpc;
|
|
1509
|
+
attachEvents(this);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1513
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1514
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1515
|
+
const NewLine$1 = '\n';
|
|
1516
|
+
const joinLines$1 = lines => {
|
|
1517
|
+
return lines.join(NewLine$1);
|
|
1493
1518
|
};
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1519
|
+
const RE_AT = /^\s+at/;
|
|
1520
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
1521
|
+
const isNormalStackLine = line => {
|
|
1522
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
1496
1523
|
};
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
return rpc.invoke(method, ...params);
|
|
1510
|
-
},
|
|
1511
|
-
// @ts-ignore
|
|
1512
|
-
invokeAndTransfer(method, ...params) {
|
|
1513
|
-
const rpc = get$3(rpcId);
|
|
1514
|
-
// @ts-ignore
|
|
1515
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1516
|
-
},
|
|
1517
|
-
registerMockRpc(commandMap) {
|
|
1518
|
-
const mockRpc = createMockRpc({
|
|
1519
|
-
commandMap
|
|
1520
|
-
});
|
|
1521
|
-
set$a(rpcId, mockRpc);
|
|
1522
|
-
// @ts-ignore
|
|
1523
|
-
mockRpc[Symbol.dispose] = () => {
|
|
1524
|
-
remove$1(rpcId);
|
|
1525
|
-
};
|
|
1526
|
-
// @ts-ignore
|
|
1527
|
-
return mockRpc;
|
|
1528
|
-
},
|
|
1529
|
-
set(rpc) {
|
|
1530
|
-
set$a(rpcId, rpc);
|
|
1524
|
+
const getDetails = lines => {
|
|
1525
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
1526
|
+
if (index === -1) {
|
|
1527
|
+
return {
|
|
1528
|
+
actualMessage: joinLines$1(lines),
|
|
1529
|
+
rest: []
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
let lastIndex = index - 1;
|
|
1533
|
+
while (++lastIndex < lines.length) {
|
|
1534
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
1535
|
+
break;
|
|
1531
1536
|
}
|
|
1537
|
+
}
|
|
1538
|
+
return {
|
|
1539
|
+
actualMessage: lines[index - 1],
|
|
1540
|
+
rest: lines.slice(index, lastIndex)
|
|
1532
1541
|
};
|
|
1533
1542
|
};
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
invoke: invoke$5,
|
|
1537
|
-
set: set$9
|
|
1538
|
-
} = create$a(ExtensionHostWorker);
|
|
1539
|
-
const getRuntimeStatus$2 = async extensionId => {
|
|
1540
|
-
// @ts-ignore
|
|
1541
|
-
return invoke$5('ExtensionHost.getRuntimeStatus', extensionId);
|
|
1542
|
-
};
|
|
1543
|
-
|
|
1544
|
-
const ExtensionHost = {
|
|
1545
|
-
__proto__: null,
|
|
1546
|
-
getRuntimeStatus: getRuntimeStatus$2,
|
|
1547
|
-
invoke: invoke$5,
|
|
1548
|
-
set: set$9
|
|
1543
|
+
const splitLines$1 = lines => {
|
|
1544
|
+
return lines.split(NewLine$1);
|
|
1549
1545
|
};
|
|
1550
|
-
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
} = create$a(ExtensionManagementWorker);
|
|
1555
|
-
const enable2 = (id, platform) => {
|
|
1556
|
-
return invoke$4(`Extensions.enable2`, id, platform);
|
|
1546
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
1547
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
1548
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
1549
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
1557
1550
|
};
|
|
1558
|
-
const
|
|
1559
|
-
return
|
|
1551
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
1552
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
1560
1553
|
};
|
|
1561
|
-
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
const
|
|
1567
|
-
return
|
|
1554
|
+
const getMessageCodeBlock = stderr => {
|
|
1555
|
+
const lines = splitLines$1(stderr);
|
|
1556
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
1557
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1558
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
1559
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
1560
|
+
return relevantMessage;
|
|
1568
1561
|
};
|
|
1569
|
-
const
|
|
1570
|
-
return
|
|
1562
|
+
const isModuleNotFoundMessage = line => {
|
|
1563
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
1571
1564
|
};
|
|
1572
|
-
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1565
|
+
const getModuleNotFoundError = stderr => {
|
|
1566
|
+
const lines = splitLines$1(stderr);
|
|
1567
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1568
|
+
const message = lines[messageIndex];
|
|
1569
|
+
return {
|
|
1570
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
1571
|
+
message
|
|
1572
|
+
};
|
|
1579
1573
|
};
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
const getVirtualDom$1 = async html => {
|
|
1586
|
-
// @ts-ignore
|
|
1587
|
-
return invoke$2('Markdown.getVirtualDom', html);
|
|
1574
|
+
const isModuleNotFoundError = stderr => {
|
|
1575
|
+
if (!stderr) {
|
|
1576
|
+
return false;
|
|
1577
|
+
}
|
|
1578
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
1588
1579
|
};
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1591
|
-
|
|
1580
|
+
const isModulesSyntaxError = stderr => {
|
|
1581
|
+
if (!stderr) {
|
|
1582
|
+
return false;
|
|
1583
|
+
}
|
|
1584
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
1592
1585
|
};
|
|
1593
|
-
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
invoke: invoke$2,
|
|
1598
|
-
render: render$1,
|
|
1599
|
-
set: set$6
|
|
1586
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
1587
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
1588
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
1589
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
1600
1590
|
};
|
|
1601
|
-
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
}
|
|
1607
|
-
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1608
|
-
number(uid);
|
|
1609
|
-
number(menuId);
|
|
1610
|
-
number(x);
|
|
1611
|
-
number(y);
|
|
1612
|
-
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1613
|
-
};
|
|
1614
|
-
const setColorTheme$1 = async id => {
|
|
1615
|
-
return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
1616
|
-
};
|
|
1617
|
-
const sendMessagePortToMarkdownWorker$1 = async (port, rpcId) => {
|
|
1618
|
-
const command = 'Markdown.handleMessagePort';
|
|
1619
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
|
|
1620
|
-
};
|
|
1621
|
-
const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
|
|
1622
|
-
const command = 'FileSystem.handleMessagePort';
|
|
1623
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1624
|
-
};
|
|
1625
|
-
const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
1626
|
-
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1627
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1628
|
-
};
|
|
1629
|
-
const confirm = async (message, options) => {
|
|
1630
|
-
const result = await invoke$1('ConfirmPrompt.prompt', message, options);
|
|
1631
|
-
return result;
|
|
1632
|
-
};
|
|
1633
|
-
const writeClipBoardText = async text => {
|
|
1634
|
-
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
1635
|
-
};
|
|
1636
|
-
const writeClipBoardImage = async blob => {
|
|
1637
|
-
await invoke$1('ClipBoard.writeImage', /* text */blob);
|
|
1638
|
-
};
|
|
1639
|
-
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
1640
|
-
const command = 'Extensions.handleMessagePort';
|
|
1641
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1642
|
-
};
|
|
1643
|
-
const getPreference = async key => {
|
|
1644
|
-
return await invoke$1('Preferences.get', key);
|
|
1645
|
-
};
|
|
1646
|
-
const getAllExtensions$1 = async () => {
|
|
1647
|
-
return invoke$1('ExtensionManagement.getAllExtensions');
|
|
1648
|
-
};
|
|
1649
|
-
const getExtension$2 = async id => {
|
|
1650
|
-
return invoke$1('ExtensionManagement.getExtension', id);
|
|
1651
|
-
};
|
|
1652
|
-
const openNativeFolder = async uri => {
|
|
1653
|
-
await invoke$1('OpenNativeFolder.openNativeFolder', uri);
|
|
1654
|
-
};
|
|
1655
|
-
const uninstallExtension = async id => {
|
|
1656
|
-
return invoke$1('ExtensionManagement.uninstall', id);
|
|
1657
|
-
};
|
|
1658
|
-
const openExtensionSearch$1 = async () => {
|
|
1659
|
-
return invoke$1('SideBar.openViewlet', 'Extensions');
|
|
1660
|
-
};
|
|
1661
|
-
const setExtensionsSearchValue = async searchValue => {
|
|
1662
|
-
return invoke$1('Extensions.handleInput', searchValue, Script$1);
|
|
1663
|
-
};
|
|
1664
|
-
const openExternal$1 = async uri => {
|
|
1665
|
-
await invoke$1('Open.openExternal', uri);
|
|
1666
|
-
};
|
|
1667
|
-
const openUrl = async uri => {
|
|
1668
|
-
await invoke$1('Open.openUrl', uri);
|
|
1669
|
-
};
|
|
1670
|
-
|
|
1671
|
-
/* eslint-disable unicorn/prefer-export-from */
|
|
1672
|
-
|
|
1673
|
-
const {
|
|
1674
|
-
getRuntimeStatus: getRuntimeStatus$1,
|
|
1675
|
-
set: set$4
|
|
1676
|
-
} = ExtensionHost;
|
|
1677
|
-
|
|
1678
|
-
const getRuntimeStatus = async extensionId => {
|
|
1679
|
-
// @ts-ignore
|
|
1680
|
-
const status = await getRuntimeStatus$1(extensionId);
|
|
1681
|
-
// @ts-ignore
|
|
1682
|
-
return status;
|
|
1591
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
1592
|
+
const message = getMessageCodeBlock(stderr);
|
|
1593
|
+
return {
|
|
1594
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
1595
|
+
message: `Incompatible native node module: ${message}`
|
|
1596
|
+
};
|
|
1683
1597
|
};
|
|
1684
|
-
|
|
1685
|
-
const getRuntimeStatusDetails = async extension => {
|
|
1686
|
-
const {
|
|
1687
|
-
activationEvent,
|
|
1688
|
-
activationTime,
|
|
1689
|
-
importTime,
|
|
1690
|
-
status
|
|
1691
|
-
} = await getRuntimeStatus(extension.id);
|
|
1598
|
+
const getModuleSyntaxError = () => {
|
|
1692
1599
|
return {
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
status,
|
|
1696
|
-
wasActivatedByEvent: activationEvent
|
|
1600
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
1601
|
+
message: `ES Modules are not supported in electron`
|
|
1697
1602
|
};
|
|
1698
1603
|
};
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
return false;
|
|
1604
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
1605
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
1606
|
+
return getNativeModuleErrorMessage(stderr);
|
|
1703
1607
|
}
|
|
1704
|
-
if (
|
|
1705
|
-
return
|
|
1608
|
+
if (isModulesSyntaxError(stderr)) {
|
|
1609
|
+
return getModuleSyntaxError();
|
|
1706
1610
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
const formatTime = time => {
|
|
1711
|
-
return time.toFixed(2) + 'ms';
|
|
1712
|
-
};
|
|
1713
|
-
|
|
1714
|
-
const getActivationTimeVirtualDom = (importTime$1, activationTime$1) => {
|
|
1715
|
-
if (!activationTime$1 && !importTime$1) {
|
|
1716
|
-
return [];
|
|
1611
|
+
if (isModuleNotFoundError(stderr)) {
|
|
1612
|
+
return getModuleNotFoundError(stderr);
|
|
1717
1613
|
}
|
|
1718
|
-
const
|
|
1719
|
-
const
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
type: Dt
|
|
1729
|
-
}, text(activationTime()), {
|
|
1730
|
-
childCount: 1,
|
|
1731
|
-
type: Dd
|
|
1732
|
-
}, text(formattedTime)];
|
|
1614
|
+
const lines = splitLines$1(stderr);
|
|
1615
|
+
const {
|
|
1616
|
+
actualMessage,
|
|
1617
|
+
rest
|
|
1618
|
+
} = getDetails(lines);
|
|
1619
|
+
return {
|
|
1620
|
+
code: '',
|
|
1621
|
+
message: actualMessage,
|
|
1622
|
+
stack: rest
|
|
1623
|
+
};
|
|
1733
1624
|
};
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
const
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1625
|
+
class IpcError extends VError {
|
|
1626
|
+
// @ts-ignore
|
|
1627
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
1628
|
+
if (stdout || stderr) {
|
|
1629
|
+
// @ts-ignore
|
|
1630
|
+
const {
|
|
1631
|
+
code,
|
|
1632
|
+
message,
|
|
1633
|
+
stack
|
|
1634
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
1635
|
+
const cause = new Error(message);
|
|
1636
|
+
// @ts-ignore
|
|
1637
|
+
cause.code = code;
|
|
1638
|
+
cause.stack = stack;
|
|
1639
|
+
super(cause, betterMessage);
|
|
1640
|
+
} else {
|
|
1641
|
+
super(betterMessage);
|
|
1642
|
+
}
|
|
1643
|
+
// @ts-ignore
|
|
1644
|
+
this.name = 'IpcError';
|
|
1645
|
+
// @ts-ignore
|
|
1646
|
+
this.stdout = stdout;
|
|
1647
|
+
// @ts-ignore
|
|
1648
|
+
this.stderr = stderr;
|
|
1755
1649
|
}
|
|
1650
|
+
}
|
|
1651
|
+
const readyMessage = 'ready';
|
|
1652
|
+
const getData$2 = event => {
|
|
1653
|
+
return event.data;
|
|
1756
1654
|
};
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
const value = {
|
|
1764
|
-
childCount: 1,
|
|
1765
|
-
className: 'RuntimeStatusDefinitionListValue',
|
|
1766
|
-
type: Dd
|
|
1655
|
+
const listen$7 = () => {
|
|
1656
|
+
// @ts-ignore
|
|
1657
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1658
|
+
throw new TypeError('module is not in web worker scope');
|
|
1659
|
+
}
|
|
1660
|
+
return globalThis;
|
|
1767
1661
|
};
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
const statusValue = getStatusMessage(status$1);
|
|
1771
|
-
return [key, text(`${statusKey}: `), value, text(`${statusValue}`)];
|
|
1662
|
+
const signal$8 = global => {
|
|
1663
|
+
global.postMessage(readyMessage);
|
|
1772
1664
|
};
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
childCount += 2; // status
|
|
1777
|
-
if (importTime || activationTime) {
|
|
1778
|
-
childCount += 4;
|
|
1665
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
1666
|
+
getData(event) {
|
|
1667
|
+
return getData$2(event);
|
|
1779
1668
|
}
|
|
1780
|
-
|
|
1669
|
+
send(message) {
|
|
1670
|
+
// @ts-ignore
|
|
1671
|
+
this._rawIpc.postMessage(message);
|
|
1672
|
+
}
|
|
1673
|
+
sendAndTransfer(message) {
|
|
1674
|
+
const transfer = getTransferrables(message);
|
|
1675
|
+
// @ts-ignore
|
|
1676
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1677
|
+
}
|
|
1678
|
+
dispose() {
|
|
1679
|
+
// ignore
|
|
1680
|
+
}
|
|
1681
|
+
onClose(callback) {
|
|
1682
|
+
// ignore
|
|
1683
|
+
}
|
|
1684
|
+
onMessage(callback) {
|
|
1685
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
const wrap$f = global => {
|
|
1689
|
+
return new IpcChildWithModuleWorker(global);
|
|
1781
1690
|
};
|
|
1782
|
-
const
|
|
1691
|
+
const waitForFirstMessage = async port => {
|
|
1783
1692
|
const {
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
type: Div
|
|
1794
|
-
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
1795
|
-
childCount,
|
|
1796
|
-
className: 'RuntimeStatusDefinitionList',
|
|
1797
|
-
type: Dl
|
|
1798
|
-
}, ...getStatusVirtualDom(status), ...getActivationTimeVirtualDom(activationTime, importTime)];
|
|
1799
|
-
};
|
|
1800
|
-
|
|
1801
|
-
const getSettingsTableEntry = setting => {
|
|
1802
|
-
const {
|
|
1803
|
-
id,
|
|
1804
|
-
label
|
|
1805
|
-
} = setting;
|
|
1806
|
-
// TODO watch out for null/undefined/number/string/array
|
|
1807
|
-
return [{
|
|
1808
|
-
type: Text,
|
|
1809
|
-
value: id
|
|
1810
|
-
}, {
|
|
1811
|
-
type: Text,
|
|
1812
|
-
value: label
|
|
1813
|
-
}];
|
|
1814
|
-
};
|
|
1815
|
-
|
|
1816
|
-
const getSettingsDetails = async extension => {
|
|
1817
|
-
const settings = extension.settings || [];
|
|
1818
|
-
const rows = settings.map(getSettingsTableEntry);
|
|
1819
|
-
return {
|
|
1820
|
-
settings: rows
|
|
1821
|
-
};
|
|
1693
|
+
promise,
|
|
1694
|
+
resolve
|
|
1695
|
+
} = Promise.withResolvers();
|
|
1696
|
+
port.addEventListener('message', resolve, {
|
|
1697
|
+
once: true
|
|
1698
|
+
});
|
|
1699
|
+
const event = await promise;
|
|
1700
|
+
// @ts-ignore
|
|
1701
|
+
return event.data;
|
|
1822
1702
|
};
|
|
1823
|
-
|
|
1824
|
-
const
|
|
1825
|
-
|
|
1826
|
-
|
|
1703
|
+
const listen$6 = async () => {
|
|
1704
|
+
const parentIpcRaw = listen$7();
|
|
1705
|
+
signal$8(parentIpcRaw);
|
|
1706
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
1707
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
1708
|
+
if (firstMessage.method !== 'initialize') {
|
|
1709
|
+
throw new IpcError('unexpected first message');
|
|
1827
1710
|
}
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1711
|
+
const type = firstMessage.params[0];
|
|
1712
|
+
if (type === 'message-port') {
|
|
1713
|
+
parentIpc.send({
|
|
1714
|
+
id: firstMessage.id,
|
|
1715
|
+
jsonrpc: '2.0',
|
|
1716
|
+
result: null
|
|
1717
|
+
});
|
|
1718
|
+
parentIpc.dispose();
|
|
1719
|
+
const port = firstMessage.params[1];
|
|
1720
|
+
return port;
|
|
1721
|
+
}
|
|
1722
|
+
return globalThis;
|
|
1838
1723
|
};
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1724
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
1725
|
+
getData(event) {
|
|
1726
|
+
return getData$2(event);
|
|
1727
|
+
}
|
|
1728
|
+
send(message) {
|
|
1729
|
+
this._rawIpc.postMessage(message);
|
|
1730
|
+
}
|
|
1731
|
+
sendAndTransfer(message) {
|
|
1732
|
+
const transfer = getTransferrables(message);
|
|
1733
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1734
|
+
}
|
|
1735
|
+
dispose() {
|
|
1736
|
+
if (this._rawIpc.close) {
|
|
1737
|
+
this._rawIpc.close();
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
onClose(callback) {
|
|
1741
|
+
// ignore
|
|
1742
|
+
}
|
|
1743
|
+
onMessage(callback) {
|
|
1744
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1745
|
+
this._rawIpc.start();
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
const wrap$e = port => {
|
|
1749
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1848
1750
|
};
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1751
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
1752
|
+
__proto__: null,
|
|
1753
|
+
listen: listen$6,
|
|
1754
|
+
wrap: wrap$e
|
|
1852
1755
|
};
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
const HandleClickSettings = 6;
|
|
1860
|
-
const HandleClickSize = 7;
|
|
1861
|
-
const HandleClickUninstall = 8;
|
|
1862
|
-
const HandleFeaturesClick = 9;
|
|
1863
|
-
const HandleIconError = 10;
|
|
1864
|
-
const HandleImageContextMenu = 11;
|
|
1865
|
-
const HandleReadmeContextMenu = 12;
|
|
1866
|
-
const HandleReadmeScroll = 13;
|
|
1867
|
-
const HandleTabsClick = 14;
|
|
1868
|
-
const HandleAdditionalDetailContextMenu = 15;
|
|
1869
|
-
const HandleReadmeClick = 16;
|
|
1870
|
-
const HandleSelectionChange = 17;
|
|
1871
|
-
const HandleTabFocus = 18;
|
|
1872
|
-
const HandleResourceLinkClick = 19;
|
|
1873
|
-
|
|
1874
|
-
const ActivationEvents = 'ActivationEvents';
|
|
1875
|
-
const Changelog = 'Changelog';
|
|
1876
|
-
const Commands = 'Commands';
|
|
1877
|
-
const Details = 'Details';
|
|
1878
|
-
const Enable = 'Enable';
|
|
1879
|
-
const Disable = 'Disable';
|
|
1880
|
-
const Features = 'Features';
|
|
1881
|
-
const JsonValidation = 'JsonValidation';
|
|
1882
|
-
const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
1883
|
-
const RuntimeStatus = 'RuntimeStatus';
|
|
1884
|
-
const ScrollToTop = 'scrolltotop';
|
|
1885
|
-
const SetColorTheme = 'SetColorTheme';
|
|
1886
|
-
const Settings = 'Settings';
|
|
1887
|
-
const Theme = 'Theme';
|
|
1888
|
-
const Uninstall = 'Uninstall';
|
|
1889
|
-
const WebViews = 'WebViews';
|
|
1890
|
-
|
|
1891
|
-
const getScrollToTopVirtualDom = scrollToTopButtonEnabled => {
|
|
1892
|
-
return [{
|
|
1893
|
-
ariaLabel: scrollToTop(),
|
|
1894
|
-
childCount: 1,
|
|
1895
|
-
className: ScrollToTopButton,
|
|
1896
|
-
name: ScrollToTop,
|
|
1897
|
-
onClick: HandleClickScrollToTop,
|
|
1898
|
-
type: Button$1
|
|
1899
|
-
}, {
|
|
1900
|
-
childCount: 0,
|
|
1901
|
-
className: mergeClassNames(MaskIcon, MaskIconChevronUp),
|
|
1902
|
-
role: None$3,
|
|
1903
|
-
type: Div
|
|
1904
|
-
}];
|
|
1756
|
+
const addListener = (emitter, type, callback) => {
|
|
1757
|
+
if ('addEventListener' in emitter) {
|
|
1758
|
+
emitter.addEventListener(type, callback);
|
|
1759
|
+
} else {
|
|
1760
|
+
emitter.on(type, callback);
|
|
1761
|
+
}
|
|
1905
1762
|
};
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
render,
|
|
1912
|
-
set: set$3
|
|
1913
|
-
} = MarkdownWorker;
|
|
1914
|
-
|
|
1915
|
-
const getMarkdownVirtualDom = async (html, options) => {
|
|
1916
|
-
string(html);
|
|
1917
|
-
const dom = await getVirtualDom(html);
|
|
1918
|
-
if (options?.scrollToTopEnabled) {
|
|
1919
|
-
const [firstNode, ...rest] = dom;
|
|
1920
|
-
const extraDom = getScrollToTopVirtualDom();
|
|
1921
|
-
return [{
|
|
1922
|
-
...firstNode,
|
|
1923
|
-
childCount: firstNode.childCount + 1,
|
|
1924
|
-
onClick: HandleReadmeClick,
|
|
1925
|
-
onScroll: HandleReadmeScroll,
|
|
1926
|
-
onSelectionChange: HandleSelectionChange
|
|
1927
|
-
}, ...extraDom, ...rest];
|
|
1763
|
+
const removeListener = (emitter, type, callback) => {
|
|
1764
|
+
if ('removeEventListener' in emitter) {
|
|
1765
|
+
emitter.removeEventListener(type, callback);
|
|
1766
|
+
} else {
|
|
1767
|
+
emitter.off(type, callback);
|
|
1928
1768
|
}
|
|
1929
|
-
return dom;
|
|
1930
1769
|
};
|
|
1931
|
-
|
|
1932
|
-
const
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1770
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1771
|
+
const {
|
|
1772
|
+
promise,
|
|
1773
|
+
resolve
|
|
1774
|
+
} = Promise.withResolvers();
|
|
1775
|
+
const listenerMap = Object.create(null);
|
|
1776
|
+
const cleanup = value => {
|
|
1777
|
+
for (const event of Object.keys(eventMap)) {
|
|
1778
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
1940
1779
|
}
|
|
1780
|
+
resolve(value);
|
|
1781
|
+
};
|
|
1782
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
1783
|
+
const listener = event => {
|
|
1784
|
+
cleanup({
|
|
1785
|
+
event,
|
|
1786
|
+
type
|
|
1787
|
+
});
|
|
1788
|
+
};
|
|
1789
|
+
addListener(eventEmitter, event, listener);
|
|
1790
|
+
listenerMap[event] = listener;
|
|
1941
1791
|
}
|
|
1942
|
-
return
|
|
1943
|
-
};
|
|
1944
|
-
|
|
1945
|
-
const getColorThemeMarkdown = themes => {
|
|
1946
|
-
const heading = 'Color Themes';
|
|
1947
|
-
return getThemeItemMarkdown(heading, themes);
|
|
1948
|
-
};
|
|
1949
|
-
const getIconThemeMarkdown = iconThemes => {
|
|
1950
|
-
const heading = 'File Icon Themes';
|
|
1951
|
-
return getThemeItemMarkdown(heading, iconThemes);
|
|
1952
|
-
};
|
|
1953
|
-
const getProductIconThemeMarkdown = iconThemes => {
|
|
1954
|
-
const heading = 'Product Icon Themes';
|
|
1955
|
-
return getThemeItemMarkdown(heading, iconThemes);
|
|
1792
|
+
return promise;
|
|
1956
1793
|
};
|
|
1957
|
-
const
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1794
|
+
const Message$1 = 3;
|
|
1795
|
+
const create$5$1 = async ({
|
|
1796
|
+
isMessagePortOpen,
|
|
1797
|
+
messagePort
|
|
1798
|
+
}) => {
|
|
1799
|
+
if (!isMessagePort(messagePort)) {
|
|
1800
|
+
throw new IpcError('port must be of type MessagePort');
|
|
1801
|
+
}
|
|
1802
|
+
if (isMessagePortOpen) {
|
|
1803
|
+
return messagePort;
|
|
1804
|
+
}
|
|
1805
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
1806
|
+
message: Message$1
|
|
1807
|
+
});
|
|
1808
|
+
messagePort.start();
|
|
1809
|
+
const {
|
|
1810
|
+
event,
|
|
1811
|
+
type
|
|
1812
|
+
} = await eventPromise;
|
|
1813
|
+
if (type !== Message$1) {
|
|
1814
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
1815
|
+
}
|
|
1816
|
+
if (event.data !== readyMessage) {
|
|
1817
|
+
throw new IpcError('unexpected first message');
|
|
1818
|
+
}
|
|
1819
|
+
return messagePort;
|
|
1963
1820
|
};
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
return bytes.toString(16).padStart(2, '0');
|
|
1821
|
+
const signal$1 = messagePort => {
|
|
1822
|
+
messagePort.start();
|
|
1967
1823
|
};
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1824
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1825
|
+
getData = getData$2;
|
|
1826
|
+
send(message) {
|
|
1827
|
+
this._rawIpc.postMessage(message);
|
|
1828
|
+
}
|
|
1829
|
+
sendAndTransfer(message) {
|
|
1830
|
+
const transfer = getTransferrables(message);
|
|
1831
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1832
|
+
}
|
|
1833
|
+
dispose() {
|
|
1834
|
+
this._rawIpc.close();
|
|
1835
|
+
}
|
|
1836
|
+
onMessage(callback) {
|
|
1837
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1838
|
+
}
|
|
1839
|
+
onClose(callback) {}
|
|
1840
|
+
}
|
|
1841
|
+
const wrap$5 = messagePort => {
|
|
1842
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
1973
1843
|
};
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1844
|
+
const IpcParentWithMessagePort$1 = {
|
|
1845
|
+
__proto__: null,
|
|
1846
|
+
create: create$5$1,
|
|
1847
|
+
signal: signal$1,
|
|
1848
|
+
wrap: wrap$5
|
|
1977
1849
|
};
|
|
1978
1850
|
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
};
|
|
1984
|
-
const getMarkdownCacheKey = async (markdown, options) => {
|
|
1985
|
-
const hash = await getMarkdownCacheHash(markdown, options);
|
|
1986
|
-
if (supportsNormalCacheKey(options.locationProtocol)) {
|
|
1987
|
-
return `/markdown/${hash}`;
|
|
1851
|
+
class CommandNotFoundError extends Error {
|
|
1852
|
+
constructor(command) {
|
|
1853
|
+
super(`Command not found ${command}`);
|
|
1854
|
+
this.name = 'CommandNotFoundError';
|
|
1988
1855
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
// TODO pass application name from renderer worker to not hardcode it
|
|
1994
|
-
|
|
1995
|
-
const cachedCaches = Object.create(null);
|
|
1996
|
-
const noopCache = {
|
|
1997
|
-
async match() {
|
|
1998
|
-
return undefined;
|
|
1999
|
-
},
|
|
2000
|
-
async put() {}
|
|
2001
|
-
};
|
|
2002
|
-
const supportsStorageBuckets = () => {
|
|
2003
|
-
// @ts-ignore
|
|
2004
|
-
return Boolean(navigator.storageBuckets);
|
|
1856
|
+
}
|
|
1857
|
+
const commands = Object.create(null);
|
|
1858
|
+
const register = commandMap => {
|
|
1859
|
+
Object.assign(commands, commandMap);
|
|
2005
1860
|
};
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2008
|
-
return noopCache;
|
|
2009
|
-
}
|
|
2010
|
-
const twoWeeks = 14 * 24 * 60 * 60 * 1000;
|
|
2011
|
-
// @ts-ignore
|
|
2012
|
-
const bucket = await navigator.storageBuckets.open(bucketName, {
|
|
2013
|
-
expires: Date.now() + twoWeeks,
|
|
2014
|
-
quota: 100 * 1024 * 1024 // 100MB
|
|
2015
|
-
});
|
|
2016
|
-
const cache = await bucket.caches.open(cacheName);
|
|
2017
|
-
return cache;
|
|
1861
|
+
const getCommand = key => {
|
|
1862
|
+
return commands[key];
|
|
2018
1863
|
};
|
|
2019
|
-
const
|
|
2020
|
-
|
|
2021
|
-
|
|
1864
|
+
const execute = (command, ...args) => {
|
|
1865
|
+
const fn = getCommand(command);
|
|
1866
|
+
if (!fn) {
|
|
1867
|
+
throw new CommandNotFoundError(command);
|
|
2022
1868
|
}
|
|
2023
|
-
return
|
|
1869
|
+
return fn(...args);
|
|
2024
1870
|
};
|
|
2025
1871
|
|
|
2026
|
-
|
|
2027
|
-
const
|
|
2028
|
-
const
|
|
2029
|
-
|
|
2030
|
-
const response = await cache.match(key);
|
|
2031
|
-
return Boolean(response);
|
|
1872
|
+
const Two$1 = '2.0';
|
|
1873
|
+
const callbacks = Object.create(null);
|
|
1874
|
+
const get$3 = id => {
|
|
1875
|
+
return callbacks[id];
|
|
2032
1876
|
};
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2035
|
-
const response = await cache.match(key);
|
|
2036
|
-
const text = await response?.text();
|
|
2037
|
-
return text || '';
|
|
1877
|
+
const remove$1 = id => {
|
|
1878
|
+
delete callbacks[id];
|
|
2038
1879
|
};
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
1880
|
+
class JsonRpcError extends Error {
|
|
1881
|
+
constructor(message) {
|
|
1882
|
+
super(message);
|
|
1883
|
+
this.name = 'JsonRpcError';
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
const NewLine = '\n';
|
|
1887
|
+
const DomException = 'DOMException';
|
|
1888
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
1889
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
1890
|
+
const TypeError$1 = 'TypeError';
|
|
1891
|
+
const getErrorConstructor = (message, type) => {
|
|
1892
|
+
if (type) {
|
|
1893
|
+
switch (type) {
|
|
1894
|
+
case DomException:
|
|
1895
|
+
return DOMException;
|
|
1896
|
+
case ReferenceError$1:
|
|
1897
|
+
return ReferenceError;
|
|
1898
|
+
case SyntaxError$1:
|
|
1899
|
+
return SyntaxError;
|
|
1900
|
+
case TypeError$1:
|
|
1901
|
+
return TypeError;
|
|
1902
|
+
default:
|
|
1903
|
+
return Error;
|
|
2045
1904
|
}
|
|
2046
|
-
}));
|
|
2047
|
-
};
|
|
2048
|
-
|
|
2049
|
-
const renderMarkdownCached = async (markdown, options) => {
|
|
2050
|
-
const cacheKey = await getMarkdownCacheKey(markdown, options);
|
|
2051
|
-
const bucketName = `markdown-cache`;
|
|
2052
|
-
const hasItem = await has(cacheKey, bucketName);
|
|
2053
|
-
if (hasItem) {
|
|
2054
|
-
const value = await get$2(cacheKey, bucketName);
|
|
2055
|
-
return value; // TODO validate if it's valid
|
|
2056
1905
|
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
return html;
|
|
2060
|
-
};
|
|
2061
|
-
|
|
2062
|
-
const renderMarkdown = async (markdown, options) => {
|
|
2063
|
-
const html = await renderMarkdownCached(markdown, options);
|
|
2064
|
-
return html;
|
|
2065
|
-
};
|
|
2066
|
-
|
|
2067
|
-
const getThemeDetails = async (extension, baseUrl, locationProtocol) => {
|
|
2068
|
-
const {
|
|
2069
|
-
colorThemes,
|
|
2070
|
-
iconThemes,
|
|
2071
|
-
productIconThemes
|
|
2072
|
-
} = extension;
|
|
2073
|
-
const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
|
|
2074
|
-
const rendered = await renderMarkdown(markdown, {
|
|
2075
|
-
baseUrl,
|
|
2076
|
-
locationProtocol
|
|
2077
|
-
});
|
|
2078
|
-
const themesMarkdownDom = await getMarkdownVirtualDom(rendered);
|
|
2079
|
-
return {
|
|
2080
|
-
themesMarkdownDom
|
|
2081
|
-
};
|
|
2082
|
-
};
|
|
2083
|
-
|
|
2084
|
-
const featureColorThemeEnabled = extension => {
|
|
2085
|
-
if (!hasProperty(extension, 'colorThemes')) {
|
|
2086
|
-
return false;
|
|
1906
|
+
if (message.startsWith('TypeError: ')) {
|
|
1907
|
+
return TypeError;
|
|
2087
1908
|
}
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
const featureIconThemeEnabled = extension => {
|
|
2092
|
-
if (!hasProperty(extension, 'iconThemes')) {
|
|
2093
|
-
return false;
|
|
1909
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
1910
|
+
return SyntaxError;
|
|
2094
1911
|
}
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
const featureProductIconThemeEnabled = extension => {
|
|
2099
|
-
if (!hasProperty(extension, 'productIconThemes')) {
|
|
2100
|
-
return false;
|
|
1912
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
1913
|
+
return ReferenceError;
|
|
2101
1914
|
}
|
|
2102
|
-
return
|
|
2103
|
-
};
|
|
2104
|
-
|
|
2105
|
-
const featureThemeEnabled = extension => {
|
|
2106
|
-
return featureColorThemeEnabled(extension) || featureIconThemeEnabled(extension) || featureProductIconThemeEnabled(extension);
|
|
1915
|
+
return Error;
|
|
2107
1916
|
};
|
|
2108
|
-
|
|
2109
|
-
const
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
1917
|
+
const constructError = (message, type, name) => {
|
|
1918
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
1919
|
+
if (ErrorConstructor === DOMException && name) {
|
|
1920
|
+
return new ErrorConstructor(message, name);
|
|
1921
|
+
}
|
|
1922
|
+
if (ErrorConstructor === Error) {
|
|
1923
|
+
const error = new Error(message);
|
|
1924
|
+
if (name && name !== 'VError') {
|
|
1925
|
+
error.name = name;
|
|
2116
1926
|
}
|
|
2117
|
-
|
|
1927
|
+
return error;
|
|
2118
1928
|
}
|
|
2119
|
-
return
|
|
2120
|
-
};
|
|
2121
|
-
|
|
2122
|
-
const getFeatureThemesVirtualDom = themesDom => {
|
|
2123
|
-
const childCount = getVirtualDomChildCount(themesDom);
|
|
2124
|
-
const heading = theme();
|
|
2125
|
-
return [{
|
|
2126
|
-
childCount: 2,
|
|
2127
|
-
className: FeatureContent,
|
|
2128
|
-
type: Div
|
|
2129
|
-
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
2130
|
-
childCount,
|
|
2131
|
-
className: DefaultMarkdown,
|
|
2132
|
-
type: Div
|
|
2133
|
-
}, ...themesDom];
|
|
1929
|
+
return new ErrorConstructor(message);
|
|
2134
1930
|
};
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
return getFeatureThemesVirtualDom(state.themesMarkdownDom);
|
|
1931
|
+
const joinLines = lines => {
|
|
1932
|
+
return lines.join(NewLine);
|
|
2138
1933
|
};
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
const {
|
|
2142
|
-
contentSecurityPolicy,
|
|
2143
|
-
elements,
|
|
2144
|
-
id,
|
|
2145
|
-
selector
|
|
2146
|
-
} = rawWebView;
|
|
2147
|
-
return {
|
|
2148
|
-
contentSecurityPolicyString: JSON.stringify(contentSecurityPolicy),
|
|
2149
|
-
elementsString: JSON.stringify(elements, null, 2),
|
|
2150
|
-
id,
|
|
2151
|
-
selectorString: JSON.stringify(selector)
|
|
2152
|
-
};
|
|
1934
|
+
const splitLines = lines => {
|
|
1935
|
+
return lines.split(NewLine);
|
|
2153
1936
|
};
|
|
2154
|
-
|
|
2155
|
-
const
|
|
2156
|
-
const
|
|
2157
|
-
return
|
|
1937
|
+
const getCurrentStack = () => {
|
|
1938
|
+
const stackLinesToSkip = 3;
|
|
1939
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
1940
|
+
return currentStack;
|
|
2158
1941
|
};
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
const webViews = getWebViews(extension);
|
|
2162
|
-
return {
|
|
2163
|
-
webViews
|
|
2164
|
-
};
|
|
1942
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1943
|
+
return string.indexOf(NewLine, startIndex);
|
|
2165
1944
|
};
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
if (
|
|
2169
|
-
|
|
1945
|
+
const getParentStack = error => {
|
|
1946
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
1947
|
+
if (parentStack.startsWith(' at')) {
|
|
1948
|
+
parentStack = error.message + NewLine + parentStack;
|
|
2170
1949
|
}
|
|
2171
|
-
return
|
|
2172
|
-
};
|
|
2173
|
-
|
|
2174
|
-
const heading = {
|
|
2175
|
-
childCount: 1,
|
|
2176
|
-
className: DefinitionListItemHeading,
|
|
2177
|
-
type: H2
|
|
2178
|
-
};
|
|
2179
|
-
const pre = {
|
|
2180
|
-
childCount: 1,
|
|
2181
|
-
className: DefinitionListItemValue,
|
|
2182
|
-
type: Pre
|
|
1950
|
+
return parentStack;
|
|
2183
1951
|
};
|
|
2184
|
-
const
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
1952
|
+
const MethodNotFound = -32601;
|
|
1953
|
+
const Custom = -32001;
|
|
1954
|
+
const restoreJsonRpcError = error => {
|
|
1955
|
+
const currentStack = getCurrentStack();
|
|
1956
|
+
if (error && error instanceof Error) {
|
|
1957
|
+
if (typeof error.stack === 'string') {
|
|
1958
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
1959
|
+
}
|
|
1960
|
+
return error;
|
|
1961
|
+
}
|
|
1962
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
1963
|
+
const restoredError = new JsonRpcError(error.message);
|
|
1964
|
+
const parentStack = getParentStack(error);
|
|
1965
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
1966
|
+
return restoredError;
|
|
1967
|
+
}
|
|
1968
|
+
if (error && error.message) {
|
|
1969
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
1970
|
+
if (error.data) {
|
|
1971
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
1972
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
1973
|
+
} else if (error.data.stack) {
|
|
1974
|
+
restoredError.stack = error.data.stack;
|
|
1975
|
+
}
|
|
1976
|
+
if (error.data.codeFrame) {
|
|
1977
|
+
// @ts-ignore
|
|
1978
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
1979
|
+
}
|
|
1980
|
+
if (error.data.code) {
|
|
1981
|
+
// @ts-ignore
|
|
1982
|
+
restoredError.code = error.data.code;
|
|
1983
|
+
}
|
|
1984
|
+
if (error.data.type) {
|
|
1985
|
+
// @ts-ignore
|
|
1986
|
+
restoredError.name = error.data.type;
|
|
1987
|
+
}
|
|
1988
|
+
} else {
|
|
1989
|
+
if (error.stack) {
|
|
1990
|
+
const lowerStack = restoredError.stack || '';
|
|
1991
|
+
// @ts-ignore
|
|
1992
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1993
|
+
const parentStack = getParentStack(error);
|
|
1994
|
+
// @ts-ignore
|
|
1995
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
1996
|
+
}
|
|
1997
|
+
if (error.codeFrame) {
|
|
1998
|
+
// @ts-ignore
|
|
1999
|
+
restoredError.codeFrame = error.codeFrame;
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
return restoredError;
|
|
2003
|
+
}
|
|
2004
|
+
if (typeof error === 'string') {
|
|
2005
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
2006
|
+
}
|
|
2007
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
2188
2008
|
};
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
const textContentSecurityPolicy = contentSecurityPolicy();
|
|
2199
|
-
const textElements = elements();
|
|
2200
|
-
return [{
|
|
2201
|
-
childCount: 4,
|
|
2202
|
-
className: FeatureWebView,
|
|
2203
|
-
type: Div
|
|
2204
|
-
}, item, heading, text(textId), pre, text(id), item, heading, text(textSelector), pre, text(selectorString), item, heading, text(textContentSecurityPolicy), pre, text(contentSecurityPolicyString), item, heading, text(textElements), pre, text(elementsString)];
|
|
2009
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
2010
|
+
if ('error' in responseMessage) {
|
|
2011
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
2012
|
+
throw restoredError;
|
|
2013
|
+
}
|
|
2014
|
+
if ('result' in responseMessage) {
|
|
2015
|
+
return responseMessage.result;
|
|
2016
|
+
}
|
|
2017
|
+
throw new JsonRpcError('unexpected response message');
|
|
2205
2018
|
};
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
const heading = webViews();
|
|
2209
|
-
return [{
|
|
2210
|
-
childCount: 2,
|
|
2211
|
-
className: FeatureContent,
|
|
2212
|
-
type: Div
|
|
2213
|
-
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
2214
|
-
childCount: webViews$1.length,
|
|
2215
|
-
type: Div
|
|
2216
|
-
}, ...webViews$1.flatMap(getWebViewVirtualDom)];
|
|
2019
|
+
const warn = (...args) => {
|
|
2020
|
+
console.warn(...args);
|
|
2217
2021
|
};
|
|
2218
|
-
|
|
2219
|
-
const
|
|
2220
|
-
|
|
2022
|
+
const resolve = (id, response) => {
|
|
2023
|
+
const fn = get$3(id);
|
|
2024
|
+
if (!fn) {
|
|
2025
|
+
console.log(response);
|
|
2026
|
+
warn(`callback ${id} may already be disposed`);
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
fn(response);
|
|
2030
|
+
remove$1(id);
|
|
2221
2031
|
};
|
|
2222
|
-
|
|
2223
|
-
const
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
register$1({
|
|
2232
|
-
getDetails: getCommandsDetails,
|
|
2233
|
-
getLabel: commands$1,
|
|
2234
|
-
getVirtualDom: getCommandsVirtualDom,
|
|
2235
|
-
id: Commands,
|
|
2236
|
-
isEnabled: featureCommandsEnabled
|
|
2237
|
-
});
|
|
2238
|
-
register$1({
|
|
2239
|
-
getDetails: getSettingsDetails,
|
|
2240
|
-
getLabel: settings,
|
|
2241
|
-
getVirtualDom: getSettingsVirtualDom,
|
|
2242
|
-
id: Settings,
|
|
2243
|
-
isEnabled: featureSettingsEnabled
|
|
2244
|
-
});
|
|
2245
|
-
register$1({
|
|
2246
|
-
getDetails: getJsonValidationDetails,
|
|
2247
|
-
getLabel: jsonValidation,
|
|
2248
|
-
getVirtualDom: getJsonValidationVirtualDom,
|
|
2249
|
-
id: JsonValidation,
|
|
2250
|
-
isEnabled: featureJsonValidationEnabled
|
|
2251
|
-
});
|
|
2252
|
-
register$1({
|
|
2253
|
-
getDetails: getFeatureDetailsProgrammingLanguages,
|
|
2254
|
-
getLabel: programmingLanguages,
|
|
2255
|
-
getVirtualDom: getProgrammingLanguagesVirtualDom,
|
|
2256
|
-
id: ProgrammingLanguages,
|
|
2257
|
-
isEnabled: featureProgrammingLanguagesEnabled
|
|
2258
|
-
});
|
|
2259
|
-
register$1({
|
|
2260
|
-
getDetails: getWebViewsDetails,
|
|
2261
|
-
getLabel: webViews,
|
|
2262
|
-
getVirtualDom: getWebViewsVirtualDom,
|
|
2263
|
-
id: WebViews,
|
|
2264
|
-
isEnabled: featureWebViewsEnabled
|
|
2265
|
-
});
|
|
2266
|
-
register$1({
|
|
2267
|
-
getDetails: getActivationEventsDetails,
|
|
2268
|
-
getLabel: activationEvents,
|
|
2269
|
-
getVirtualDom: getActivationEventsVirtualDom,
|
|
2270
|
-
id: ActivationEvents,
|
|
2271
|
-
isEnabled: featureActivationEventsEnabled
|
|
2272
|
-
});
|
|
2273
|
-
register$1({
|
|
2274
|
-
getDetails: getRuntimeStatusDetails,
|
|
2275
|
-
getLabel: runtimeStatus,
|
|
2276
|
-
getVirtualDom: getRuntimeStatusVirtualDom,
|
|
2277
|
-
id: RuntimeStatus,
|
|
2278
|
-
isEnabled: featureRuntimeStatusEnabled
|
|
2279
|
-
});
|
|
2032
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
2033
|
+
const getErrorType = prettyError => {
|
|
2034
|
+
if (prettyError && prettyError.type) {
|
|
2035
|
+
return prettyError.type;
|
|
2036
|
+
}
|
|
2037
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
2038
|
+
return prettyError.constructor.name;
|
|
2039
|
+
}
|
|
2040
|
+
return undefined;
|
|
2280
2041
|
};
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
return value && value instanceof MessagePort;
|
|
2042
|
+
const isAlreadyStack = line => {
|
|
2043
|
+
return line.trim().startsWith('at ');
|
|
2284
2044
|
};
|
|
2285
|
-
const
|
|
2286
|
-
|
|
2045
|
+
const getStack = prettyError => {
|
|
2046
|
+
const stackString = prettyError.stack || '';
|
|
2047
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
2048
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
2049
|
+
return stackString.slice(newLineIndex + 1);
|
|
2050
|
+
}
|
|
2051
|
+
return stackString;
|
|
2287
2052
|
};
|
|
2288
|
-
const
|
|
2289
|
-
|
|
2053
|
+
const getErrorProperty = (error, prettyError) => {
|
|
2054
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
2055
|
+
return {
|
|
2056
|
+
code: MethodNotFound,
|
|
2057
|
+
data: error.stack,
|
|
2058
|
+
message: error.message
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
return {
|
|
2062
|
+
code: Custom,
|
|
2063
|
+
data: {
|
|
2064
|
+
code: prettyError.code,
|
|
2065
|
+
codeFrame: prettyError.codeFrame,
|
|
2066
|
+
name: prettyError.name,
|
|
2067
|
+
stack: getStack(prettyError),
|
|
2068
|
+
type: getErrorType(prettyError)
|
|
2069
|
+
},
|
|
2070
|
+
message: prettyError.message
|
|
2071
|
+
};
|
|
2290
2072
|
};
|
|
2291
|
-
const
|
|
2292
|
-
return
|
|
2073
|
+
const create$1$1 = (id, error) => {
|
|
2074
|
+
return {
|
|
2075
|
+
error,
|
|
2076
|
+
id,
|
|
2077
|
+
jsonrpc: Two$1
|
|
2078
|
+
};
|
|
2293
2079
|
};
|
|
2294
|
-
const
|
|
2295
|
-
|
|
2080
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
2081
|
+
const prettyError = preparePrettyError(error);
|
|
2082
|
+
logError(error, prettyError);
|
|
2083
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
2084
|
+
return create$1$1(id, errorProperty);
|
|
2296
2085
|
};
|
|
2297
|
-
const
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2086
|
+
const create$a = (message, result) => {
|
|
2087
|
+
return {
|
|
2088
|
+
id: message.id,
|
|
2089
|
+
jsonrpc: Two$1,
|
|
2090
|
+
result: result ?? null
|
|
2091
|
+
};
|
|
2092
|
+
};
|
|
2093
|
+
const getSuccessResponse = (message, result) => {
|
|
2094
|
+
const resultProperty = result ?? null;
|
|
2095
|
+
return create$a(message, resultProperty);
|
|
2096
|
+
};
|
|
2097
|
+
const getErrorResponseSimple = (id, error) => {
|
|
2098
|
+
return {
|
|
2099
|
+
error: {
|
|
2100
|
+
code: Custom,
|
|
2101
|
+
data: error,
|
|
2102
|
+
// @ts-ignore
|
|
2103
|
+
message: error.message
|
|
2104
|
+
},
|
|
2105
|
+
id,
|
|
2106
|
+
jsonrpc: Two$1
|
|
2107
|
+
};
|
|
2108
|
+
};
|
|
2109
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
2110
|
+
try {
|
|
2111
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
2112
|
+
return getSuccessResponse(message, result);
|
|
2113
|
+
} catch (error) {
|
|
2114
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
2115
|
+
return getErrorResponseSimple(message.id, error);
|
|
2302
2116
|
}
|
|
2117
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2303
2118
|
}
|
|
2119
|
+
};
|
|
2120
|
+
const defaultPreparePrettyError = error => {
|
|
2121
|
+
return error;
|
|
2122
|
+
};
|
|
2123
|
+
const defaultLogError = () => {
|
|
2124
|
+
// ignore
|
|
2125
|
+
};
|
|
2126
|
+
const defaultRequiresSocket = () => {
|
|
2304
2127
|
return false;
|
|
2305
2128
|
};
|
|
2306
|
-
const
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
if (
|
|
2311
|
-
|
|
2312
|
-
return
|
|
2129
|
+
const defaultResolve = resolve;
|
|
2130
|
+
|
|
2131
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
2132
|
+
const normalizeParams = args => {
|
|
2133
|
+
if (args.length === 1) {
|
|
2134
|
+
const options = args[0];
|
|
2135
|
+
return {
|
|
2136
|
+
execute: options.execute,
|
|
2137
|
+
ipc: options.ipc,
|
|
2138
|
+
logError: options.logError || defaultLogError,
|
|
2139
|
+
message: options.message,
|
|
2140
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
2141
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
2142
|
+
resolve: options.resolve || defaultResolve
|
|
2143
|
+
};
|
|
2313
2144
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2145
|
+
return {
|
|
2146
|
+
execute: args[2],
|
|
2147
|
+
ipc: args[0],
|
|
2148
|
+
logError: args[5],
|
|
2149
|
+
message: args[1],
|
|
2150
|
+
preparePrettyError: args[4],
|
|
2151
|
+
requiresSocket: args[6],
|
|
2152
|
+
resolve: args[3]
|
|
2153
|
+
};
|
|
2154
|
+
};
|
|
2155
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
2156
|
+
const options = normalizeParams(args);
|
|
2157
|
+
const {
|
|
2158
|
+
execute,
|
|
2159
|
+
ipc,
|
|
2160
|
+
logError,
|
|
2161
|
+
message,
|
|
2162
|
+
preparePrettyError,
|
|
2163
|
+
requiresSocket,
|
|
2164
|
+
resolve
|
|
2165
|
+
} = options;
|
|
2166
|
+
if ('id' in message) {
|
|
2167
|
+
if ('method' in message) {
|
|
2168
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
2169
|
+
try {
|
|
2170
|
+
ipc.send(response);
|
|
2171
|
+
} catch (error) {
|
|
2172
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2173
|
+
ipc.send(errorResponse);
|
|
2174
|
+
}
|
|
2175
|
+
return;
|
|
2317
2176
|
}
|
|
2177
|
+
resolve(message.id, message);
|
|
2318
2178
|
return;
|
|
2319
2179
|
}
|
|
2320
|
-
if (
|
|
2321
|
-
|
|
2322
|
-
walkValue(property, transferrables, isTransferrable);
|
|
2323
|
-
}
|
|
2180
|
+
if ('method' in message) {
|
|
2181
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
2324
2182
|
return;
|
|
2325
2183
|
}
|
|
2184
|
+
throw new JsonRpcError('unexpected message');
|
|
2326
2185
|
};
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
2336
|
-
data
|
|
2337
|
-
}));
|
|
2186
|
+
|
|
2187
|
+
const Two = '2.0';
|
|
2188
|
+
|
|
2189
|
+
const create$9 = (method, params) => {
|
|
2190
|
+
return {
|
|
2191
|
+
jsonrpc: Two,
|
|
2192
|
+
method,
|
|
2193
|
+
params
|
|
2338
2194
|
};
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2195
|
+
};
|
|
2196
|
+
|
|
2197
|
+
const create$8 = (id, method, params) => {
|
|
2198
|
+
const message = {
|
|
2199
|
+
id,
|
|
2200
|
+
jsonrpc: Two,
|
|
2201
|
+
method,
|
|
2202
|
+
params
|
|
2342
2203
|
};
|
|
2343
|
-
|
|
2204
|
+
return message;
|
|
2344
2205
|
};
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
attachEvents(this);
|
|
2350
|
-
}
|
|
2351
|
-
}
|
|
2352
|
-
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
2353
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
2354
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
2355
|
-
const NewLine$1 = '\n';
|
|
2356
|
-
const joinLines$1 = lines => {
|
|
2357
|
-
return lines.join(NewLine$1);
|
|
2206
|
+
|
|
2207
|
+
let id = 0;
|
|
2208
|
+
const create$7 = () => {
|
|
2209
|
+
return ++id;
|
|
2358
2210
|
};
|
|
2359
|
-
|
|
2360
|
-
const
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2211
|
+
|
|
2212
|
+
const registerPromise = map => {
|
|
2213
|
+
const id = create$7();
|
|
2214
|
+
const {
|
|
2215
|
+
promise,
|
|
2216
|
+
resolve
|
|
2217
|
+
} = Promise.withResolvers();
|
|
2218
|
+
map[id] = resolve;
|
|
2219
|
+
return {
|
|
2220
|
+
id,
|
|
2221
|
+
promise
|
|
2222
|
+
};
|
|
2363
2223
|
};
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2224
|
+
|
|
2225
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
2226
|
+
const {
|
|
2227
|
+
id,
|
|
2228
|
+
promise
|
|
2229
|
+
} = registerPromise(callbacks);
|
|
2230
|
+
const message = create$8(id, method, params);
|
|
2231
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
2232
|
+
ipc.sendAndTransfer(message);
|
|
2233
|
+
} else {
|
|
2234
|
+
ipc.send(message);
|
|
2371
2235
|
}
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2236
|
+
const responseMessage = await promise;
|
|
2237
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
2238
|
+
};
|
|
2239
|
+
const createRpc = ipc => {
|
|
2240
|
+
const callbacks = Object.create(null);
|
|
2241
|
+
ipc._resolve = (id, response) => {
|
|
2242
|
+
const fn = callbacks[id];
|
|
2243
|
+
if (!fn) {
|
|
2244
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
2245
|
+
return;
|
|
2246
|
+
}
|
|
2247
|
+
fn(response);
|
|
2248
|
+
delete callbacks[id];
|
|
2249
|
+
};
|
|
2250
|
+
const rpc = {
|
|
2251
|
+
async dispose() {
|
|
2252
|
+
await ipc?.dispose();
|
|
2253
|
+
},
|
|
2254
|
+
invoke(method, ...params) {
|
|
2255
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
2256
|
+
},
|
|
2257
|
+
invokeAndTransfer(method, ...params) {
|
|
2258
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
2259
|
+
},
|
|
2260
|
+
// @ts-ignore
|
|
2261
|
+
ipc,
|
|
2262
|
+
/**
|
|
2263
|
+
* @deprecated
|
|
2264
|
+
*/
|
|
2265
|
+
send(method, ...params) {
|
|
2266
|
+
const message = create$9(method, params);
|
|
2267
|
+
ipc.send(message);
|
|
2376
2268
|
}
|
|
2377
|
-
}
|
|
2378
|
-
return {
|
|
2379
|
-
actualMessage: lines[index - 1],
|
|
2380
|
-
rest: lines.slice(index, lastIndex)
|
|
2381
2269
|
};
|
|
2270
|
+
return rpc;
|
|
2382
2271
|
};
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
2387
|
-
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
2388
|
-
const isMessageCodeBlockStartIndex = line => {
|
|
2389
|
-
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
2390
|
-
};
|
|
2391
|
-
const isMessageCodeBlockEndIndex = line => {
|
|
2392
|
-
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
2272
|
+
|
|
2273
|
+
const requiresSocket = () => {
|
|
2274
|
+
return false;
|
|
2393
2275
|
};
|
|
2394
|
-
const
|
|
2395
|
-
|
|
2396
|
-
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
2397
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
2398
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
2399
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
2400
|
-
return relevantMessage;
|
|
2276
|
+
const preparePrettyError = error => {
|
|
2277
|
+
return error;
|
|
2401
2278
|
};
|
|
2402
|
-
const
|
|
2403
|
-
|
|
2279
|
+
const logError = () => {
|
|
2280
|
+
// handled by renderer worker
|
|
2404
2281
|
};
|
|
2405
|
-
const
|
|
2406
|
-
const
|
|
2407
|
-
const
|
|
2408
|
-
|
|
2409
|
-
return {
|
|
2410
|
-
code: ERR_MODULE_NOT_FOUND,
|
|
2411
|
-
message
|
|
2412
|
-
};
|
|
2282
|
+
const handleMessage = event => {
|
|
2283
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
2284
|
+
const actualExecute = event?.target?.execute || execute;
|
|
2285
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
2413
2286
|
};
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2287
|
+
|
|
2288
|
+
const handleIpc = ipc => {
|
|
2289
|
+
if ('addEventListener' in ipc) {
|
|
2290
|
+
ipc.addEventListener('message', handleMessage);
|
|
2291
|
+
} else if ('on' in ipc) {
|
|
2292
|
+
// deprecated
|
|
2293
|
+
ipc.on('message', handleMessage);
|
|
2417
2294
|
}
|
|
2418
|
-
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
2419
2295
|
};
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2296
|
+
|
|
2297
|
+
const listen$1 = async (module, options) => {
|
|
2298
|
+
const rawIpc = await module.listen(options);
|
|
2299
|
+
if (module.signal) {
|
|
2300
|
+
module.signal(rawIpc);
|
|
2423
2301
|
}
|
|
2424
|
-
|
|
2302
|
+
const ipc = module.wrap(rawIpc);
|
|
2303
|
+
return ipc;
|
|
2425
2304
|
};
|
|
2426
|
-
|
|
2427
|
-
const
|
|
2428
|
-
|
|
2429
|
-
|
|
2305
|
+
|
|
2306
|
+
const create$6 = async ({
|
|
2307
|
+
commandMap,
|
|
2308
|
+
isMessagePortOpen = true,
|
|
2309
|
+
messagePort
|
|
2310
|
+
}) => {
|
|
2311
|
+
// TODO create a commandMap per rpc instance
|
|
2312
|
+
register(commandMap);
|
|
2313
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2314
|
+
isMessagePortOpen,
|
|
2315
|
+
messagePort
|
|
2316
|
+
});
|
|
2317
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2318
|
+
handleIpc(ipc);
|
|
2319
|
+
const rpc = createRpc(ipc);
|
|
2320
|
+
messagePort.start();
|
|
2321
|
+
return rpc;
|
|
2430
2322
|
};
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2323
|
+
|
|
2324
|
+
const create$5 = async ({
|
|
2325
|
+
commandMap,
|
|
2326
|
+
isMessagePortOpen,
|
|
2327
|
+
send
|
|
2328
|
+
}) => {
|
|
2329
|
+
const {
|
|
2330
|
+
port1,
|
|
2331
|
+
port2
|
|
2332
|
+
} = new MessageChannel();
|
|
2333
|
+
await send(port1);
|
|
2334
|
+
return create$6({
|
|
2335
|
+
commandMap,
|
|
2336
|
+
isMessagePortOpen,
|
|
2337
|
+
messagePort: port2
|
|
2338
|
+
});
|
|
2437
2339
|
};
|
|
2438
|
-
|
|
2340
|
+
|
|
2341
|
+
const createSharedLazyRpc = factory => {
|
|
2342
|
+
let rpcPromise;
|
|
2343
|
+
const getOrCreate = () => {
|
|
2344
|
+
if (!rpcPromise) {
|
|
2345
|
+
rpcPromise = factory();
|
|
2346
|
+
}
|
|
2347
|
+
return rpcPromise;
|
|
2348
|
+
};
|
|
2439
2349
|
return {
|
|
2440
|
-
|
|
2441
|
-
|
|
2350
|
+
async dispose() {
|
|
2351
|
+
const rpc = await getOrCreate();
|
|
2352
|
+
await rpc.dispose();
|
|
2353
|
+
},
|
|
2354
|
+
async invoke(method, ...params) {
|
|
2355
|
+
const rpc = await getOrCreate();
|
|
2356
|
+
return rpc.invoke(method, ...params);
|
|
2357
|
+
},
|
|
2358
|
+
async invokeAndTransfer(method, ...params) {
|
|
2359
|
+
const rpc = await getOrCreate();
|
|
2360
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
2361
|
+
},
|
|
2362
|
+
async send(method, ...params) {
|
|
2363
|
+
const rpc = await getOrCreate();
|
|
2364
|
+
rpc.send(method, ...params);
|
|
2365
|
+
}
|
|
2442
2366
|
};
|
|
2443
2367
|
};
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2368
|
+
|
|
2369
|
+
const create$4 = async ({
|
|
2370
|
+
commandMap,
|
|
2371
|
+
isMessagePortOpen,
|
|
2372
|
+
send
|
|
2373
|
+
}) => {
|
|
2374
|
+
return createSharedLazyRpc(() => {
|
|
2375
|
+
return create$5({
|
|
2376
|
+
commandMap,
|
|
2377
|
+
isMessagePortOpen,
|
|
2378
|
+
send
|
|
2379
|
+
});
|
|
2380
|
+
});
|
|
2381
|
+
};
|
|
2382
|
+
|
|
2383
|
+
const create$3 = async ({
|
|
2384
|
+
commandMap
|
|
2385
|
+
}) => {
|
|
2386
|
+
// TODO create a commandMap per rpc instance
|
|
2387
|
+
register(commandMap);
|
|
2388
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
2389
|
+
handleIpc(ipc);
|
|
2390
|
+
const rpc = createRpc(ipc);
|
|
2391
|
+
return rpc;
|
|
2392
|
+
};
|
|
2393
|
+
|
|
2394
|
+
const createMockRpc = ({
|
|
2395
|
+
commandMap
|
|
2396
|
+
}) => {
|
|
2397
|
+
const invocations = [];
|
|
2398
|
+
const invoke = (method, ...params) => {
|
|
2399
|
+
invocations.push([method, ...params]);
|
|
2400
|
+
const command = commandMap[method];
|
|
2401
|
+
if (!command) {
|
|
2402
|
+
throw new Error(`command ${method} not found`);
|
|
2403
|
+
}
|
|
2404
|
+
return command(...params);
|
|
2405
|
+
};
|
|
2406
|
+
const mockRpc = {
|
|
2407
|
+
invocations,
|
|
2408
|
+
invoke,
|
|
2409
|
+
invokeAndTransfer: invoke
|
|
2463
2410
|
};
|
|
2411
|
+
return mockRpc;
|
|
2464
2412
|
};
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2413
|
+
|
|
2414
|
+
const rpcs = Object.create(null);
|
|
2415
|
+
const set$a = (id, rpc) => {
|
|
2416
|
+
rpcs[id] = rpc;
|
|
2417
|
+
};
|
|
2418
|
+
const get$2 = id => {
|
|
2419
|
+
return rpcs[id];
|
|
2420
|
+
};
|
|
2421
|
+
const remove = id => {
|
|
2422
|
+
delete rpcs[id];
|
|
2423
|
+
};
|
|
2424
|
+
|
|
2425
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
2426
|
+
const create$2 = rpcId => {
|
|
2427
|
+
return {
|
|
2428
|
+
async dispose() {
|
|
2429
|
+
const rpc = get$2(rpcId);
|
|
2430
|
+
await rpc.dispose();
|
|
2431
|
+
},
|
|
2432
|
+
// @ts-ignore
|
|
2433
|
+
invoke(method, ...params) {
|
|
2434
|
+
const rpc = get$2(rpcId);
|
|
2469
2435
|
// @ts-ignore
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
const cause = new Error(message);
|
|
2436
|
+
return rpc.invoke(method, ...params);
|
|
2437
|
+
},
|
|
2438
|
+
// @ts-ignore
|
|
2439
|
+
invokeAndTransfer(method, ...params) {
|
|
2440
|
+
const rpc = get$2(rpcId);
|
|
2476
2441
|
// @ts-ignore
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2442
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
2443
|
+
},
|
|
2444
|
+
registerMockRpc(commandMap) {
|
|
2445
|
+
const mockRpc = createMockRpc({
|
|
2446
|
+
commandMap
|
|
2447
|
+
});
|
|
2448
|
+
set$a(rpcId, mockRpc);
|
|
2449
|
+
// @ts-ignore
|
|
2450
|
+
mockRpc[Symbol.dispose] = () => {
|
|
2451
|
+
remove(rpcId);
|
|
2452
|
+
};
|
|
2453
|
+
// @ts-ignore
|
|
2454
|
+
return mockRpc;
|
|
2455
|
+
},
|
|
2456
|
+
set(rpc) {
|
|
2457
|
+
set$a(rpcId, rpc);
|
|
2482
2458
|
}
|
|
2483
|
-
|
|
2484
|
-
this.name = 'IpcError';
|
|
2485
|
-
// @ts-ignore
|
|
2486
|
-
this.stdout = stdout;
|
|
2487
|
-
// @ts-ignore
|
|
2488
|
-
this.stderr = stderr;
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
const readyMessage = 'ready';
|
|
2492
|
-
const getData$2 = event => {
|
|
2493
|
-
return event.data;
|
|
2459
|
+
};
|
|
2494
2460
|
};
|
|
2495
|
-
|
|
2461
|
+
|
|
2462
|
+
const {
|
|
2463
|
+
invoke: invoke$5,
|
|
2464
|
+
set: set$9
|
|
2465
|
+
} = create$2(ExtensionHostWorker);
|
|
2466
|
+
const getRuntimeStatus$2 = async extensionId => {
|
|
2496
2467
|
// @ts-ignore
|
|
2497
|
-
|
|
2498
|
-
throw new TypeError('module is not in web worker scope');
|
|
2499
|
-
}
|
|
2500
|
-
return globalThis;
|
|
2468
|
+
return invoke$5('ExtensionHost.getRuntimeStatus', extensionId);
|
|
2501
2469
|
};
|
|
2502
|
-
|
|
2503
|
-
|
|
2470
|
+
|
|
2471
|
+
const ExtensionHost = {
|
|
2472
|
+
__proto__: null,
|
|
2473
|
+
getRuntimeStatus: getRuntimeStatus$2,
|
|
2474
|
+
invoke: invoke$5,
|
|
2475
|
+
set: set$9
|
|
2504
2476
|
};
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
}
|
|
2513
|
-
sendAndTransfer(message) {
|
|
2514
|
-
const transfer = getTransferrables(message);
|
|
2515
|
-
// @ts-ignore
|
|
2516
|
-
this._rawIpc.postMessage(message, transfer);
|
|
2517
|
-
}
|
|
2518
|
-
dispose() {
|
|
2519
|
-
// ignore
|
|
2520
|
-
}
|
|
2521
|
-
onClose(callback) {
|
|
2522
|
-
// ignore
|
|
2523
|
-
}
|
|
2524
|
-
onMessage(callback) {
|
|
2525
|
-
this._rawIpc.addEventListener('message', callback);
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
const wrap$f = global => {
|
|
2529
|
-
return new IpcChildWithModuleWorker(global);
|
|
2477
|
+
|
|
2478
|
+
const {
|
|
2479
|
+
invoke: invoke$4,
|
|
2480
|
+
set: set$8
|
|
2481
|
+
} = create$2(ExtensionManagementWorker);
|
|
2482
|
+
const enable2 = (id, platform) => {
|
|
2483
|
+
return invoke$4(`Extensions.enable2`, id, platform);
|
|
2530
2484
|
};
|
|
2531
|
-
const
|
|
2532
|
-
|
|
2533
|
-
promise,
|
|
2534
|
-
resolve
|
|
2535
|
-
} = Promise.withResolvers();
|
|
2536
|
-
port.addEventListener('message', resolve, {
|
|
2537
|
-
once: true
|
|
2538
|
-
});
|
|
2539
|
-
const event = await promise;
|
|
2540
|
-
// @ts-ignore
|
|
2541
|
-
return event.data;
|
|
2485
|
+
const disable2 = (id, platform) => {
|
|
2486
|
+
return invoke$4(`Extensions.disable2`, id, platform);
|
|
2542
2487
|
};
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
}
|
|
2551
|
-
const type = firstMessage.params[0];
|
|
2552
|
-
if (type === 'message-port') {
|
|
2553
|
-
parentIpc.send({
|
|
2554
|
-
id: firstMessage.id,
|
|
2555
|
-
jsonrpc: '2.0',
|
|
2556
|
-
result: null
|
|
2557
|
-
});
|
|
2558
|
-
parentIpc.dispose();
|
|
2559
|
-
const port = firstMessage.params[1];
|
|
2560
|
-
return port;
|
|
2561
|
-
}
|
|
2562
|
-
return globalThis;
|
|
2488
|
+
|
|
2489
|
+
const {
|
|
2490
|
+
invoke: invoke$3,
|
|
2491
|
+
set: set$7
|
|
2492
|
+
} = create$2(FileSystemWorker$1);
|
|
2493
|
+
const readFile$2 = async uri => {
|
|
2494
|
+
return invoke$3('FileSystem.readFile', uri);
|
|
2563
2495
|
};
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
return getData$2(event);
|
|
2567
|
-
}
|
|
2568
|
-
send(message) {
|
|
2569
|
-
this._rawIpc.postMessage(message);
|
|
2570
|
-
}
|
|
2571
|
-
sendAndTransfer(message) {
|
|
2572
|
-
const transfer = getTransferrables(message);
|
|
2573
|
-
this._rawIpc.postMessage(message, transfer);
|
|
2574
|
-
}
|
|
2575
|
-
dispose() {
|
|
2576
|
-
if (this._rawIpc.close) {
|
|
2577
|
-
this._rawIpc.close();
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
onClose(callback) {
|
|
2581
|
-
// ignore
|
|
2582
|
-
}
|
|
2583
|
-
onMessage(callback) {
|
|
2584
|
-
this._rawIpc.addEventListener('message', callback);
|
|
2585
|
-
this._rawIpc.start();
|
|
2586
|
-
}
|
|
2587
|
-
}
|
|
2588
|
-
const wrap$e = port => {
|
|
2589
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
2496
|
+
const exists$1 = async uri => {
|
|
2497
|
+
return invoke$3('FileSystem.exists', uri);
|
|
2590
2498
|
};
|
|
2591
|
-
|
|
2499
|
+
|
|
2500
|
+
const FileSystemWorker = {
|
|
2592
2501
|
__proto__: null,
|
|
2593
|
-
|
|
2594
|
-
|
|
2502
|
+
exists: exists$1,
|
|
2503
|
+
invoke: invoke$3,
|
|
2504
|
+
readFile: readFile$2,
|
|
2505
|
+
set: set$7
|
|
2595
2506
|
};
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2507
|
+
|
|
2508
|
+
const {
|
|
2509
|
+
invoke: invoke$2,
|
|
2510
|
+
set: set$6
|
|
2511
|
+
} = create$2(MarkdownWorker$1);
|
|
2512
|
+
const getVirtualDom$1 = async html => {
|
|
2513
|
+
// @ts-ignore
|
|
2514
|
+
return invoke$2('Markdown.getVirtualDom', html);
|
|
2602
2515
|
};
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
} else {
|
|
2607
|
-
emitter.off(type, callback);
|
|
2608
|
-
}
|
|
2516
|
+
const render$1 = async (markdown, options) => {
|
|
2517
|
+
// @ts-ignore
|
|
2518
|
+
return invoke$2('Markdown.render', markdown, options);
|
|
2609
2519
|
};
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
for (const event of Object.keys(eventMap)) {
|
|
2618
|
-
removeListener(eventEmitter, event, listenerMap[event]);
|
|
2619
|
-
}
|
|
2620
|
-
resolve(value);
|
|
2621
|
-
};
|
|
2622
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
2623
|
-
const listener = event => {
|
|
2624
|
-
cleanup({
|
|
2625
|
-
event,
|
|
2626
|
-
type
|
|
2627
|
-
});
|
|
2628
|
-
};
|
|
2629
|
-
addListener(eventEmitter, event, listener);
|
|
2630
|
-
listenerMap[event] = listener;
|
|
2631
|
-
}
|
|
2632
|
-
return promise;
|
|
2520
|
+
|
|
2521
|
+
const MarkdownWorker = {
|
|
2522
|
+
__proto__: null,
|
|
2523
|
+
getVirtualDom: getVirtualDom$1,
|
|
2524
|
+
invoke: invoke$2,
|
|
2525
|
+
render: render$1,
|
|
2526
|
+
set: set$6
|
|
2633
2527
|
};
|
|
2634
|
-
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2528
|
+
|
|
2529
|
+
const {
|
|
2530
|
+
invoke: invoke$1,
|
|
2531
|
+
invokeAndTransfer,
|
|
2532
|
+
set: set$5
|
|
2533
|
+
} = create$2(RendererWorker);
|
|
2534
|
+
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
2535
|
+
number(uid);
|
|
2536
|
+
number(menuId);
|
|
2537
|
+
number(x);
|
|
2538
|
+
number(y);
|
|
2539
|
+
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
2540
|
+
};
|
|
2541
|
+
const setColorTheme$1 = async id => {
|
|
2542
|
+
return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
2543
|
+
};
|
|
2544
|
+
const sendMessagePortToMarkdownWorker$1 = async (port, rpcId) => {
|
|
2545
|
+
const command = 'Markdown.handleMessagePort';
|
|
2546
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
|
|
2547
|
+
};
|
|
2548
|
+
const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
|
|
2549
|
+
const command = 'FileSystem.handleMessagePort';
|
|
2550
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
2551
|
+
};
|
|
2552
|
+
const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
2553
|
+
const command = 'HandleMessagePort.handleMessagePort2';
|
|
2554
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
2555
|
+
};
|
|
2556
|
+
const confirm = async (message, options) => {
|
|
2557
|
+
const result = await invoke$1('ConfirmPrompt.prompt', message, options);
|
|
2558
|
+
return result;
|
|
2559
|
+
};
|
|
2560
|
+
const writeClipBoardText = async text => {
|
|
2561
|
+
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
2562
|
+
};
|
|
2563
|
+
const writeClipBoardImage = async blob => {
|
|
2564
|
+
await invoke$1('ClipBoard.writeImage', /* text */blob);
|
|
2660
2565
|
};
|
|
2661
|
-
const
|
|
2662
|
-
|
|
2566
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
2567
|
+
const command = 'Extensions.handleMessagePort';
|
|
2568
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
2663
2569
|
};
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
send(message) {
|
|
2667
|
-
this._rawIpc.postMessage(message);
|
|
2668
|
-
}
|
|
2669
|
-
sendAndTransfer(message) {
|
|
2670
|
-
const transfer = getTransferrables(message);
|
|
2671
|
-
this._rawIpc.postMessage(message, transfer);
|
|
2672
|
-
}
|
|
2673
|
-
dispose() {
|
|
2674
|
-
this._rawIpc.close();
|
|
2675
|
-
}
|
|
2676
|
-
onMessage(callback) {
|
|
2677
|
-
this._rawIpc.addEventListener('message', callback);
|
|
2678
|
-
}
|
|
2679
|
-
onClose(callback) {}
|
|
2680
|
-
}
|
|
2681
|
-
const wrap$5 = messagePort => {
|
|
2682
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
2570
|
+
const getPreference = async key => {
|
|
2571
|
+
return await invoke$1('Preferences.get', key);
|
|
2683
2572
|
};
|
|
2684
|
-
const
|
|
2685
|
-
|
|
2686
|
-
create: create$5$1,
|
|
2687
|
-
signal: signal$1,
|
|
2688
|
-
wrap: wrap$5
|
|
2573
|
+
const getAllExtensions$1 = async () => {
|
|
2574
|
+
return invoke$1('ExtensionManagement.getAllExtensions');
|
|
2689
2575
|
};
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
const callbacks = Object.create(null);
|
|
2693
|
-
const get$1 = id => {
|
|
2694
|
-
return callbacks[id];
|
|
2576
|
+
const getExtension$2 = async id => {
|
|
2577
|
+
return invoke$1('ExtensionManagement.getExtension', id);
|
|
2695
2578
|
};
|
|
2696
|
-
const
|
|
2697
|
-
|
|
2579
|
+
const openNativeFolder = async uri => {
|
|
2580
|
+
await invoke$1('OpenNativeFolder.openNativeFolder', uri);
|
|
2698
2581
|
};
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
super(message);
|
|
2702
|
-
this.name = 'JsonRpcError';
|
|
2703
|
-
}
|
|
2704
|
-
}
|
|
2705
|
-
const NewLine = '\n';
|
|
2706
|
-
const DomException = 'DOMException';
|
|
2707
|
-
const ReferenceError$1 = 'ReferenceError';
|
|
2708
|
-
const SyntaxError$1 = 'SyntaxError';
|
|
2709
|
-
const TypeError$1 = 'TypeError';
|
|
2710
|
-
const getErrorConstructor = (message, type) => {
|
|
2711
|
-
if (type) {
|
|
2712
|
-
switch (type) {
|
|
2713
|
-
case DomException:
|
|
2714
|
-
return DOMException;
|
|
2715
|
-
case ReferenceError$1:
|
|
2716
|
-
return ReferenceError;
|
|
2717
|
-
case SyntaxError$1:
|
|
2718
|
-
return SyntaxError;
|
|
2719
|
-
case TypeError$1:
|
|
2720
|
-
return TypeError;
|
|
2721
|
-
default:
|
|
2722
|
-
return Error;
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
if (message.startsWith('TypeError: ')) {
|
|
2726
|
-
return TypeError;
|
|
2727
|
-
}
|
|
2728
|
-
if (message.startsWith('SyntaxError: ')) {
|
|
2729
|
-
return SyntaxError;
|
|
2730
|
-
}
|
|
2731
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
2732
|
-
return ReferenceError;
|
|
2733
|
-
}
|
|
2734
|
-
return Error;
|
|
2582
|
+
const uninstallExtension = async id => {
|
|
2583
|
+
return invoke$1('ExtensionManagement.uninstall', id);
|
|
2735
2584
|
};
|
|
2736
|
-
const
|
|
2737
|
-
|
|
2738
|
-
if (ErrorConstructor === DOMException && name) {
|
|
2739
|
-
return new ErrorConstructor(message, name);
|
|
2740
|
-
}
|
|
2741
|
-
if (ErrorConstructor === Error) {
|
|
2742
|
-
const error = new Error(message);
|
|
2743
|
-
if (name && name !== 'VError') {
|
|
2744
|
-
error.name = name;
|
|
2745
|
-
}
|
|
2746
|
-
return error;
|
|
2747
|
-
}
|
|
2748
|
-
return new ErrorConstructor(message);
|
|
2585
|
+
const openExtensionSearch$1 = async () => {
|
|
2586
|
+
return invoke$1('SideBar.openViewlet', 'Extensions');
|
|
2749
2587
|
};
|
|
2750
|
-
const
|
|
2751
|
-
return
|
|
2588
|
+
const setExtensionsSearchValue = async searchValue => {
|
|
2589
|
+
return invoke$1('Extensions.handleInput', searchValue, Script$1);
|
|
2752
2590
|
};
|
|
2753
|
-
const
|
|
2754
|
-
|
|
2591
|
+
const openExternal$1 = async uri => {
|
|
2592
|
+
await invoke$1('Open.openExternal', uri);
|
|
2755
2593
|
};
|
|
2756
|
-
const
|
|
2757
|
-
|
|
2758
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
2759
|
-
return currentStack;
|
|
2594
|
+
const openUrl = async uri => {
|
|
2595
|
+
await invoke$1('Open.openUrl', uri);
|
|
2760
2596
|
};
|
|
2761
|
-
|
|
2762
|
-
|
|
2597
|
+
|
|
2598
|
+
/* eslint-disable unicorn/prefer-export-from */
|
|
2599
|
+
|
|
2600
|
+
const {
|
|
2601
|
+
getRuntimeStatus: getRuntimeStatus$1,
|
|
2602
|
+
set: set$4
|
|
2603
|
+
} = ExtensionHost;
|
|
2604
|
+
|
|
2605
|
+
const getRuntimeStatus = async extensionId => {
|
|
2606
|
+
// @ts-ignore
|
|
2607
|
+
const status = await getRuntimeStatus$1(extensionId);
|
|
2608
|
+
// @ts-ignore
|
|
2609
|
+
return status;
|
|
2763
2610
|
};
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2611
|
+
|
|
2612
|
+
const getRuntimeStatusDetails = async extension => {
|
|
2613
|
+
const {
|
|
2614
|
+
activationEvent,
|
|
2615
|
+
activationTime,
|
|
2616
|
+
importTime,
|
|
2617
|
+
status
|
|
2618
|
+
} = await getRuntimeStatus(extension.id);
|
|
2619
|
+
return {
|
|
2620
|
+
activationTime,
|
|
2621
|
+
importTime,
|
|
2622
|
+
status,
|
|
2623
|
+
wasActivatedByEvent: activationEvent
|
|
2624
|
+
};
|
|
2770
2625
|
};
|
|
2771
|
-
|
|
2772
|
-
const
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
if (error && error instanceof Error) {
|
|
2776
|
-
if (typeof error.stack === 'string') {
|
|
2777
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
2778
|
-
}
|
|
2779
|
-
return error;
|
|
2780
|
-
}
|
|
2781
|
-
if (error && error.code && error.code === MethodNotFound) {
|
|
2782
|
-
const restoredError = new JsonRpcError(error.message);
|
|
2783
|
-
const parentStack = getParentStack(error);
|
|
2784
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
2785
|
-
return restoredError;
|
|
2786
|
-
}
|
|
2787
|
-
if (error && error.message) {
|
|
2788
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
2789
|
-
if (error.data) {
|
|
2790
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
2791
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
2792
|
-
} else if (error.data.stack) {
|
|
2793
|
-
restoredError.stack = error.data.stack;
|
|
2794
|
-
}
|
|
2795
|
-
if (error.data.codeFrame) {
|
|
2796
|
-
// @ts-ignore
|
|
2797
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
2798
|
-
}
|
|
2799
|
-
if (error.data.code) {
|
|
2800
|
-
// @ts-ignore
|
|
2801
|
-
restoredError.code = error.data.code;
|
|
2802
|
-
}
|
|
2803
|
-
if (error.data.type) {
|
|
2804
|
-
// @ts-ignore
|
|
2805
|
-
restoredError.name = error.data.type;
|
|
2806
|
-
}
|
|
2807
|
-
} else {
|
|
2808
|
-
if (error.stack) {
|
|
2809
|
-
const lowerStack = restoredError.stack || '';
|
|
2810
|
-
// @ts-ignore
|
|
2811
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
2812
|
-
const parentStack = getParentStack(error);
|
|
2813
|
-
// @ts-ignore
|
|
2814
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
2815
|
-
}
|
|
2816
|
-
if (error.codeFrame) {
|
|
2817
|
-
// @ts-ignore
|
|
2818
|
-
restoredError.codeFrame = error.codeFrame;
|
|
2819
|
-
}
|
|
2820
|
-
}
|
|
2821
|
-
return restoredError;
|
|
2626
|
+
|
|
2627
|
+
const featureRuntimeStatusEnabled = extension => {
|
|
2628
|
+
if (!extension || typeof extension !== 'object') {
|
|
2629
|
+
return false;
|
|
2822
2630
|
}
|
|
2823
|
-
if (
|
|
2824
|
-
return
|
|
2631
|
+
if ('main' in extension || 'browser' in extension) {
|
|
2632
|
+
return true;
|
|
2825
2633
|
}
|
|
2826
|
-
return
|
|
2634
|
+
return false;
|
|
2827
2635
|
};
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2636
|
+
|
|
2637
|
+
const formatTime = time => {
|
|
2638
|
+
return time.toFixed(2) + 'ms';
|
|
2639
|
+
};
|
|
2640
|
+
|
|
2641
|
+
const getActivationTimeVirtualDom = (importTime$1, activationTime$1) => {
|
|
2642
|
+
if (!activationTime$1 && !importTime$1) {
|
|
2643
|
+
return [];
|
|
2832
2644
|
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2645
|
+
const formattedImportTime = formatTime(importTime$1);
|
|
2646
|
+
const formattedTime = formatTime(activationTime$1);
|
|
2647
|
+
return [{
|
|
2648
|
+
childCount: 1,
|
|
2649
|
+
type: Dt
|
|
2650
|
+
}, text(importTime()), {
|
|
2651
|
+
childCount: 1,
|
|
2652
|
+
type: Dd
|
|
2653
|
+
}, text(formattedImportTime), {
|
|
2654
|
+
childCount: 1,
|
|
2655
|
+
type: Dt
|
|
2656
|
+
}, text(activationTime()), {
|
|
2657
|
+
childCount: 1,
|
|
2658
|
+
type: Dd
|
|
2659
|
+
}, text(formattedTime)];
|
|
2660
|
+
};
|
|
2661
|
+
|
|
2662
|
+
const None$1 = 0;
|
|
2663
|
+
const Importing = 1;
|
|
2664
|
+
const Activating = 2;
|
|
2665
|
+
const Activated = 3;
|
|
2666
|
+
const Error$1 = 4;
|
|
2667
|
+
|
|
2668
|
+
const getStatusMessage = statusType => {
|
|
2669
|
+
switch (statusType) {
|
|
2670
|
+
case Activated:
|
|
2671
|
+
return 'activated';
|
|
2672
|
+
case Activating:
|
|
2673
|
+
return 'Activating';
|
|
2674
|
+
case Error$1:
|
|
2675
|
+
return 'error';
|
|
2676
|
+
case Importing:
|
|
2677
|
+
return 'importing';
|
|
2678
|
+
case None$1:
|
|
2679
|
+
return 'none';
|
|
2680
|
+
default:
|
|
2681
|
+
return 'unknown';
|
|
2835
2682
|
}
|
|
2836
|
-
throw new JsonRpcError('unexpected response message');
|
|
2837
2683
|
};
|
|
2838
|
-
|
|
2839
|
-
|
|
2684
|
+
|
|
2685
|
+
const key = {
|
|
2686
|
+
childCount: 1,
|
|
2687
|
+
className: 'RuntimeStatusDefinitionListKey',
|
|
2688
|
+
type: Dt
|
|
2840
2689
|
};
|
|
2841
|
-
const
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
warn(`callback ${id} may already be disposed`);
|
|
2846
|
-
return;
|
|
2847
|
-
}
|
|
2848
|
-
fn(response);
|
|
2849
|
-
remove(id);
|
|
2690
|
+
const value = {
|
|
2691
|
+
childCount: 1,
|
|
2692
|
+
className: 'RuntimeStatusDefinitionListValue',
|
|
2693
|
+
type: Dd
|
|
2850
2694
|
};
|
|
2851
|
-
const
|
|
2852
|
-
const
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2695
|
+
const getStatusVirtualDom = status$1 => {
|
|
2696
|
+
const statusKey = status();
|
|
2697
|
+
const statusValue = getStatusMessage(status$1);
|
|
2698
|
+
return [key, text(`${statusKey}: `), value, text(`${statusValue}`)];
|
|
2699
|
+
};
|
|
2700
|
+
|
|
2701
|
+
const getChildCount$1 = (status, activationTime, importTime) => {
|
|
2702
|
+
let childCount = 0;
|
|
2703
|
+
childCount += 2; // status
|
|
2704
|
+
if (importTime || activationTime) {
|
|
2705
|
+
childCount += 4;
|
|
2858
2706
|
}
|
|
2859
|
-
return
|
|
2707
|
+
return childCount;
|
|
2860
2708
|
};
|
|
2861
|
-
const
|
|
2862
|
-
|
|
2709
|
+
const getRuntimeStatusVirtualDom = state => {
|
|
2710
|
+
const {
|
|
2711
|
+
activationTime: displayedImportTime,
|
|
2712
|
+
importTime: displayedActivationTime,
|
|
2713
|
+
status
|
|
2714
|
+
} = state;
|
|
2715
|
+
const heading = runtimeStatus();
|
|
2716
|
+
const childCount = getChildCount$1(status, displayedActivationTime, displayedImportTime);
|
|
2717
|
+
return [{
|
|
2718
|
+
childCount: 2,
|
|
2719
|
+
className: FeatureContent,
|
|
2720
|
+
type: Div
|
|
2721
|
+
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
2722
|
+
childCount,
|
|
2723
|
+
className: 'RuntimeStatusDefinitionList',
|
|
2724
|
+
type: Dl
|
|
2725
|
+
}, ...getStatusVirtualDom(status), ...getActivationTimeVirtualDom(displayedImportTime, displayedActivationTime)];
|
|
2863
2726
|
};
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
const
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
}
|
|
2870
|
-
|
|
2727
|
+
|
|
2728
|
+
const getSettingsTableEntry = setting => {
|
|
2729
|
+
const {
|
|
2730
|
+
id,
|
|
2731
|
+
label
|
|
2732
|
+
} = setting;
|
|
2733
|
+
// TODO watch out for null/undefined/number/string/array
|
|
2734
|
+
return [{
|
|
2735
|
+
type: Text,
|
|
2736
|
+
value: id
|
|
2737
|
+
}, {
|
|
2738
|
+
type: Text,
|
|
2739
|
+
value: label
|
|
2740
|
+
}];
|
|
2871
2741
|
};
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
data: error.stack,
|
|
2877
|
-
message: error.message
|
|
2878
|
-
};
|
|
2879
|
-
}
|
|
2742
|
+
|
|
2743
|
+
const getSettingsDetails = async extension => {
|
|
2744
|
+
const settings = extension.settings || [];
|
|
2745
|
+
const rows = settings.map(getSettingsTableEntry);
|
|
2880
2746
|
return {
|
|
2881
|
-
|
|
2882
|
-
data: {
|
|
2883
|
-
code: prettyError.code,
|
|
2884
|
-
codeFrame: prettyError.codeFrame,
|
|
2885
|
-
name: prettyError.name,
|
|
2886
|
-
stack: getStack(prettyError),
|
|
2887
|
-
type: getErrorType(prettyError)
|
|
2888
|
-
},
|
|
2889
|
-
message: prettyError.message
|
|
2747
|
+
settings: rows
|
|
2890
2748
|
};
|
|
2891
2749
|
};
|
|
2892
|
-
|
|
2750
|
+
|
|
2751
|
+
const featureSettingsEnabled = extension => {
|
|
2752
|
+
if (!hasProperty(extension, 'settings')) {
|
|
2753
|
+
return false;
|
|
2754
|
+
}
|
|
2755
|
+
return Array.isArray(extension.settings);
|
|
2756
|
+
};
|
|
2757
|
+
|
|
2758
|
+
const getSettingsTableEntries = rows => {
|
|
2759
|
+
const textId = id$1();
|
|
2760
|
+
const textLabel = label();
|
|
2893
2761
|
return {
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
jsonrpc: Two$1
|
|
2762
|
+
headings: [textId, textLabel],
|
|
2763
|
+
rows
|
|
2897
2764
|
};
|
|
2898
2765
|
};
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
const
|
|
2903
|
-
return
|
|
2766
|
+
|
|
2767
|
+
const getFeatureSettingsVirtualDom = rows => {
|
|
2768
|
+
const heading = settings();
|
|
2769
|
+
const tableInfo = getSettingsTableEntries(rows);
|
|
2770
|
+
return [{
|
|
2771
|
+
childCount: 2,
|
|
2772
|
+
className: FeatureContent,
|
|
2773
|
+
type: Div
|
|
2774
|
+
}, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
|
|
2904
2775
|
};
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2776
|
+
|
|
2777
|
+
const getSettingsVirtualDom = state => {
|
|
2778
|
+
return getFeatureSettingsVirtualDom(state.settings);
|
|
2779
|
+
};
|
|
2780
|
+
|
|
2781
|
+
const HandleClickCategory = 1;
|
|
2782
|
+
const HandleClickDisable = 2;
|
|
2783
|
+
const HandleClickEnable = 3;
|
|
2784
|
+
const HandleClickScrollToTop = 4;
|
|
2785
|
+
const HandleClickSetColorTheme = 5;
|
|
2786
|
+
const HandleClickSettings = 6;
|
|
2787
|
+
const HandleClickSize = 7;
|
|
2788
|
+
const HandleClickUninstall = 8;
|
|
2789
|
+
const HandleFeaturesClick = 9;
|
|
2790
|
+
const HandleIconError = 10;
|
|
2791
|
+
const HandleImageContextMenu = 11;
|
|
2792
|
+
const HandleReadmeContextMenu = 12;
|
|
2793
|
+
const HandleReadmeScroll = 13;
|
|
2794
|
+
const HandleTabsClick = 14;
|
|
2795
|
+
const HandleAdditionalDetailContextMenu = 15;
|
|
2796
|
+
const HandleReadmeClick = 16;
|
|
2797
|
+
const HandleSelectionChange = 17;
|
|
2798
|
+
const HandleTabFocus = 18;
|
|
2799
|
+
const HandleResourceLinkClick = 19;
|
|
2800
|
+
|
|
2801
|
+
const ActivationEvents = 'ActivationEvents';
|
|
2802
|
+
const Changelog = 'Changelog';
|
|
2803
|
+
const Commands = 'Commands';
|
|
2804
|
+
const Details = 'Details';
|
|
2805
|
+
const Enable = 'Enable';
|
|
2806
|
+
const Disable = 'Disable';
|
|
2807
|
+
const Features = 'Features';
|
|
2808
|
+
const JsonValidation = 'JsonValidation';
|
|
2809
|
+
const ProgrammingLanguages = 'ProgrammingLanguages';
|
|
2810
|
+
const RuntimeStatus = 'RuntimeStatus';
|
|
2811
|
+
const ScrollToTop = 'scrolltotop';
|
|
2812
|
+
const SetColorTheme = 'SetColorTheme';
|
|
2813
|
+
const Settings = 'Settings';
|
|
2814
|
+
const Theme = 'Theme';
|
|
2815
|
+
const Uninstall = 'Uninstall';
|
|
2816
|
+
const WebViews = 'WebViews';
|
|
2817
|
+
|
|
2818
|
+
const getScrollToTopVirtualDom = scrollToTopButtonEnabled => {
|
|
2819
|
+
return [{
|
|
2820
|
+
ariaLabel: scrollToTop(),
|
|
2821
|
+
childCount: 1,
|
|
2822
|
+
className: ScrollToTopButton,
|
|
2823
|
+
name: ScrollToTop,
|
|
2824
|
+
onClick: HandleClickScrollToTop,
|
|
2825
|
+
type: Button$1
|
|
2826
|
+
}, {
|
|
2827
|
+
childCount: 0,
|
|
2828
|
+
className: mergeClassNames(MaskIcon, MaskIconChevronUp),
|
|
2829
|
+
role: None$3,
|
|
2830
|
+
type: Div
|
|
2831
|
+
}];
|
|
2832
|
+
};
|
|
2833
|
+
|
|
2834
|
+
/* eslint-disable unicorn/prefer-export-from */
|
|
2835
|
+
|
|
2836
|
+
const {
|
|
2837
|
+
getVirtualDom,
|
|
2838
|
+
render,
|
|
2839
|
+
set: set$3
|
|
2840
|
+
} = MarkdownWorker;
|
|
2841
|
+
|
|
2842
|
+
const getMarkdownVirtualDom = async (html, options) => {
|
|
2843
|
+
string(html);
|
|
2844
|
+
const dom = await getVirtualDom(html);
|
|
2845
|
+
if (options?.scrollToTopEnabled) {
|
|
2846
|
+
const [firstNode, ...rest] = dom;
|
|
2847
|
+
const extraDom = getScrollToTopVirtualDom();
|
|
2848
|
+
return [{
|
|
2849
|
+
...firstNode,
|
|
2850
|
+
childCount: firstNode.childCount + 1,
|
|
2851
|
+
onClick: HandleReadmeClick,
|
|
2852
|
+
onScroll: HandleReadmeScroll,
|
|
2853
|
+
onSelectionChange: HandleSelectionChange
|
|
2854
|
+
}, ...extraDom, ...rest];
|
|
2855
|
+
}
|
|
2856
|
+
return dom;
|
|
2857
|
+
};
|
|
2858
|
+
|
|
2859
|
+
const getThemeItemMarkdown = (heading, items) => {
|
|
2860
|
+
let markdown = '';
|
|
2861
|
+
if (items.length > 0) {
|
|
2862
|
+
markdown += `### ${heading}`;
|
|
2863
|
+
markdown += '\n\n';
|
|
2864
|
+
for (const item of items) {
|
|
2865
|
+
markdown += `- ${item.label}`;
|
|
2866
|
+
markdown += '\n';
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
return markdown;
|
|
2870
|
+
};
|
|
2871
|
+
|
|
2872
|
+
const getColorThemeMarkdown = themes => {
|
|
2873
|
+
const heading = 'Color Themes';
|
|
2874
|
+
return getThemeItemMarkdown(heading, themes);
|
|
2875
|
+
};
|
|
2876
|
+
const getIconThemeMarkdown = iconThemes => {
|
|
2877
|
+
const heading = 'File Icon Themes';
|
|
2878
|
+
return getThemeItemMarkdown(heading, iconThemes);
|
|
2879
|
+
};
|
|
2880
|
+
const getProductIconThemeMarkdown = iconThemes => {
|
|
2881
|
+
const heading = 'Product Icon Themes';
|
|
2882
|
+
return getThemeItemMarkdown(heading, iconThemes);
|
|
2883
|
+
};
|
|
2884
|
+
const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
|
|
2885
|
+
let markdown = '';
|
|
2886
|
+
markdown += getColorThemeMarkdown(themes);
|
|
2887
|
+
markdown += getIconThemeMarkdown(iconThemes);
|
|
2888
|
+
markdown += getProductIconThemeMarkdown(productIconThemes);
|
|
2889
|
+
return markdown;
|
|
2890
|
+
};
|
|
2891
|
+
|
|
2892
|
+
const padBytes = bytes => {
|
|
2893
|
+
return bytes.toString(16).padStart(2, '0');
|
|
2894
|
+
};
|
|
2895
|
+
const hash = async content => {
|
|
2896
|
+
const sourceBytes = new TextEncoder().encode(content);
|
|
2897
|
+
const digest = await crypto.subtle.digest('SHA-256', sourceBytes);
|
|
2898
|
+
const resultBytes = [...new Uint8Array(digest)];
|
|
2899
|
+
return resultBytes.map(padBytes).join('');
|
|
2911
2900
|
};
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
return
|
|
2901
|
+
|
|
2902
|
+
const supportsNormalCacheKey = locationProtocol => {
|
|
2903
|
+
return locationProtocol === 'http:' || locationProtocol === 'https:';
|
|
2915
2904
|
};
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
// @ts-ignore
|
|
2922
|
-
message: error.message
|
|
2923
|
-
},
|
|
2924
|
-
id,
|
|
2925
|
-
jsonrpc: Two$1
|
|
2926
|
-
};
|
|
2905
|
+
|
|
2906
|
+
const getMarkdownCacheHash = async (markdown, options) => {
|
|
2907
|
+
const stringifiedOptions = JSON.stringify(options);
|
|
2908
|
+
const contents = `${markdown}:${stringifiedOptions}:${options.commit}`;
|
|
2909
|
+
return hash(contents);
|
|
2927
2910
|
};
|
|
2928
|
-
const
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
return
|
|
2932
|
-
} catch (error) {
|
|
2933
|
-
if (ipc.canUseSimpleErrorResponse) {
|
|
2934
|
-
return getErrorResponseSimple(message.id, error);
|
|
2935
|
-
}
|
|
2936
|
-
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2911
|
+
const getMarkdownCacheKey = async (markdown, options) => {
|
|
2912
|
+
const hash = await getMarkdownCacheHash(markdown, options);
|
|
2913
|
+
if (supportsNormalCacheKey(options.locationProtocol)) {
|
|
2914
|
+
return `/markdown/${hash}`;
|
|
2937
2915
|
}
|
|
2916
|
+
// workaround for electron bug
|
|
2917
|
+
return `https://-/markdown/${hash}`;
|
|
2938
2918
|
};
|
|
2939
|
-
|
|
2940
|
-
|
|
2919
|
+
|
|
2920
|
+
// TODO pass application name from renderer worker to not hardcode it
|
|
2921
|
+
|
|
2922
|
+
const cachedCaches = Object.create(null);
|
|
2923
|
+
const noopCache = {
|
|
2924
|
+
async match() {
|
|
2925
|
+
return undefined;
|
|
2926
|
+
},
|
|
2927
|
+
async put() {}
|
|
2941
2928
|
};
|
|
2942
|
-
const
|
|
2943
|
-
// ignore
|
|
2929
|
+
const supportsStorageBuckets = () => {
|
|
2930
|
+
// @ts-ignore
|
|
2931
|
+
return Boolean(navigator.storageBuckets);
|
|
2944
2932
|
};
|
|
2945
|
-
const
|
|
2946
|
-
|
|
2933
|
+
const getCacheInternal = async (cacheName, bucketName) => {
|
|
2934
|
+
if (!supportsStorageBuckets()) {
|
|
2935
|
+
return noopCache;
|
|
2936
|
+
}
|
|
2937
|
+
const twoWeeks = 14 * 24 * 60 * 60 * 1000;
|
|
2938
|
+
// @ts-ignore
|
|
2939
|
+
const bucket = await navigator.storageBuckets.open(bucketName, {
|
|
2940
|
+
expires: Date.now() + twoWeeks,
|
|
2941
|
+
quota: 100 * 1024 * 1024 // 100MB
|
|
2942
|
+
});
|
|
2943
|
+
const cache = await bucket.caches.open(cacheName);
|
|
2944
|
+
return cache;
|
|
2947
2945
|
};
|
|
2948
|
-
const
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
const normalizeParams = args => {
|
|
2952
|
-
if (args.length === 1) {
|
|
2953
|
-
const options = args[0];
|
|
2954
|
-
return {
|
|
2955
|
-
execute: options.execute,
|
|
2956
|
-
ipc: options.ipc,
|
|
2957
|
-
logError: options.logError || defaultLogError,
|
|
2958
|
-
message: options.message,
|
|
2959
|
-
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
2960
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
2961
|
-
resolve: options.resolve || defaultResolve
|
|
2962
|
-
};
|
|
2946
|
+
const getCache = (cacheName, bucketName) => {
|
|
2947
|
+
if (!(cacheName in cachedCaches)) {
|
|
2948
|
+
cachedCaches[cacheName] = getCacheInternal(cacheName, bucketName);
|
|
2963
2949
|
}
|
|
2964
|
-
return
|
|
2965
|
-
execute: args[2],
|
|
2966
|
-
ipc: args[0],
|
|
2967
|
-
logError: args[5],
|
|
2968
|
-
message: args[1],
|
|
2969
|
-
preparePrettyError: args[4],
|
|
2970
|
-
requiresSocket: args[6],
|
|
2971
|
-
resolve: args[3]
|
|
2972
|
-
};
|
|
2950
|
+
return cachedCaches[cacheName];
|
|
2973
2951
|
};
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
return;
|
|
2952
|
+
|
|
2953
|
+
// TODO pass application name from renderer worker to not hardcode it
|
|
2954
|
+
const cacheName = 'lvce-editor/markdown-cache';
|
|
2955
|
+
const has = async (key, bucketName) => {
|
|
2956
|
+
const cache = await getCache(cacheName, bucketName);
|
|
2957
|
+
const response = await cache.match(key);
|
|
2958
|
+
return Boolean(response);
|
|
2959
|
+
};
|
|
2960
|
+
const get$1 = async (key, bucketName) => {
|
|
2961
|
+
const cache = await getCache(cacheName, bucketName);
|
|
2962
|
+
const response = await cache.match(key);
|
|
2963
|
+
const text = await response?.text();
|
|
2964
|
+
return text || '';
|
|
2965
|
+
};
|
|
2966
|
+
const set$2 = async (key, bucketName, value) => {
|
|
2967
|
+
const cache = await getCache(cacheName, bucketName);
|
|
2968
|
+
await cache.put(key, new Response(value, {
|
|
2969
|
+
headers: {
|
|
2970
|
+
'Content-Length': `${value.length}`,
|
|
2971
|
+
'Content-Type': 'application/markdown'
|
|
2995
2972
|
}
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
2973
|
+
}));
|
|
2974
|
+
};
|
|
2975
|
+
|
|
2976
|
+
const renderMarkdownCached = async (markdown, options) => {
|
|
2977
|
+
const cacheKey = await getMarkdownCacheKey(markdown, options);
|
|
2978
|
+
const bucketName = `markdown-cache`;
|
|
2979
|
+
const hasItem = await has(cacheKey, bucketName);
|
|
2980
|
+
if (hasItem) {
|
|
2981
|
+
const value = await get$1(cacheKey, bucketName);
|
|
2982
|
+
return value; // TODO validate if it's valid
|
|
3002
2983
|
}
|
|
3003
|
-
|
|
2984
|
+
const html = await render(markdown, options);
|
|
2985
|
+
await set$2(cacheKey, bucketName, html);
|
|
2986
|
+
return html;
|
|
3004
2987
|
};
|
|
3005
2988
|
|
|
3006
|
-
const
|
|
2989
|
+
const renderMarkdown = async (markdown, options) => {
|
|
2990
|
+
const html = await renderMarkdownCached(markdown, options);
|
|
2991
|
+
return html;
|
|
2992
|
+
};
|
|
3007
2993
|
|
|
3008
|
-
const
|
|
2994
|
+
const getThemeDetails = async (extension, baseUrl, locationProtocol) => {
|
|
2995
|
+
const {
|
|
2996
|
+
colorThemes,
|
|
2997
|
+
iconThemes,
|
|
2998
|
+
productIconThemes
|
|
2999
|
+
} = extension;
|
|
3000
|
+
const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
|
|
3001
|
+
const rendered = await renderMarkdown(markdown, {
|
|
3002
|
+
baseUrl,
|
|
3003
|
+
locationProtocol
|
|
3004
|
+
});
|
|
3005
|
+
const themesMarkdownDom = await getMarkdownVirtualDom(rendered);
|
|
3009
3006
|
return {
|
|
3010
|
-
|
|
3011
|
-
method,
|
|
3012
|
-
params
|
|
3007
|
+
themesMarkdownDom
|
|
3013
3008
|
};
|
|
3014
3009
|
};
|
|
3015
3010
|
|
|
3016
|
-
const
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
params
|
|
3022
|
-
};
|
|
3023
|
-
return message;
|
|
3011
|
+
const featureColorThemeEnabled = extension => {
|
|
3012
|
+
if (!hasProperty(extension, 'colorThemes')) {
|
|
3013
|
+
return false;
|
|
3014
|
+
}
|
|
3015
|
+
return Array.isArray(extension.colorThemes);
|
|
3024
3016
|
};
|
|
3025
3017
|
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3018
|
+
const featureIconThemeEnabled = extension => {
|
|
3019
|
+
if (!hasProperty(extension, 'iconThemes')) {
|
|
3020
|
+
return false;
|
|
3021
|
+
}
|
|
3022
|
+
return Array.isArray(extension.iconThemes);
|
|
3029
3023
|
};
|
|
3030
3024
|
|
|
3031
|
-
const
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
} = Promise.withResolvers();
|
|
3037
|
-
map[id] = resolve;
|
|
3038
|
-
return {
|
|
3039
|
-
id,
|
|
3040
|
-
promise
|
|
3041
|
-
};
|
|
3025
|
+
const featureProductIconThemeEnabled = extension => {
|
|
3026
|
+
if (!hasProperty(extension, 'productIconThemes')) {
|
|
3027
|
+
return false;
|
|
3028
|
+
}
|
|
3029
|
+
return Array.isArray(extension.productIconThemes);
|
|
3042
3030
|
};
|
|
3043
3031
|
|
|
3044
|
-
const
|
|
3045
|
-
|
|
3046
|
-
id,
|
|
3047
|
-
promise
|
|
3048
|
-
} = registerPromise(callbacks);
|
|
3049
|
-
const message = create$7(id, method, params);
|
|
3050
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
3051
|
-
ipc.sendAndTransfer(message);
|
|
3052
|
-
} else {
|
|
3053
|
-
ipc.send(message);
|
|
3054
|
-
}
|
|
3055
|
-
const responseMessage = await promise;
|
|
3056
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
3032
|
+
const featureThemeEnabled = extension => {
|
|
3033
|
+
return featureColorThemeEnabled(extension) || featureIconThemeEnabled(extension) || featureProductIconThemeEnabled(extension);
|
|
3057
3034
|
};
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
fn(response);
|
|
3067
|
-
delete callbacks[id];
|
|
3068
|
-
};
|
|
3069
|
-
const rpc = {
|
|
3070
|
-
async dispose() {
|
|
3071
|
-
await ipc?.dispose();
|
|
3072
|
-
},
|
|
3073
|
-
invoke(method, ...params) {
|
|
3074
|
-
return invokeHelper(callbacks, ipc, method, params, false);
|
|
3075
|
-
},
|
|
3076
|
-
invokeAndTransfer(method, ...params) {
|
|
3077
|
-
return invokeHelper(callbacks, ipc, method, params, true);
|
|
3078
|
-
},
|
|
3079
|
-
// @ts-ignore
|
|
3080
|
-
ipc,
|
|
3081
|
-
/**
|
|
3082
|
-
* @deprecated
|
|
3083
|
-
*/
|
|
3084
|
-
send(method, ...params) {
|
|
3085
|
-
const message = create$8(method, params);
|
|
3086
|
-
ipc.send(message);
|
|
3035
|
+
|
|
3036
|
+
const getVirtualDomChildCount = dom => {
|
|
3037
|
+
const max = dom.length - 1;
|
|
3038
|
+
let stack = [];
|
|
3039
|
+
for (let i = max; i >= 0; i--) {
|
|
3040
|
+
const element = dom[i];
|
|
3041
|
+
if (element.childCount > 0) {
|
|
3042
|
+
stack = stack.slice(element.childCount);
|
|
3087
3043
|
}
|
|
3088
|
-
|
|
3089
|
-
|
|
3044
|
+
stack.unshift(element);
|
|
3045
|
+
}
|
|
3046
|
+
return stack.length;
|
|
3090
3047
|
};
|
|
3091
3048
|
|
|
3092
|
-
const
|
|
3093
|
-
|
|
3049
|
+
const getFeatureThemesVirtualDom = themesDom => {
|
|
3050
|
+
const childCount = getVirtualDomChildCount(themesDom);
|
|
3051
|
+
const heading = theme();
|
|
3052
|
+
return [{
|
|
3053
|
+
childCount: 2,
|
|
3054
|
+
className: FeatureContent,
|
|
3055
|
+
type: Div
|
|
3056
|
+
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
3057
|
+
childCount,
|
|
3058
|
+
className: DefaultMarkdown,
|
|
3059
|
+
type: Div
|
|
3060
|
+
}, ...themesDom];
|
|
3094
3061
|
};
|
|
3095
|
-
|
|
3096
|
-
|
|
3062
|
+
|
|
3063
|
+
const getThemeVirtualDom = state => {
|
|
3064
|
+
return getFeatureThemesVirtualDom(state.themesMarkdownDom);
|
|
3097
3065
|
};
|
|
3098
|
-
|
|
3099
|
-
|
|
3066
|
+
|
|
3067
|
+
const toWebView = rawWebView => {
|
|
3068
|
+
const {
|
|
3069
|
+
contentSecurityPolicy,
|
|
3070
|
+
elements,
|
|
3071
|
+
id,
|
|
3072
|
+
selector
|
|
3073
|
+
} = rawWebView;
|
|
3074
|
+
return {
|
|
3075
|
+
contentSecurityPolicyString: JSON.stringify(contentSecurityPolicy),
|
|
3076
|
+
elementsString: JSON.stringify(elements, null, 2),
|
|
3077
|
+
id,
|
|
3078
|
+
selectorString: JSON.stringify(selector)
|
|
3079
|
+
};
|
|
3100
3080
|
};
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
const
|
|
3104
|
-
return
|
|
3081
|
+
|
|
3082
|
+
const getWebViews = extension => {
|
|
3083
|
+
const rawWebViews = extension.webViews || [];
|
|
3084
|
+
return rawWebViews.map(toWebView);
|
|
3105
3085
|
};
|
|
3106
3086
|
|
|
3107
|
-
const
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
ipc.on('message', handleMessage);
|
|
3113
|
-
}
|
|
3087
|
+
const getWebViewsDetails = async extension => {
|
|
3088
|
+
const webViews = getWebViews(extension);
|
|
3089
|
+
return {
|
|
3090
|
+
webViews
|
|
3091
|
+
};
|
|
3114
3092
|
};
|
|
3115
3093
|
|
|
3116
|
-
const
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
module.signal(rawIpc);
|
|
3094
|
+
const featureWebViewsEnabled = extension => {
|
|
3095
|
+
if (!hasProperty(extension, 'webViews')) {
|
|
3096
|
+
return false;
|
|
3120
3097
|
}
|
|
3121
|
-
|
|
3122
|
-
return ipc;
|
|
3098
|
+
return Array.isArray(extension.webViews);
|
|
3123
3099
|
};
|
|
3124
3100
|
|
|
3125
|
-
const
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
}) => {
|
|
3130
|
-
// TODO create a commandMap per rpc instance
|
|
3131
|
-
register(commandMap);
|
|
3132
|
-
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
3133
|
-
isMessagePortOpen,
|
|
3134
|
-
messagePort
|
|
3135
|
-
});
|
|
3136
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
3137
|
-
handleIpc(ipc);
|
|
3138
|
-
const rpc = createRpc(ipc);
|
|
3139
|
-
messagePort.start();
|
|
3140
|
-
return rpc;
|
|
3101
|
+
const heading = {
|
|
3102
|
+
childCount: 1,
|
|
3103
|
+
className: DefinitionListItemHeading,
|
|
3104
|
+
type: H2
|
|
3141
3105
|
};
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3106
|
+
const pre = {
|
|
3107
|
+
childCount: 1,
|
|
3108
|
+
className: DefinitionListItemValue,
|
|
3109
|
+
type: Pre
|
|
3110
|
+
};
|
|
3111
|
+
const item = {
|
|
3112
|
+
childCount: 2,
|
|
3113
|
+
className: DefinitionListItem,
|
|
3114
|
+
type: Div
|
|
3115
|
+
};
|
|
3116
|
+
const getWebViewVirtualDom = webView => {
|
|
3148
3117
|
const {
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3118
|
+
contentSecurityPolicyString,
|
|
3119
|
+
elementsString,
|
|
3120
|
+
id,
|
|
3121
|
+
selectorString
|
|
3122
|
+
} = webView;
|
|
3123
|
+
const textId = id$1();
|
|
3124
|
+
const textSelector = selector();
|
|
3125
|
+
const textContentSecurityPolicy = contentSecurityPolicy();
|
|
3126
|
+
const textElements = elements();
|
|
3127
|
+
return [{
|
|
3128
|
+
childCount: 4,
|
|
3129
|
+
className: FeatureWebView,
|
|
3130
|
+
type: Div
|
|
3131
|
+
}, item, heading, text(textId), pre, text(id), item, heading, text(textSelector), pre, text(selectorString), item, heading, text(textContentSecurityPolicy), pre, text(contentSecurityPolicyString), item, heading, text(textElements), pre, text(elementsString)];
|
|
3158
3132
|
};
|
|
3159
3133
|
|
|
3160
|
-
const
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
const rpc = await getOrCreate();
|
|
3171
|
-
await rpc.dispose();
|
|
3172
|
-
},
|
|
3173
|
-
async invoke(method, ...params) {
|
|
3174
|
-
const rpc = await getOrCreate();
|
|
3175
|
-
return rpc.invoke(method, ...params);
|
|
3176
|
-
},
|
|
3177
|
-
async invokeAndTransfer(method, ...params) {
|
|
3178
|
-
const rpc = await getOrCreate();
|
|
3179
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
3180
|
-
},
|
|
3181
|
-
async send(method, ...params) {
|
|
3182
|
-
const rpc = await getOrCreate();
|
|
3183
|
-
rpc.send(method, ...params);
|
|
3184
|
-
}
|
|
3185
|
-
};
|
|
3134
|
+
const getFeatureWebViewsVirtualDom = webViews$1 => {
|
|
3135
|
+
const heading = webViews();
|
|
3136
|
+
return [{
|
|
3137
|
+
childCount: 2,
|
|
3138
|
+
className: FeatureContent,
|
|
3139
|
+
type: Div
|
|
3140
|
+
}, ...getFeatureContentHeadingVirtualDom(heading), {
|
|
3141
|
+
childCount: webViews$1.length,
|
|
3142
|
+
type: Div
|
|
3143
|
+
}, ...webViews$1.flatMap(getWebViewVirtualDom)];
|
|
3186
3144
|
};
|
|
3187
3145
|
|
|
3188
|
-
const
|
|
3189
|
-
|
|
3190
|
-
isMessagePortOpen,
|
|
3191
|
-
send
|
|
3192
|
-
}) => {
|
|
3193
|
-
return createSharedLazyRpc(() => {
|
|
3194
|
-
return create$4({
|
|
3195
|
-
commandMap,
|
|
3196
|
-
isMessagePortOpen,
|
|
3197
|
-
send
|
|
3198
|
-
});
|
|
3199
|
-
});
|
|
3146
|
+
const getWebViewsVirtualDom = state => {
|
|
3147
|
+
return getFeatureWebViewsVirtualDom(state.webViews);
|
|
3200
3148
|
};
|
|
3201
3149
|
|
|
3202
|
-
const
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3150
|
+
const registerAllFeatures = () => {
|
|
3151
|
+
register$1({
|
|
3152
|
+
getDetails: getThemeDetails,
|
|
3153
|
+
getLabel: theme,
|
|
3154
|
+
getVirtualDom: getThemeVirtualDom,
|
|
3155
|
+
id: Theme,
|
|
3156
|
+
isEnabled: featureThemeEnabled
|
|
3157
|
+
});
|
|
3158
|
+
register$1({
|
|
3159
|
+
getDetails: getCommandsDetails,
|
|
3160
|
+
getLabel: commands$1,
|
|
3161
|
+
getVirtualDom: getCommandsVirtualDom,
|
|
3162
|
+
id: Commands,
|
|
3163
|
+
isEnabled: featureCommandsEnabled
|
|
3164
|
+
});
|
|
3165
|
+
register$1({
|
|
3166
|
+
getDetails: getSettingsDetails,
|
|
3167
|
+
getLabel: settings,
|
|
3168
|
+
getVirtualDom: getSettingsVirtualDom,
|
|
3169
|
+
id: Settings,
|
|
3170
|
+
isEnabled: featureSettingsEnabled
|
|
3171
|
+
});
|
|
3172
|
+
register$1({
|
|
3173
|
+
getDetails: getJsonValidationDetails,
|
|
3174
|
+
getLabel: jsonValidation,
|
|
3175
|
+
getVirtualDom: getJsonValidationVirtualDom,
|
|
3176
|
+
id: JsonValidation,
|
|
3177
|
+
isEnabled: featureJsonValidationEnabled
|
|
3178
|
+
});
|
|
3179
|
+
register$1({
|
|
3180
|
+
getDetails: getFeatureDetailsProgrammingLanguages,
|
|
3181
|
+
getLabel: programmingLanguages,
|
|
3182
|
+
getVirtualDom: getProgrammingLanguagesVirtualDom,
|
|
3183
|
+
id: ProgrammingLanguages,
|
|
3184
|
+
isEnabled: featureProgrammingLanguagesEnabled
|
|
3185
|
+
});
|
|
3186
|
+
register$1({
|
|
3187
|
+
getDetails: getWebViewsDetails,
|
|
3188
|
+
getLabel: webViews,
|
|
3189
|
+
getVirtualDom: getWebViewsVirtualDom,
|
|
3190
|
+
id: WebViews,
|
|
3191
|
+
isEnabled: featureWebViewsEnabled
|
|
3192
|
+
});
|
|
3193
|
+
register$1({
|
|
3194
|
+
getDetails: getActivationEventsDetails,
|
|
3195
|
+
getLabel: activationEvents,
|
|
3196
|
+
getVirtualDom: getActivationEventsVirtualDom,
|
|
3197
|
+
id: ActivationEvents,
|
|
3198
|
+
isEnabled: featureActivationEventsEnabled
|
|
3199
|
+
});
|
|
3200
|
+
register$1({
|
|
3201
|
+
getDetails: getRuntimeStatusDetails,
|
|
3202
|
+
getLabel: runtimeStatus,
|
|
3203
|
+
getVirtualDom: getRuntimeStatusVirtualDom,
|
|
3204
|
+
id: RuntimeStatus,
|
|
3205
|
+
isEnabled: featureRuntimeStatusEnabled
|
|
3206
|
+
});
|
|
3211
3207
|
};
|
|
3212
3208
|
|
|
3213
3209
|
const toCommandId = key => {
|
|
@@ -3754,7 +3750,7 @@ const getExtension$1 = async (id, platform) => {
|
|
|
3754
3750
|
|
|
3755
3751
|
const getExtensionNew = async id => {
|
|
3756
3752
|
try {
|
|
3757
|
-
const rpc = get$
|
|
3753
|
+
const rpc = get$2(ExtensionManagementWorker);
|
|
3758
3754
|
return await rpc.invoke('Extensions.getExtension', id);
|
|
3759
3755
|
} catch {
|
|
3760
3756
|
// ignore
|
|
@@ -4342,10 +4338,7 @@ const getDisplaySize = size => {
|
|
|
4342
4338
|
};
|
|
4343
4339
|
|
|
4344
4340
|
const supportsFileSize = uri => {
|
|
4345
|
-
|
|
4346
|
-
return false;
|
|
4347
|
-
}
|
|
4348
|
-
return true;
|
|
4341
|
+
return !uri.startsWith('http:') && !uri.startsWith('https://');
|
|
4349
4342
|
};
|
|
4350
4343
|
|
|
4351
4344
|
const getFolderSize = async uri => {
|
|
@@ -4791,7 +4784,6 @@ const handleReadmeLinkClick = async (linkProtectionEnabled, platform, href) => {
|
|
|
4791
4784
|
}
|
|
4792
4785
|
}
|
|
4793
4786
|
await openExternal(href, platform);
|
|
4794
|
-
return;
|
|
4795
4787
|
};
|
|
4796
4788
|
|
|
4797
4789
|
const isExternalLink$1 = href => {
|
|
@@ -5035,7 +5027,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
|
|
|
5035
5027
|
|
|
5036
5028
|
const createExtensionHostWorkerRpc = async () => {
|
|
5037
5029
|
try {
|
|
5038
|
-
const rpc = await create$
|
|
5030
|
+
const rpc = await create$5({
|
|
5039
5031
|
commandMap: {},
|
|
5040
5032
|
send: sendMessagePortToExtensionHostWorker
|
|
5041
5033
|
});
|
|
@@ -5052,7 +5044,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
5052
5044
|
|
|
5053
5045
|
const createExtensionManagementWorkerRpc = async () => {
|
|
5054
5046
|
try {
|
|
5055
|
-
const rpc = await create$
|
|
5047
|
+
const rpc = await create$5({
|
|
5056
5048
|
commandMap: {},
|
|
5057
5049
|
send: port => sendMessagePortToExtensionManagementWorker(port, 0)
|
|
5058
5050
|
});
|
|
@@ -5077,7 +5069,7 @@ const sendMessagePortToFileSystemWorker = async port => {
|
|
|
5077
5069
|
|
|
5078
5070
|
const createFileSystemWorkerRpc = async () => {
|
|
5079
5071
|
try {
|
|
5080
|
-
const rpc = await create$
|
|
5072
|
+
const rpc = await create$5({
|
|
5081
5073
|
commandMap: {},
|
|
5082
5074
|
send: sendMessagePortToFileSystemWorker
|
|
5083
5075
|
});
|
|
@@ -5098,7 +5090,7 @@ const sendMessagePortToMarkdownWorker = async port => {
|
|
|
5098
5090
|
|
|
5099
5091
|
const createMarkdownWorkerRpc = async () => {
|
|
5100
5092
|
try {
|
|
5101
|
-
const rpc = await create$
|
|
5093
|
+
const rpc = await create$4({
|
|
5102
5094
|
commandMap: {},
|
|
5103
5095
|
send: sendMessagePortToMarkdownWorker
|
|
5104
5096
|
});
|
|
@@ -5922,7 +5914,7 @@ const commandMap = {
|
|
|
5922
5914
|
|
|
5923
5915
|
const listen = async () => {
|
|
5924
5916
|
registerCommands(commandMap);
|
|
5925
|
-
const rpc = await create$
|
|
5917
|
+
const rpc = await create$3({
|
|
5926
5918
|
commandMap: commandMap
|
|
5927
5919
|
});
|
|
5928
5920
|
set$5(rpc);
|