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