@lvce-editor/editor-worker 2.6.0 → 3.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/api/api.d.ts +3 -0
- package/dist/editorWorkerMain.js +379 -178
- package/package.json +1 -1
package/dist/api/api.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ interface EventMap {
|
|
|
9
9
|
'EditorCompletion.loadContent': (editorUid: number, state: any) => Promise<any>
|
|
10
10
|
'EditorCompletion.selectCurrent': (editorUid: number, state: any) => Promise<any>
|
|
11
11
|
'EditorCompletion.selectIndex': (editorUid: number, state: any, index: number) => Promise<any>
|
|
12
|
+
'EditorCompletion.openDetails': (editorUid: number, state: any) => Promise<any>
|
|
13
|
+
'EditorCompletion.closeDetails': (editorUid: number, state: any) => Promise<any>
|
|
14
|
+
'EditorCompletion.toggleDetails': (editorUid: number, state: any) => Promise<any>
|
|
12
15
|
'FindWidget.focusFirst': (state: any) => Promise<any>
|
|
13
16
|
'FindWidget.focusIndex': (state: any, index: number) => Promise<any>
|
|
14
17
|
'FindWidget.focusLast': (state: any) => Promise<any>
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -4,7 +4,7 @@ let AssertionError$1 = class AssertionError extends Error {
|
|
|
4
4
|
this.name = 'AssertionError';
|
|
5
5
|
}
|
|
6
6
|
};
|
|
7
|
-
const getType$
|
|
7
|
+
const getType$2 = value => {
|
|
8
8
|
switch (typeof value) {
|
|
9
9
|
case 'number':
|
|
10
10
|
return 'number';
|
|
@@ -27,31 +27,31 @@ const getType$1 = value => {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
const object = value => {
|
|
30
|
-
const type = getType$
|
|
30
|
+
const type = getType$2(value);
|
|
31
31
|
if (type !== 'object') {
|
|
32
32
|
throw new AssertionError$1('expected value to be of type object');
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
const number$1 = value => {
|
|
36
|
-
const type = getType$
|
|
36
|
+
const type = getType$2(value);
|
|
37
37
|
if (type !== 'number') {
|
|
38
38
|
throw new AssertionError$1('expected value to be of type number');
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
const array = value => {
|
|
42
|
-
const type = getType$
|
|
42
|
+
const type = getType$2(value);
|
|
43
43
|
if (type !== 'array') {
|
|
44
44
|
throw new AssertionError$1('expected value to be of type array');
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
const string = value => {
|
|
48
|
-
const type = getType$
|
|
48
|
+
const type = getType$2(value);
|
|
49
49
|
if (type !== 'string') {
|
|
50
50
|
throw new AssertionError$1('expected value to be of type string');
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
const boolean = value => {
|
|
54
|
-
const type = getType$
|
|
54
|
+
const type = getType$2(value);
|
|
55
55
|
if (type !== 'boolean') {
|
|
56
56
|
throw new AssertionError$1('expected value to be of type boolean');
|
|
57
57
|
}
|
|
@@ -211,10 +211,10 @@ const renderColorPickerDom = {
|
|
|
211
211
|
return ['Viewlet.setDom2', dom];
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
|
-
const render$
|
|
214
|
+
const render$6 = [renderColorPickerDom, renderColor, renderOffsetX];
|
|
215
215
|
const renderColorPicker = async (oldState, newState) => {
|
|
216
216
|
const commands = [];
|
|
217
|
-
for (const item of render$
|
|
217
|
+
for (const item of render$6) {
|
|
218
218
|
if (!item.isEqual(oldState, newState)) {
|
|
219
219
|
commands.push(item.apply(oldState, newState));
|
|
220
220
|
}
|
|
@@ -1140,7 +1140,7 @@ class AssertionError extends Error {
|
|
|
1140
1140
|
this.name = 'AssertionError';
|
|
1141
1141
|
}
|
|
1142
1142
|
}
|
|
1143
|
-
const getType = value => {
|
|
1143
|
+
const getType$1 = value => {
|
|
1144
1144
|
switch (typeof value) {
|
|
1145
1145
|
case 'number':
|
|
1146
1146
|
return 'number';
|
|
@@ -1163,7 +1163,7 @@ const getType = value => {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
};
|
|
1165
1165
|
const number = value => {
|
|
1166
|
-
const type = getType(value);
|
|
1166
|
+
const type = getType$1(value);
|
|
1167
1167
|
if (type !== 'number') {
|
|
1168
1168
|
throw new AssertionError('expected value to be of type number');
|
|
1169
1169
|
}
|
|
@@ -1177,7 +1177,7 @@ const set$5 = (id, fn) => {
|
|
|
1177
1177
|
const get$5 = id => {
|
|
1178
1178
|
return state$1$1.callbacks[id];
|
|
1179
1179
|
};
|
|
1180
|
-
const remove$
|
|
1180
|
+
const remove$2 = id => {
|
|
1181
1181
|
delete state$1$1.callbacks[id];
|
|
1182
1182
|
};
|
|
1183
1183
|
const state$a = {
|
|
@@ -1223,7 +1223,7 @@ const resolve = (id, args) => {
|
|
|
1223
1223
|
return;
|
|
1224
1224
|
}
|
|
1225
1225
|
fn(args);
|
|
1226
|
-
remove$
|
|
1226
|
+
remove$2(id);
|
|
1227
1227
|
};
|
|
1228
1228
|
const create$2$1 = (method, params) => {
|
|
1229
1229
|
const {
|
|
@@ -1372,75 +1372,16 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
1372
1372
|
}
|
|
1373
1373
|
throw new JsonRpcError('unexpected response message');
|
|
1374
1374
|
};
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
return value?.constructor?.name === constructorName;
|
|
1380
|
-
};
|
|
1381
|
-
const isMessagePortMain = value => {
|
|
1382
|
-
return isInstanceOf(value, 'MessagePortMain');
|
|
1383
|
-
};
|
|
1384
|
-
const isOffscreenCanvas = value => {
|
|
1385
|
-
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
1386
|
-
};
|
|
1387
|
-
const isSocket = value => {
|
|
1388
|
-
return isInstanceOf(value, 'Socket');
|
|
1389
|
-
};
|
|
1390
|
-
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
1391
|
-
const isTransferrable = value => {
|
|
1392
|
-
for (const fn of transferrables) {
|
|
1393
|
-
if (fn(value)) {
|
|
1394
|
-
return true;
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
return false;
|
|
1398
|
-
};
|
|
1399
|
-
const walkValue = (value, transferrables) => {
|
|
1400
|
-
if (!value) {
|
|
1401
|
-
return;
|
|
1402
|
-
}
|
|
1403
|
-
if (isTransferrable(value)) {
|
|
1404
|
-
transferrables.push(value);
|
|
1405
|
-
}
|
|
1406
|
-
if (Array.isArray(value)) {
|
|
1407
|
-
for (const item of value) {
|
|
1408
|
-
walkValue(item, transferrables);
|
|
1409
|
-
}
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
if (typeof value === 'object') {
|
|
1413
|
-
for (const property of Object.values(value)) {
|
|
1414
|
-
walkValue(property, transferrables);
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
};
|
|
1418
|
-
const getTransferrables = value => {
|
|
1419
|
-
const transferrables = [];
|
|
1420
|
-
walkValue(value, transferrables);
|
|
1421
|
-
return transferrables;
|
|
1422
|
-
};
|
|
1423
|
-
const isSingleTransferrable = value => {
|
|
1424
|
-
return isSocket(value);
|
|
1425
|
-
};
|
|
1426
|
-
const getTransferrableParams = value => {
|
|
1427
|
-
const transferrables = getTransferrables(value);
|
|
1428
|
-
if (transferrables.length === 0) {
|
|
1429
|
-
return undefined;
|
|
1375
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1376
|
+
const getType = prettyError => {
|
|
1377
|
+
if (prettyError && prettyError.type) {
|
|
1378
|
+
return prettyError.type;
|
|
1430
1379
|
}
|
|
1431
|
-
if (
|
|
1432
|
-
return
|
|
1380
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
1381
|
+
return prettyError.constructor.name;
|
|
1433
1382
|
}
|
|
1434
|
-
return
|
|
1435
|
-
};
|
|
1436
|
-
const create$1$1 = (message, error) => {
|
|
1437
|
-
return {
|
|
1438
|
-
jsonrpc: Two,
|
|
1439
|
-
id: message.id,
|
|
1440
|
-
error
|
|
1441
|
-
};
|
|
1383
|
+
return undefined;
|
|
1442
1384
|
};
|
|
1443
|
-
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1444
1385
|
const getErrorProperty = (error, prettyError) => {
|
|
1445
1386
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
1446
1387
|
return {
|
|
@@ -1455,18 +1396,26 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1455
1396
|
data: {
|
|
1456
1397
|
stack: prettyError.stack,
|
|
1457
1398
|
codeFrame: prettyError.codeFrame,
|
|
1458
|
-
type: prettyError
|
|
1459
|
-
code: prettyError.code
|
|
1399
|
+
type: getType(prettyError),
|
|
1400
|
+
code: prettyError.code,
|
|
1401
|
+
name: prettyError.name
|
|
1460
1402
|
}
|
|
1461
1403
|
};
|
|
1462
1404
|
};
|
|
1405
|
+
const create$1$1 = (message, error) => {
|
|
1406
|
+
return {
|
|
1407
|
+
jsonrpc: Two,
|
|
1408
|
+
id: message.id,
|
|
1409
|
+
error
|
|
1410
|
+
};
|
|
1411
|
+
};
|
|
1463
1412
|
const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
1464
1413
|
const prettyError = preparePrettyError(error);
|
|
1465
1414
|
logError(error, prettyError);
|
|
1466
1415
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1467
1416
|
return create$1$1(message, errorProperty);
|
|
1468
1417
|
};
|
|
1469
|
-
const create$
|
|
1418
|
+
const create$8 = (message, result) => {
|
|
1470
1419
|
return {
|
|
1471
1420
|
jsonrpc: Two,
|
|
1472
1421
|
id: message.id,
|
|
@@ -1475,7 +1424,7 @@ const create$5 = (message, result) => {
|
|
|
1475
1424
|
};
|
|
1476
1425
|
const getSuccessResponse = (message, result) => {
|
|
1477
1426
|
const resultProperty = result ?? null;
|
|
1478
|
-
return create$
|
|
1427
|
+
return create$8(message, resultProperty);
|
|
1479
1428
|
};
|
|
1480
1429
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1481
1430
|
try {
|
|
@@ -1551,21 +1500,12 @@ const invoke$5 = async (ipc, method, ...params) => {
|
|
|
1551
1500
|
const result = unwrapJsonRpcResult(responseMessage);
|
|
1552
1501
|
return result;
|
|
1553
1502
|
};
|
|
1554
|
-
|
|
1555
|
-
// TODO deprecated old typings,
|
|
1556
|
-
// always use automatic transferrable detection
|
|
1557
|
-
const invokeAndTransfer$2 = async (ipc, handle, method, ...params) => {
|
|
1558
|
-
let transfer = handle;
|
|
1559
|
-
if (typeof handle === 'string') {
|
|
1560
|
-
params = [method, ...params];
|
|
1561
|
-
method = handle;
|
|
1562
|
-
transfer = getTransferrableParams(params);
|
|
1563
|
-
}
|
|
1503
|
+
const invokeAndTransfer$2 = async (ipc, method, ...params) => {
|
|
1564
1504
|
const {
|
|
1565
1505
|
message,
|
|
1566
1506
|
promise
|
|
1567
1507
|
} = create$2$1(method, params);
|
|
1568
|
-
ipc.sendAndTransfer(message
|
|
1508
|
+
ipc.sendAndTransfer(message);
|
|
1569
1509
|
const responseMessage = await promise;
|
|
1570
1510
|
const result = unwrapJsonRpcResult(responseMessage);
|
|
1571
1511
|
return result;
|
|
@@ -1716,7 +1656,7 @@ const waitForFirstMessage$1 = async port => {
|
|
|
1716
1656
|
return event;
|
|
1717
1657
|
};
|
|
1718
1658
|
|
|
1719
|
-
const create$
|
|
1659
|
+
const create$7 = async () => {
|
|
1720
1660
|
const {
|
|
1721
1661
|
port1,
|
|
1722
1662
|
port2
|
|
@@ -1761,7 +1701,7 @@ const wrap$3 = port => {
|
|
|
1761
1701
|
|
|
1762
1702
|
const IpcParentWithExtensionHostWorker = {
|
|
1763
1703
|
__proto__: null,
|
|
1764
|
-
create: create$
|
|
1704
|
+
create: create$7,
|
|
1765
1705
|
wrap: wrap$3
|
|
1766
1706
|
};
|
|
1767
1707
|
|
|
@@ -1769,7 +1709,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
|
1769
1709
|
await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
1770
1710
|
};
|
|
1771
1711
|
|
|
1772
|
-
const create$
|
|
1712
|
+
const create$6 = async () => {
|
|
1773
1713
|
const {
|
|
1774
1714
|
port1,
|
|
1775
1715
|
port2
|
|
@@ -1814,7 +1754,7 @@ const wrap$1 = port => {
|
|
|
1814
1754
|
|
|
1815
1755
|
const IpcParentWithSyntaxHighlightingWorker = {
|
|
1816
1756
|
__proto__: null,
|
|
1817
|
-
create: create$
|
|
1757
|
+
create: create$6,
|
|
1818
1758
|
wrap: wrap$1
|
|
1819
1759
|
};
|
|
1820
1760
|
|
|
@@ -1822,7 +1762,7 @@ const sendMessagePortToRendererProcess = async port => {
|
|
|
1822
1762
|
await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
|
|
1823
1763
|
};
|
|
1824
1764
|
|
|
1825
|
-
const create$
|
|
1765
|
+
const create$5 = async () => {
|
|
1826
1766
|
const {
|
|
1827
1767
|
port1,
|
|
1828
1768
|
port2
|
|
@@ -1867,7 +1807,7 @@ const wrap = port => {
|
|
|
1867
1807
|
|
|
1868
1808
|
const IpcParentWithRendererProcess = {
|
|
1869
1809
|
__proto__: null,
|
|
1870
|
-
create: create$
|
|
1810
|
+
create: create$5,
|
|
1871
1811
|
wrap
|
|
1872
1812
|
};
|
|
1873
1813
|
|
|
@@ -1884,7 +1824,7 @@ const getModule$1 = method => {
|
|
|
1884
1824
|
}
|
|
1885
1825
|
};
|
|
1886
1826
|
|
|
1887
|
-
const create$
|
|
1827
|
+
const create$4 = async ({
|
|
1888
1828
|
method,
|
|
1889
1829
|
...options
|
|
1890
1830
|
}) => {
|
|
@@ -1902,7 +1842,7 @@ const create$1 = async ({
|
|
|
1902
1842
|
const createRpc = method => {
|
|
1903
1843
|
let _ipc;
|
|
1904
1844
|
const listen = async () => {
|
|
1905
|
-
const ipc = await create$
|
|
1845
|
+
const ipc = await create$4({
|
|
1906
1846
|
method
|
|
1907
1847
|
});
|
|
1908
1848
|
handleIpc(ipc);
|
|
@@ -2179,7 +2119,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
|
|
|
2179
2119
|
const supported = () => {
|
|
2180
2120
|
return 'Segmenter' in Intl;
|
|
2181
2121
|
};
|
|
2182
|
-
const create = () => {
|
|
2122
|
+
const create$3 = () => {
|
|
2183
2123
|
// @ts-ignore
|
|
2184
2124
|
const segmenter = new Intl.Segmenter();
|
|
2185
2125
|
return {
|
|
@@ -2217,7 +2157,7 @@ const create = () => {
|
|
|
2217
2157
|
|
|
2218
2158
|
// @ts-ignore
|
|
2219
2159
|
const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
2220
|
-
const segmenter = create();
|
|
2160
|
+
const segmenter = create$3();
|
|
2221
2161
|
const segments = segmenter.getSegments(line);
|
|
2222
2162
|
const isMonospaceFont = false;
|
|
2223
2163
|
const charWidth = 0;
|
|
@@ -2446,7 +2386,9 @@ const cancelSelection = editor => {
|
|
|
2446
2386
|
return scheduleSelections(editor, newSelections);
|
|
2447
2387
|
};
|
|
2448
2388
|
|
|
2389
|
+
// TODO use numeric widget id
|
|
2449
2390
|
const Completion = 'completion';
|
|
2391
|
+
const CompletionDetail = 'completionDetail';
|
|
2450
2392
|
|
|
2451
2393
|
const isCompletionWidget = widget => {
|
|
2452
2394
|
return widget.id === Completion;
|
|
@@ -2760,7 +2702,7 @@ const characterLeft = (line, columnIndex) => {
|
|
|
2760
2702
|
if (!supported()) {
|
|
2761
2703
|
return 1;
|
|
2762
2704
|
}
|
|
2763
|
-
const segmenter = create();
|
|
2705
|
+
const segmenter = create$3();
|
|
2764
2706
|
const last = segmenter.at(line, columnIndex - 1);
|
|
2765
2707
|
return columnIndex - last.index;
|
|
2766
2708
|
};
|
|
@@ -2771,7 +2713,7 @@ const characterRight = (line, columnIndex) => {
|
|
|
2771
2713
|
if (!supported()) {
|
|
2772
2714
|
return 1;
|
|
2773
2715
|
}
|
|
2774
|
-
const segmenter = create();
|
|
2716
|
+
const segmenter = create$3();
|
|
2775
2717
|
const next = segmenter.at(line, columnIndex);
|
|
2776
2718
|
return next.segment.length;
|
|
2777
2719
|
};
|
|
@@ -3417,7 +3359,7 @@ const goTo = async ({
|
|
|
3417
3359
|
endRowIndex: definition.endRowIndex,
|
|
3418
3360
|
endColumnIndex: definition.endColumnIndex
|
|
3419
3361
|
};
|
|
3420
|
-
await invoke$3(
|
|
3362
|
+
await invoke$3(/* Main.openUri */'Main.openUri', /* uri */uri, /* focus */true, context);
|
|
3421
3363
|
return editor;
|
|
3422
3364
|
} catch (error) {
|
|
3423
3365
|
// TODO if editor is already disposed at this point, do nothing
|
|
@@ -3542,7 +3484,7 @@ const goToTypeDefinition = (editor, explicit = true) => {
|
|
|
3542
3484
|
const Editor = 3;
|
|
3543
3485
|
|
|
3544
3486
|
const handleContextMenu = async (editor, button, x, y) => {
|
|
3545
|
-
await invoke$3(
|
|
3487
|
+
await invoke$3(/* ContextMenu.show */'ContextMenu.show', /* x */x, /* y */y, /* id */Editor);
|
|
3546
3488
|
return editor;
|
|
3547
3489
|
};
|
|
3548
3490
|
|
|
@@ -4528,6 +4470,44 @@ const moveSelectionPx = (editor, x, y) => {
|
|
|
4528
4470
|
return editorMoveSelection(editor, position);
|
|
4529
4471
|
};
|
|
4530
4472
|
|
|
4473
|
+
const create$2 = () => {
|
|
4474
|
+
return Math.random();
|
|
4475
|
+
};
|
|
4476
|
+
|
|
4477
|
+
const create$1 = () => {
|
|
4478
|
+
const completionUid = create$2();
|
|
4479
|
+
const completionWidget = {
|
|
4480
|
+
id: Completion,
|
|
4481
|
+
oldState: {
|
|
4482
|
+
items: [],
|
|
4483
|
+
itemHeight: 20,
|
|
4484
|
+
maxHeight: 150,
|
|
4485
|
+
minLineY: 0,
|
|
4486
|
+
maxLineY: 0,
|
|
4487
|
+
uid: completionUid,
|
|
4488
|
+
focusedIndex: -1,
|
|
4489
|
+
x: 0,
|
|
4490
|
+
y: 0,
|
|
4491
|
+
width: 0,
|
|
4492
|
+
height: 0
|
|
4493
|
+
},
|
|
4494
|
+
newState: {
|
|
4495
|
+
items: [],
|
|
4496
|
+
itemHeight: 20,
|
|
4497
|
+
maxHeight: 150,
|
|
4498
|
+
minLineY: 0,
|
|
4499
|
+
maxLineY: 10,
|
|
4500
|
+
uid: completionUid,
|
|
4501
|
+
focusedIndex: -1,
|
|
4502
|
+
x: 0,
|
|
4503
|
+
y: 0,
|
|
4504
|
+
width: 0,
|
|
4505
|
+
height: 0
|
|
4506
|
+
}
|
|
4507
|
+
};
|
|
4508
|
+
return completionWidget;
|
|
4509
|
+
};
|
|
4510
|
+
|
|
4531
4511
|
const OnCompletion = 'onCompletion';
|
|
4532
4512
|
const OnHover = 'onHover';
|
|
4533
4513
|
|
|
@@ -4985,26 +4965,7 @@ const openCompletion = async editor => {
|
|
|
4985
4965
|
if (hasWidget(widgets, Completion)) {
|
|
4986
4966
|
return editor;
|
|
4987
4967
|
}
|
|
4988
|
-
const
|
|
4989
|
-
const completionWidget = {
|
|
4990
|
-
id: Completion,
|
|
4991
|
-
oldState: {
|
|
4992
|
-
items: [],
|
|
4993
|
-
itemHeight: 20,
|
|
4994
|
-
maxHeight: 150,
|
|
4995
|
-
minLineY: 0,
|
|
4996
|
-
maxLineY: 0,
|
|
4997
|
-
uid: completionUid
|
|
4998
|
-
},
|
|
4999
|
-
newState: {
|
|
5000
|
-
items: [],
|
|
5001
|
-
itemHeight: 20,
|
|
5002
|
-
maxHeight: 150,
|
|
5003
|
-
minLineY: 0,
|
|
5004
|
-
maxLineY: 10,
|
|
5005
|
-
uid: completionUid
|
|
5006
|
-
}
|
|
5007
|
-
};
|
|
4968
|
+
const completionWidget = create$1();
|
|
5008
4969
|
const newWidgets = [...widgets, completionWidget];
|
|
5009
4970
|
const newEditor = {
|
|
5010
4971
|
...editor,
|
|
@@ -6412,7 +6373,7 @@ const toggleComment = async editor => {
|
|
|
6412
6373
|
} catch (error$1) {
|
|
6413
6374
|
error(error$1);
|
|
6414
6375
|
// TODO use correct position
|
|
6415
|
-
await editorShowMessage(
|
|
6376
|
+
await editorShowMessage(/* editor */editor, /* rowIndex */0, /* columnIndex */0, /* message */`${error$1}`, /* isError */true);
|
|
6416
6377
|
return editor;
|
|
6417
6378
|
}
|
|
6418
6379
|
};
|
|
@@ -6715,15 +6676,32 @@ const editorUnindent = editor => {
|
|
|
6715
6676
|
|
|
6716
6677
|
// editor.lines //?
|
|
6717
6678
|
|
|
6718
|
-
const
|
|
6719
|
-
return widget.id === Completion;
|
|
6720
|
-
};
|
|
6721
|
-
const getCompletionState = editor => {
|
|
6679
|
+
const getWidgetState = (editor, id) => {
|
|
6722
6680
|
const {
|
|
6723
6681
|
widgets
|
|
6724
6682
|
} = editor;
|
|
6725
|
-
const
|
|
6726
|
-
|
|
6683
|
+
for (const widget of widgets) {
|
|
6684
|
+
if (widget.id === id) {
|
|
6685
|
+
return widget.newState;
|
|
6686
|
+
}
|
|
6687
|
+
}
|
|
6688
|
+
return undefined;
|
|
6689
|
+
};
|
|
6690
|
+
|
|
6691
|
+
const getCompletionState = editor => {
|
|
6692
|
+
return getWidgetState(editor, Completion);
|
|
6693
|
+
};
|
|
6694
|
+
|
|
6695
|
+
const closeDetails = editor => {
|
|
6696
|
+
const child = getCompletionState(editor);
|
|
6697
|
+
if (!child) {
|
|
6698
|
+
return editor;
|
|
6699
|
+
}
|
|
6700
|
+
console.log('open details');
|
|
6701
|
+
// TODO when completion details are open, close them
|
|
6702
|
+
// TODO when completion details are opening, close them
|
|
6703
|
+
// TODO when completion details are closed, open them
|
|
6704
|
+
return editor;
|
|
6727
6705
|
};
|
|
6728
6706
|
|
|
6729
6707
|
const isCompletion$1 = widget => {
|
|
@@ -6759,16 +6737,81 @@ const focusFirst$1 = editor => {
|
|
|
6759
6737
|
|
|
6760
6738
|
const focusNext$1 = editor => {
|
|
6761
6739
|
const child = getCompletionState(editor);
|
|
6740
|
+
if (!child) {
|
|
6741
|
+
return editor;
|
|
6742
|
+
}
|
|
6762
6743
|
const nextIndex = child.focusedIndex + 1;
|
|
6763
6744
|
return focusIndex$1(editor, nextIndex);
|
|
6764
6745
|
};
|
|
6765
6746
|
|
|
6766
6747
|
const focusPrevious$1 = editor => {
|
|
6767
6748
|
const child = getCompletionState(editor);
|
|
6749
|
+
if (!child) {
|
|
6750
|
+
return editor;
|
|
6751
|
+
}
|
|
6768
6752
|
const previousIndex = child.focusedIndex - 1;
|
|
6769
6753
|
return focusIndex$1(editor, previousIndex);
|
|
6770
6754
|
};
|
|
6771
6755
|
|
|
6756
|
+
const create = () => {
|
|
6757
|
+
const completionUid = create$2();
|
|
6758
|
+
const completionWidget = {
|
|
6759
|
+
id: CompletionDetail,
|
|
6760
|
+
oldState: {
|
|
6761
|
+
content: '',
|
|
6762
|
+
uid: completionUid,
|
|
6763
|
+
x: 0,
|
|
6764
|
+
y: 0,
|
|
6765
|
+
width: 0,
|
|
6766
|
+
height: 0
|
|
6767
|
+
},
|
|
6768
|
+
newState: {
|
|
6769
|
+
content: '',
|
|
6770
|
+
uid: completionUid,
|
|
6771
|
+
x: 0,
|
|
6772
|
+
y: 0,
|
|
6773
|
+
width: 0,
|
|
6774
|
+
height: 0
|
|
6775
|
+
}
|
|
6776
|
+
};
|
|
6777
|
+
return completionWidget;
|
|
6778
|
+
};
|
|
6779
|
+
|
|
6780
|
+
const getCompletionDetailState = editor => {
|
|
6781
|
+
return getWidgetState(editor, CompletionDetail);
|
|
6782
|
+
};
|
|
6783
|
+
|
|
6784
|
+
const openDetails = editor => {
|
|
6785
|
+
const child = getCompletionState(editor);
|
|
6786
|
+
if (!child) {
|
|
6787
|
+
return editor;
|
|
6788
|
+
}
|
|
6789
|
+
const detailState = getCompletionDetailState(editor);
|
|
6790
|
+
if (detailState) {
|
|
6791
|
+
return editor;
|
|
6792
|
+
}
|
|
6793
|
+
const widget = create();
|
|
6794
|
+
console.log({
|
|
6795
|
+
child
|
|
6796
|
+
});
|
|
6797
|
+
const newestState = {
|
|
6798
|
+
...widget.newState,
|
|
6799
|
+
content: 'abc',
|
|
6800
|
+
x: child.x + child.width,
|
|
6801
|
+
y: child.y,
|
|
6802
|
+
width: 100,
|
|
6803
|
+
height: 100
|
|
6804
|
+
};
|
|
6805
|
+
const latestWidgets = [...editor.widgets, {
|
|
6806
|
+
...widget,
|
|
6807
|
+
newState: newestState
|
|
6808
|
+
}];
|
|
6809
|
+
return {
|
|
6810
|
+
...editor,
|
|
6811
|
+
widgets: latestWidgets
|
|
6812
|
+
};
|
|
6813
|
+
};
|
|
6814
|
+
|
|
6772
6815
|
const getEdits = async (editor, completionItem) => {
|
|
6773
6816
|
const child = getCompletionState(editor);
|
|
6774
6817
|
// @ts-ignore
|
|
@@ -6818,6 +6861,9 @@ const select = async (editor, completionItem) => {
|
|
|
6818
6861
|
};
|
|
6819
6862
|
const selectIndex = (editor, index) => {
|
|
6820
6863
|
const child = getCompletionState(editor);
|
|
6864
|
+
if (!child) {
|
|
6865
|
+
return editor;
|
|
6866
|
+
}
|
|
6821
6867
|
const {
|
|
6822
6868
|
items
|
|
6823
6869
|
} = child;
|
|
@@ -6834,12 +6880,26 @@ const selectIndex = (editor, index) => {
|
|
|
6834
6880
|
|
|
6835
6881
|
const selectCurrent = editor => {
|
|
6836
6882
|
const child = getCompletionState(editor);
|
|
6883
|
+
if (!child) {
|
|
6884
|
+
return editor;
|
|
6885
|
+
}
|
|
6837
6886
|
const {
|
|
6838
6887
|
focusedIndex
|
|
6839
6888
|
} = child;
|
|
6840
6889
|
return selectIndex(editor, focusedIndex);
|
|
6841
6890
|
};
|
|
6842
6891
|
|
|
6892
|
+
const toggleDetails = editor => {
|
|
6893
|
+
const child = getCompletionState(editor);
|
|
6894
|
+
if (!child) {
|
|
6895
|
+
return editor;
|
|
6896
|
+
}
|
|
6897
|
+
// TODO when completion details are open, close them
|
|
6898
|
+
// TODO when completion details are opening, close them
|
|
6899
|
+
// TODO when completion details are closed, open them
|
|
6900
|
+
return editor;
|
|
6901
|
+
};
|
|
6902
|
+
|
|
6843
6903
|
const executeHoverProvider = (editor, offset) => {
|
|
6844
6904
|
object(editor);
|
|
6845
6905
|
number$1(offset);
|
|
@@ -6862,7 +6922,7 @@ const getHover = async (editor, offset) => {
|
|
|
6862
6922
|
|
|
6863
6923
|
let _ipc;
|
|
6864
6924
|
const listen$5 = async () => {
|
|
6865
|
-
const ipc = await create$
|
|
6925
|
+
const ipc = await create$4({
|
|
6866
6926
|
method: RendererProcess
|
|
6867
6927
|
});
|
|
6868
6928
|
handleIpc(ipc);
|
|
@@ -7186,7 +7246,7 @@ const renderHoverDom = {
|
|
|
7186
7246
|
return [/* method */'Viewlet.setDom2', dom];
|
|
7187
7247
|
}
|
|
7188
7248
|
};
|
|
7189
|
-
const renderBounds$
|
|
7249
|
+
const renderBounds$2 = {
|
|
7190
7250
|
isEqual(oldState, newState) {
|
|
7191
7251
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.resizedWidth === newState.resizedWidth;
|
|
7192
7252
|
},
|
|
@@ -7204,10 +7264,10 @@ const renderBounds$1 = {
|
|
|
7204
7264
|
return [SetBounds, x, y, resizedWidth, height];
|
|
7205
7265
|
}
|
|
7206
7266
|
};
|
|
7207
|
-
const render$
|
|
7267
|
+
const render$5 = [renderHoverDom, renderBounds$2];
|
|
7208
7268
|
const renderHover = async (oldState, newState) => {
|
|
7209
7269
|
const commands = [];
|
|
7210
|
-
for (const item of render$
|
|
7270
|
+
for (const item of render$5) {
|
|
7211
7271
|
if (!item.isEqual(oldState, newState)) {
|
|
7212
7272
|
commands.push(item.apply(oldState, newState));
|
|
7213
7273
|
}
|
|
@@ -8325,7 +8385,7 @@ const renderItems = {
|
|
|
8325
8385
|
return ['setDom', dom];
|
|
8326
8386
|
}
|
|
8327
8387
|
};
|
|
8328
|
-
const renderBounds = {
|
|
8388
|
+
const renderBounds$1 = {
|
|
8329
8389
|
isEqual(oldState, newState) {
|
|
8330
8390
|
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
|
|
8331
8391
|
},
|
|
@@ -8371,10 +8431,10 @@ const renderScrollBar = {
|
|
|
8371
8431
|
return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
|
|
8372
8432
|
}
|
|
8373
8433
|
};
|
|
8374
|
-
const render$
|
|
8434
|
+
const render$4 = [renderItems, renderBounds$1, renderHeight, renderNegativeMargin, renderScrollBar];
|
|
8375
8435
|
const renderCompletion = (oldState, newState) => {
|
|
8376
8436
|
const commands = [];
|
|
8377
|
-
for (const item of render$
|
|
8437
|
+
for (const item of render$4) {
|
|
8378
8438
|
if (!item.isEqual(oldState, newState)) {
|
|
8379
8439
|
commands.push(item.apply(oldState, newState));
|
|
8380
8440
|
}
|
|
@@ -8382,7 +8442,7 @@ const renderCompletion = (oldState, newState) => {
|
|
|
8382
8442
|
return commands;
|
|
8383
8443
|
};
|
|
8384
8444
|
|
|
8385
|
-
const render$
|
|
8445
|
+
const render$3 = (oldState, newState) => {
|
|
8386
8446
|
const commands = renderCompletion(oldState, newState);
|
|
8387
8447
|
const wrappedCommands = [];
|
|
8388
8448
|
const uid = newState.uid;
|
|
@@ -8391,8 +8451,8 @@ const render$1 = (oldState, newState) => {
|
|
|
8391
8451
|
}
|
|
8392
8452
|
return wrappedCommands;
|
|
8393
8453
|
};
|
|
8394
|
-
const add = widget => {
|
|
8395
|
-
const commands = render$
|
|
8454
|
+
const add$1 = widget => {
|
|
8455
|
+
const commands = render$3(widget.oldState, widget.newState);
|
|
8396
8456
|
const id = 'EditorCompletion';
|
|
8397
8457
|
// TODO how to generate a unique integer id
|
|
8398
8458
|
// that doesn't collide with ids created in renderer worker?
|
|
@@ -8402,7 +8462,7 @@ const add = widget => {
|
|
|
8402
8462
|
allCommands.push(...commands);
|
|
8403
8463
|
return allCommands;
|
|
8404
8464
|
};
|
|
8405
|
-
const remove = widget => {
|
|
8465
|
+
const remove$1 = widget => {
|
|
8406
8466
|
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
8407
8467
|
};
|
|
8408
8468
|
const handleEditorType = (editor, state) => {
|
|
@@ -8469,11 +8529,85 @@ const handleEditorDeleteLeft = (editor, state) => {
|
|
|
8469
8529
|
|
|
8470
8530
|
const EditorCompletionWidget = {
|
|
8471
8531
|
__proto__: null,
|
|
8472
|
-
add,
|
|
8532
|
+
add: add$1,
|
|
8473
8533
|
handleEditorDeleteLeft,
|
|
8474
8534
|
handleEditorType,
|
|
8475
|
-
remove,
|
|
8476
|
-
render: render$
|
|
8535
|
+
remove: remove$1,
|
|
8536
|
+
render: render$3
|
|
8537
|
+
};
|
|
8538
|
+
|
|
8539
|
+
const getCompletionDetailVirtualDom = content => {
|
|
8540
|
+
const dom = [{
|
|
8541
|
+
type: Div,
|
|
8542
|
+
childCount: 2
|
|
8543
|
+
}, {
|
|
8544
|
+
type: Div,
|
|
8545
|
+
className: 'CompletionDetailContent',
|
|
8546
|
+
childCount: 1
|
|
8547
|
+
}, text(content), {
|
|
8548
|
+
type: Div,
|
|
8549
|
+
className: 'CompletionDetailCloseButton',
|
|
8550
|
+
childCount: 0
|
|
8551
|
+
}];
|
|
8552
|
+
return dom;
|
|
8553
|
+
};
|
|
8554
|
+
|
|
8555
|
+
const renderContent = {
|
|
8556
|
+
isEqual(oldState, newState) {
|
|
8557
|
+
return oldState.content === newState.content;
|
|
8558
|
+
},
|
|
8559
|
+
apply(oldState, newState) {
|
|
8560
|
+
const dom = getCompletionDetailVirtualDom(newState.content);
|
|
8561
|
+
return ['setDom', dom];
|
|
8562
|
+
}
|
|
8563
|
+
};
|
|
8564
|
+
const renderBounds = {
|
|
8565
|
+
isEqual(oldState, newState) {
|
|
8566
|
+
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
8567
|
+
},
|
|
8568
|
+
apply(oldState, newState) {
|
|
8569
|
+
const {
|
|
8570
|
+
x,
|
|
8571
|
+
y,
|
|
8572
|
+
width,
|
|
8573
|
+
height
|
|
8574
|
+
} = newState;
|
|
8575
|
+
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
8576
|
+
}
|
|
8577
|
+
};
|
|
8578
|
+
const render$2 = [renderContent, renderBounds];
|
|
8579
|
+
const renderFull = (oldState, newState) => {
|
|
8580
|
+
const commands = [];
|
|
8581
|
+
for (const item of render$2) {
|
|
8582
|
+
if (!item.isEqual(oldState, newState)) {
|
|
8583
|
+
commands.push(item.apply(oldState, newState));
|
|
8584
|
+
}
|
|
8585
|
+
}
|
|
8586
|
+
return commands;
|
|
8587
|
+
};
|
|
8588
|
+
|
|
8589
|
+
const render$1 = (oldState, newState) => {
|
|
8590
|
+
const commands = renderFull(oldState, newState);
|
|
8591
|
+
const wrappedCommands = [];
|
|
8592
|
+
const uid = newState.uid;
|
|
8593
|
+
for (const command of commands) {
|
|
8594
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
8595
|
+
}
|
|
8596
|
+
return wrappedCommands;
|
|
8597
|
+
};
|
|
8598
|
+
const add = widget => {
|
|
8599
|
+
const commands = render$1(widget.oldState, widget.newState);
|
|
8600
|
+
const id = 'EditorCompletionDetails';
|
|
8601
|
+
// TODO how to generate a unique integer id
|
|
8602
|
+
// that doesn't collide with ids created in renderer worker?
|
|
8603
|
+
const uid = widget.newState.uid;
|
|
8604
|
+
const allCommands = [];
|
|
8605
|
+
allCommands.push(['Viewlet.create', id, uid]);
|
|
8606
|
+
allCommands.push(...commands);
|
|
8607
|
+
return allCommands;
|
|
8608
|
+
};
|
|
8609
|
+
const remove = widget => {
|
|
8610
|
+
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
8477
8611
|
};
|
|
8478
8612
|
|
|
8479
8613
|
const addWidget = widget => {
|
|
@@ -8482,6 +8616,8 @@ const addWidget = widget => {
|
|
|
8482
8616
|
} = widget;
|
|
8483
8617
|
switch (id) {
|
|
8484
8618
|
case Completion:
|
|
8619
|
+
return add$1(widget);
|
|
8620
|
+
case CompletionDetail:
|
|
8485
8621
|
return add(widget);
|
|
8486
8622
|
default:
|
|
8487
8623
|
throw new Error('unsupported widget');
|
|
@@ -8493,6 +8629,8 @@ const renderWidget = widget => {
|
|
|
8493
8629
|
} = widget;
|
|
8494
8630
|
switch (id) {
|
|
8495
8631
|
case Completion:
|
|
8632
|
+
return render$3(widget.oldState, widget.newState);
|
|
8633
|
+
case CompletionDetail:
|
|
8496
8634
|
return render$1(widget.oldState, widget.newState);
|
|
8497
8635
|
default:
|
|
8498
8636
|
throw new Error(`unsupported widget`);
|
|
@@ -8504,6 +8642,8 @@ const removeWidget = widget => {
|
|
|
8504
8642
|
} = widget;
|
|
8505
8643
|
switch (id) {
|
|
8506
8644
|
case Completion:
|
|
8645
|
+
return remove$1(widget);
|
|
8646
|
+
case CompletionDetail:
|
|
8507
8647
|
return remove(widget);
|
|
8508
8648
|
default:
|
|
8509
8649
|
throw new Error('unsupported widget');
|
|
@@ -8846,6 +8986,7 @@ const commandMap = {
|
|
|
8846
8986
|
'Editor.undo': undo,
|
|
8847
8987
|
'Editor.unIndent': editorUnindent,
|
|
8848
8988
|
'EditorCompletion.advance': advance,
|
|
8989
|
+
'EditorCompletion.closeDetails': closeDetails,
|
|
8849
8990
|
'EditorCompletion.focusFirst': focusFirst$1,
|
|
8850
8991
|
'EditorCompletion.focusIndex': focusIndex$1,
|
|
8851
8992
|
'EditorCompletion.focusNext': focusNext$1,
|
|
@@ -8855,8 +8996,10 @@ const commandMap = {
|
|
|
8855
8996
|
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
|
|
8856
8997
|
'EditorCompletion.handleEditorType': handleEditorType$1,
|
|
8857
8998
|
'EditorCompletion.loadContent': loadContent$2,
|
|
8999
|
+
'EditorCompletion.openDetails': openDetails,
|
|
8858
9000
|
'EditorCompletion.selectCurrent': selectCurrent,
|
|
8859
9001
|
'EditorCompletion.selectIndex': selectIndex,
|
|
9002
|
+
'EditorCompletion.toggleDetails': toggleDetails,
|
|
8860
9003
|
'FindWidget.focusFirst': focusFirst,
|
|
8861
9004
|
'FindWidget.focusIndex': focusIndex,
|
|
8862
9005
|
'FindWidget.focusLast': focusLast,
|
|
@@ -8894,6 +9037,56 @@ const Auto = () => {
|
|
|
8894
9037
|
const getData$1 = event => {
|
|
8895
9038
|
return event.data;
|
|
8896
9039
|
};
|
|
9040
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
9041
|
+
if (!value) {
|
|
9042
|
+
return;
|
|
9043
|
+
}
|
|
9044
|
+
if (isTransferrable(value)) {
|
|
9045
|
+
transferrables.push(value);
|
|
9046
|
+
return;
|
|
9047
|
+
}
|
|
9048
|
+
if (Array.isArray(value)) {
|
|
9049
|
+
for (const item of value) {
|
|
9050
|
+
walkValue(item, transferrables, isTransferrable);
|
|
9051
|
+
}
|
|
9052
|
+
return;
|
|
9053
|
+
}
|
|
9054
|
+
if (typeof value === 'object') {
|
|
9055
|
+
for (const property of Object.values(value)) {
|
|
9056
|
+
walkValue(property, transferrables, isTransferrable);
|
|
9057
|
+
}
|
|
9058
|
+
return;
|
|
9059
|
+
}
|
|
9060
|
+
};
|
|
9061
|
+
const isMessagePort = value => {
|
|
9062
|
+
return value && value instanceof MessagePort;
|
|
9063
|
+
};
|
|
9064
|
+
const isMessagePortMain = value => {
|
|
9065
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
9066
|
+
};
|
|
9067
|
+
const isOffscreenCanvas = value => {
|
|
9068
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
9069
|
+
};
|
|
9070
|
+
const isInstanceOf = (value, constructorName) => {
|
|
9071
|
+
return value?.constructor?.name === constructorName;
|
|
9072
|
+
};
|
|
9073
|
+
const isSocket = value => {
|
|
9074
|
+
return isInstanceOf(value, 'Socket');
|
|
9075
|
+
};
|
|
9076
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
9077
|
+
const isTransferrable = value => {
|
|
9078
|
+
for (const fn of transferrables) {
|
|
9079
|
+
if (fn(value)) {
|
|
9080
|
+
return true;
|
|
9081
|
+
}
|
|
9082
|
+
}
|
|
9083
|
+
return false;
|
|
9084
|
+
};
|
|
9085
|
+
const getTransferrables = value => {
|
|
9086
|
+
const transferrables = [];
|
|
9087
|
+
walkValue(value, transferrables, isTransferrable);
|
|
9088
|
+
return transferrables;
|
|
9089
|
+
};
|
|
8897
9090
|
const attachEvents = that => {
|
|
8898
9091
|
const handleMessage = (...args) => {
|
|
8899
9092
|
const data = that.getData(...args);
|
|
@@ -8915,14 +9108,14 @@ class Ipc extends EventTarget {
|
|
|
8915
9108
|
}
|
|
8916
9109
|
}
|
|
8917
9110
|
const readyMessage = 'ready';
|
|
8918
|
-
const listen$
|
|
9111
|
+
const listen$4 = () => {
|
|
8919
9112
|
// @ts-ignore
|
|
8920
9113
|
if (typeof WorkerGlobalScope === 'undefined') {
|
|
8921
9114
|
throw new TypeError('module is not in web worker scope');
|
|
8922
9115
|
}
|
|
8923
9116
|
return globalThis;
|
|
8924
9117
|
};
|
|
8925
|
-
const signal$
|
|
9118
|
+
const signal$3 = global => {
|
|
8926
9119
|
global.postMessage(readyMessage);
|
|
8927
9120
|
};
|
|
8928
9121
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -8933,7 +9126,8 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
8933
9126
|
// @ts-ignore
|
|
8934
9127
|
this._rawIpc.postMessage(message);
|
|
8935
9128
|
}
|
|
8936
|
-
sendAndTransfer(message
|
|
9129
|
+
sendAndTransfer(message) {
|
|
9130
|
+
const transfer = getTransferrables(message);
|
|
8937
9131
|
// @ts-ignore
|
|
8938
9132
|
this._rawIpc.postMessage(message, transfer);
|
|
8939
9133
|
}
|
|
@@ -8947,14 +9141,14 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
8947
9141
|
this._rawIpc.addEventListener('message', callback);
|
|
8948
9142
|
}
|
|
8949
9143
|
}
|
|
8950
|
-
const wrap$
|
|
9144
|
+
const wrap$6 = global => {
|
|
8951
9145
|
return new IpcChildWithModuleWorker(global);
|
|
8952
9146
|
};
|
|
8953
9147
|
const IpcChildWithModuleWorker$1 = {
|
|
8954
9148
|
__proto__: null,
|
|
8955
|
-
listen: listen$
|
|
8956
|
-
signal: signal$
|
|
8957
|
-
wrap: wrap$
|
|
9149
|
+
listen: listen$4,
|
|
9150
|
+
signal: signal$3,
|
|
9151
|
+
wrap: wrap$6
|
|
8958
9152
|
};
|
|
8959
9153
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
8960
9154
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
@@ -8966,6 +9160,18 @@ const joinLines = lines => {
|
|
|
8966
9160
|
const splitLines = lines => {
|
|
8967
9161
|
return lines.split(NewLine$1);
|
|
8968
9162
|
};
|
|
9163
|
+
const isModuleNotFoundMessage = line => {
|
|
9164
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
9165
|
+
};
|
|
9166
|
+
const getModuleNotFoundError = stderr => {
|
|
9167
|
+
const lines = splitLines(stderr);
|
|
9168
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
9169
|
+
const message = lines[messageIndex];
|
|
9170
|
+
return {
|
|
9171
|
+
message,
|
|
9172
|
+
code: ERR_MODULE_NOT_FOUND
|
|
9173
|
+
};
|
|
9174
|
+
};
|
|
8969
9175
|
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
8970
9176
|
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
8971
9177
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
@@ -9014,18 +9220,6 @@ const isModuleNotFoundError = stderr => {
|
|
|
9014
9220
|
}
|
|
9015
9221
|
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
9016
9222
|
};
|
|
9017
|
-
const isModuleNotFoundMessage = line => {
|
|
9018
|
-
return line.includes('ERR_MODULE_NOT_FOUND');
|
|
9019
|
-
};
|
|
9020
|
-
const getModuleNotFoundError = stderr => {
|
|
9021
|
-
const lines = splitLines(stderr);
|
|
9022
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
9023
|
-
const message = lines[messageIndex];
|
|
9024
|
-
return {
|
|
9025
|
-
message,
|
|
9026
|
-
code: ERR_MODULE_NOT_FOUND
|
|
9027
|
-
};
|
|
9028
|
-
};
|
|
9029
9223
|
const isNormalStackLine = line => {
|
|
9030
9224
|
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
9031
9225
|
};
|
|
@@ -9172,16 +9366,21 @@ const waitForFirstMessage = async port => {
|
|
|
9172
9366
|
// @ts-ignore
|
|
9173
9367
|
return event.data;
|
|
9174
9368
|
};
|
|
9175
|
-
const listen$
|
|
9176
|
-
const parentIpcRaw = listen$
|
|
9177
|
-
signal$
|
|
9178
|
-
const parentIpc = wrap$
|
|
9369
|
+
const listen$3 = async () => {
|
|
9370
|
+
const parentIpcRaw = listen$4();
|
|
9371
|
+
signal$3(parentIpcRaw);
|
|
9372
|
+
const parentIpc = wrap$6(parentIpcRaw);
|
|
9179
9373
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
9180
9374
|
if (firstMessage.method !== 'initialize') {
|
|
9181
9375
|
throw new IpcError('unexpected first message');
|
|
9182
9376
|
}
|
|
9183
9377
|
const type = firstMessage.params[0];
|
|
9184
9378
|
if (type === 'message-port') {
|
|
9379
|
+
parentIpc.send({
|
|
9380
|
+
jsonrpc: '2.0',
|
|
9381
|
+
id: firstMessage.id,
|
|
9382
|
+
result: null
|
|
9383
|
+
});
|
|
9185
9384
|
parentIpc.dispose();
|
|
9186
9385
|
const port = firstMessage.params[1];
|
|
9187
9386
|
return port;
|
|
@@ -9198,7 +9397,8 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
9198
9397
|
send(message) {
|
|
9199
9398
|
this._rawIpc.postMessage(message);
|
|
9200
9399
|
}
|
|
9201
|
-
sendAndTransfer(message
|
|
9400
|
+
sendAndTransfer(message) {
|
|
9401
|
+
const transfer = getTransferrables(message);
|
|
9202
9402
|
this._rawIpc.postMessage(message, transfer);
|
|
9203
9403
|
}
|
|
9204
9404
|
dispose() {
|
|
@@ -9214,15 +9414,15 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
9214
9414
|
this._rawIpc.start();
|
|
9215
9415
|
}
|
|
9216
9416
|
}
|
|
9217
|
-
const wrap$
|
|
9417
|
+
const wrap$5 = port => {
|
|
9218
9418
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
9219
9419
|
};
|
|
9220
9420
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
9221
9421
|
__proto__: null,
|
|
9222
|
-
listen: listen$
|
|
9223
|
-
wrap: wrap$
|
|
9422
|
+
listen: listen$3,
|
|
9423
|
+
wrap: wrap$5
|
|
9224
9424
|
};
|
|
9225
|
-
const listen$
|
|
9425
|
+
const listen$2 = ({
|
|
9226
9426
|
port
|
|
9227
9427
|
}) => {
|
|
9228
9428
|
return port;
|
|
@@ -9240,7 +9440,8 @@ class IpcChildWithMessagePort extends Ipc {
|
|
|
9240
9440
|
send(message) {
|
|
9241
9441
|
this._rawIpc.postMessage(message);
|
|
9242
9442
|
}
|
|
9243
|
-
sendAndTransfer(message
|
|
9443
|
+
sendAndTransfer(message) {
|
|
9444
|
+
const transfer = getTransferrables(message);
|
|
9244
9445
|
this._rawIpc.postMessage(message, transfer);
|
|
9245
9446
|
}
|
|
9246
9447
|
dispose() {
|
|
@@ -9259,7 +9460,7 @@ const wrap$2 = port => {
|
|
|
9259
9460
|
};
|
|
9260
9461
|
const IpcChildWithMessagePort$1 = {
|
|
9261
9462
|
__proto__: null,
|
|
9262
|
-
listen: listen$
|
|
9463
|
+
listen: listen$2,
|
|
9263
9464
|
signal,
|
|
9264
9465
|
wrap: wrap$2
|
|
9265
9466
|
};
|