@lvce-editor/editor-worker 5.13.0 → 5.15.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/editorWorkerMain.js +377 -432
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -236,6 +236,34 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
236
236
|
};
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
+
// TODO this should be in a separate scrolling module
|
|
240
|
+
const setDeltaY$3 = (state, value) => {
|
|
241
|
+
object(state);
|
|
242
|
+
number(value);
|
|
243
|
+
const {
|
|
244
|
+
finalDeltaY,
|
|
245
|
+
deltaY,
|
|
246
|
+
numberOfVisibleLines,
|
|
247
|
+
height,
|
|
248
|
+
scrollBarHeight,
|
|
249
|
+
itemHeight
|
|
250
|
+
} = state;
|
|
251
|
+
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
252
|
+
if (deltaY === newDeltaY) {
|
|
253
|
+
return state;
|
|
254
|
+
}
|
|
255
|
+
const newMinLineY = Math.floor(newDeltaY / itemHeight);
|
|
256
|
+
const newMaxLineY = newMinLineY + numberOfVisibleLines;
|
|
257
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height, scrollBarHeight);
|
|
258
|
+
return {
|
|
259
|
+
...state,
|
|
260
|
+
minLineY: newMinLineY,
|
|
261
|
+
maxLineY: newMaxLineY,
|
|
262
|
+
deltaY: newDeltaY,
|
|
263
|
+
scrollBarY
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
|
|
239
267
|
const splitLines$2 = lines => {
|
|
240
268
|
if (!lines) {
|
|
241
269
|
return [];
|
|
@@ -424,34 +452,6 @@ const positionAt = (textDocument, offset) => {
|
|
|
424
452
|
};
|
|
425
453
|
};
|
|
426
454
|
|
|
427
|
-
// TODO this should be in a separate scrolling module
|
|
428
|
-
const setDeltaY$3 = (state, value) => {
|
|
429
|
-
object(state);
|
|
430
|
-
number(value);
|
|
431
|
-
const {
|
|
432
|
-
finalDeltaY,
|
|
433
|
-
deltaY,
|
|
434
|
-
numberOfVisibleLines,
|
|
435
|
-
height,
|
|
436
|
-
scrollBarHeight,
|
|
437
|
-
itemHeight
|
|
438
|
-
} = state;
|
|
439
|
-
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
440
|
-
if (deltaY === newDeltaY) {
|
|
441
|
-
return state;
|
|
442
|
-
}
|
|
443
|
-
const newMinLineY = Math.floor(newDeltaY / itemHeight);
|
|
444
|
-
const newMaxLineY = newMinLineY + numberOfVisibleLines;
|
|
445
|
-
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height, scrollBarHeight);
|
|
446
|
-
return {
|
|
447
|
-
...state,
|
|
448
|
-
minLineY: newMinLineY,
|
|
449
|
-
maxLineY: newMaxLineY,
|
|
450
|
-
deltaY: newDeltaY,
|
|
451
|
-
scrollBarY
|
|
452
|
-
};
|
|
453
|
-
};
|
|
454
|
-
|
|
455
455
|
const getSelectionPairs = (selections, i) => {
|
|
456
456
|
const first = selections[i];
|
|
457
457
|
const second = selections[i + 1];
|
|
@@ -464,7 +464,7 @@ const getSelectionPairs = (selections, i) => {
|
|
|
464
464
|
};
|
|
465
465
|
|
|
466
466
|
const EmptyString$1 = '';
|
|
467
|
-
const NewLine$
|
|
467
|
+
const NewLine$3 = '\n';
|
|
468
468
|
const Space$2 = ' ';
|
|
469
469
|
const Tab$1 = '\t';
|
|
470
470
|
const DoubleQuote$1 = '"';
|
|
@@ -1067,9 +1067,6 @@ let id = 0;
|
|
|
1067
1067
|
const create$3$1 = () => {
|
|
1068
1068
|
return ++id;
|
|
1069
1069
|
};
|
|
1070
|
-
const warn$1 = (...args) => {
|
|
1071
|
-
console.warn(...args);
|
|
1072
|
-
};
|
|
1073
1070
|
const registerPromise = () => {
|
|
1074
1071
|
const id = create$3$1();
|
|
1075
1072
|
const {
|
|
@@ -1082,16 +1079,6 @@ const registerPromise = () => {
|
|
|
1082
1079
|
promise
|
|
1083
1080
|
};
|
|
1084
1081
|
};
|
|
1085
|
-
const resolve = (id, response) => {
|
|
1086
|
-
const fn = get$5(id);
|
|
1087
|
-
if (!fn) {
|
|
1088
|
-
console.log(response);
|
|
1089
|
-
warn$1(`callback ${id} may already be disposed`);
|
|
1090
|
-
return;
|
|
1091
|
-
}
|
|
1092
|
-
fn(response);
|
|
1093
|
-
remove$8(id);
|
|
1094
|
-
};
|
|
1095
1082
|
const create$2$1 = (method, params) => {
|
|
1096
1083
|
const {
|
|
1097
1084
|
id,
|
|
@@ -1114,7 +1101,7 @@ class JsonRpcError extends Error {
|
|
|
1114
1101
|
this.name = 'JsonRpcError';
|
|
1115
1102
|
}
|
|
1116
1103
|
}
|
|
1117
|
-
const NewLine$
|
|
1104
|
+
const NewLine$2 = '\n';
|
|
1118
1105
|
const DomException = 'DOMException';
|
|
1119
1106
|
const ReferenceError$1 = 'ReferenceError';
|
|
1120
1107
|
const SyntaxError$1 = 'SyntaxError';
|
|
@@ -1159,23 +1146,23 @@ const constructError = (message, type, name) => {
|
|
|
1159
1146
|
}
|
|
1160
1147
|
return new ErrorConstructor(message);
|
|
1161
1148
|
};
|
|
1162
|
-
const getNewLineIndex$
|
|
1163
|
-
return string.indexOf(NewLine$
|
|
1149
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
1150
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
1164
1151
|
};
|
|
1165
1152
|
const getParentStack = error => {
|
|
1166
1153
|
let parentStack = error.stack || error.data || error.message || '';
|
|
1167
1154
|
if (parentStack.startsWith(' at')) {
|
|
1168
|
-
parentStack = error.message + NewLine$
|
|
1155
|
+
parentStack = error.message + NewLine$2 + parentStack;
|
|
1169
1156
|
}
|
|
1170
1157
|
return parentStack;
|
|
1171
1158
|
};
|
|
1172
1159
|
const joinLines$1 = lines => {
|
|
1173
|
-
return lines.join(NewLine$
|
|
1160
|
+
return lines.join(NewLine$2);
|
|
1174
1161
|
};
|
|
1175
1162
|
const MethodNotFound = -32601;
|
|
1176
1163
|
const Custom = -32001;
|
|
1177
1164
|
const splitLines$1 = lines => {
|
|
1178
|
-
return lines.split(NewLine$
|
|
1165
|
+
return lines.split(NewLine$2);
|
|
1179
1166
|
};
|
|
1180
1167
|
const restoreJsonRpcError = error => {
|
|
1181
1168
|
if (error && error instanceof Error) {
|
|
@@ -1185,14 +1172,14 @@ const restoreJsonRpcError = error => {
|
|
|
1185
1172
|
if (error && error.code && error.code === MethodNotFound) {
|
|
1186
1173
|
const restoredError = new JsonRpcError(error.message);
|
|
1187
1174
|
const parentStack = getParentStack(error);
|
|
1188
|
-
restoredError.stack = parentStack + NewLine$
|
|
1175
|
+
restoredError.stack = parentStack + NewLine$2 + currentStack;
|
|
1189
1176
|
return restoredError;
|
|
1190
1177
|
}
|
|
1191
1178
|
if (error && error.message) {
|
|
1192
1179
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
1193
1180
|
if (error.data) {
|
|
1194
1181
|
if (error.data.stack && error.data.type && error.message) {
|
|
1195
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$
|
|
1182
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine$2 + error.data.stack + NewLine$2 + currentStack;
|
|
1196
1183
|
} else if (error.data.stack) {
|
|
1197
1184
|
restoredError.stack = error.data.stack;
|
|
1198
1185
|
}
|
|
@@ -1212,7 +1199,7 @@ const restoreJsonRpcError = error => {
|
|
|
1212
1199
|
if (error.stack) {
|
|
1213
1200
|
const lowerStack = restoredError.stack || '';
|
|
1214
1201
|
// @ts-ignore
|
|
1215
|
-
const indexNewLine = getNewLineIndex$
|
|
1202
|
+
const indexNewLine = getNewLineIndex$1(lowerStack);
|
|
1216
1203
|
const parentStack = getParentStack(error);
|
|
1217
1204
|
// @ts-ignore
|
|
1218
1205
|
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
@@ -1239,6 +1226,19 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
1239
1226
|
}
|
|
1240
1227
|
throw new JsonRpcError('unexpected response message');
|
|
1241
1228
|
};
|
|
1229
|
+
const warn$1 = (...args) => {
|
|
1230
|
+
console.warn(...args);
|
|
1231
|
+
};
|
|
1232
|
+
const resolve = (id, response) => {
|
|
1233
|
+
const fn = get$5(id);
|
|
1234
|
+
if (!fn) {
|
|
1235
|
+
console.log(response);
|
|
1236
|
+
warn$1(`callback ${id} may already be disposed`);
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
fn(response);
|
|
1240
|
+
remove$8(id);
|
|
1241
|
+
};
|
|
1242
1242
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1243
1243
|
const getErrorType = prettyError => {
|
|
1244
1244
|
if (prettyError && prettyError.type) {
|
|
@@ -1457,7 +1457,7 @@ const invokeAndTransfer$1 = async (method, ...params) => {
|
|
|
1457
1457
|
const ipc = get$4();
|
|
1458
1458
|
return invokeAndTransfer$2(ipc, method, ...params);
|
|
1459
1459
|
};
|
|
1460
|
-
const listen$
|
|
1460
|
+
const listen$5 = ipc => {
|
|
1461
1461
|
set$4(ipc);
|
|
1462
1462
|
};
|
|
1463
1463
|
|
|
@@ -1549,8 +1549,8 @@ const IpcParentWithExtensionHostWorker = {
|
|
|
1549
1549
|
wrap: wrap$2
|
|
1550
1550
|
};
|
|
1551
1551
|
|
|
1552
|
-
const
|
|
1553
|
-
await invokeAndTransfer('
|
|
1552
|
+
const sendMessagePortToRendererProcess = async port => {
|
|
1553
|
+
await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
|
|
1554
1554
|
};
|
|
1555
1555
|
|
|
1556
1556
|
const create$c = async () => {
|
|
@@ -1558,7 +1558,7 @@ const create$c = async () => {
|
|
|
1558
1558
|
port1,
|
|
1559
1559
|
port2
|
|
1560
1560
|
} = getPortTuple();
|
|
1561
|
-
await
|
|
1561
|
+
await sendMessagePortToRendererProcess(port1);
|
|
1562
1562
|
const event = await waitForFirstMessage$1(port2);
|
|
1563
1563
|
if (event.data !== 'ready') {
|
|
1564
1564
|
throw new IpcError$1('unexpected first message');
|
|
@@ -1596,14 +1596,14 @@ const wrap$1 = port => {
|
|
|
1596
1596
|
};
|
|
1597
1597
|
};
|
|
1598
1598
|
|
|
1599
|
-
const
|
|
1599
|
+
const IpcParentWithRendererProcess = {
|
|
1600
1600
|
__proto__: null,
|
|
1601
1601
|
create: create$c,
|
|
1602
1602
|
wrap: wrap$1
|
|
1603
1603
|
};
|
|
1604
1604
|
|
|
1605
|
-
const
|
|
1606
|
-
await invokeAndTransfer('
|
|
1605
|
+
const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
1606
|
+
await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
1607
1607
|
};
|
|
1608
1608
|
|
|
1609
1609
|
const create$b = async () => {
|
|
@@ -1611,7 +1611,7 @@ const create$b = async () => {
|
|
|
1611
1611
|
port1,
|
|
1612
1612
|
port2
|
|
1613
1613
|
} = getPortTuple();
|
|
1614
|
-
await
|
|
1614
|
+
await sendMessagePortToSyntaxHighlightingWorker(port1);
|
|
1615
1615
|
const event = await waitForFirstMessage$1(port2);
|
|
1616
1616
|
if (event.data !== 'ready') {
|
|
1617
1617
|
throw new IpcError$1('unexpected first message');
|
|
@@ -1649,7 +1649,7 @@ const wrap = port => {
|
|
|
1649
1649
|
};
|
|
1650
1650
|
};
|
|
1651
1651
|
|
|
1652
|
-
const
|
|
1652
|
+
const IpcParentWithSyntaxHighlightingWorker = {
|
|
1653
1653
|
__proto__: null,
|
|
1654
1654
|
create: create$b,
|
|
1655
1655
|
wrap
|
|
@@ -1702,7 +1702,7 @@ const createRpc = method => {
|
|
|
1702
1702
|
};
|
|
1703
1703
|
|
|
1704
1704
|
const {
|
|
1705
|
-
listen: listen$
|
|
1705
|
+
listen: listen$4,
|
|
1706
1706
|
invoke: invoke$2
|
|
1707
1707
|
} = createRpc(ExtensionHostWorker);
|
|
1708
1708
|
|
|
@@ -2364,15 +2364,6 @@ const cancelSelection = editor => {
|
|
|
2364
2364
|
return scheduleSelections(editor, newSelections);
|
|
2365
2365
|
};
|
|
2366
2366
|
|
|
2367
|
-
const CodeGenerator = 1;
|
|
2368
|
-
const ColorPicker$1 = 2;
|
|
2369
|
-
const Completion = 3;
|
|
2370
|
-
const CompletionDetail = 4;
|
|
2371
|
-
const Find = 5;
|
|
2372
|
-
const Hover = 6;
|
|
2373
|
-
const Rename = 7;
|
|
2374
|
-
const SourceAction = 8;
|
|
2375
|
-
|
|
2376
2367
|
const getIndex = (widgets, id) => {
|
|
2377
2368
|
for (const [i, widget] of widgets.entries()) {
|
|
2378
2369
|
if (widget.id === id) {
|
|
@@ -2387,6 +2378,15 @@ const removeEditorWidget = (widgets, id) => {
|
|
|
2387
2378
|
return newWidgets;
|
|
2388
2379
|
};
|
|
2389
2380
|
|
|
2381
|
+
const CodeGenerator = 1;
|
|
2382
|
+
const ColorPicker$1 = 2;
|
|
2383
|
+
const Completion = 3;
|
|
2384
|
+
const CompletionDetail = 4;
|
|
2385
|
+
const Find = 5;
|
|
2386
|
+
const Hover = 6;
|
|
2387
|
+
const Rename = 7;
|
|
2388
|
+
const SourceAction = 8;
|
|
2389
|
+
|
|
2390
2390
|
const isMatchingWidget$2 = widget => {
|
|
2391
2391
|
return widget.id === CodeGenerator;
|
|
2392
2392
|
};
|
|
@@ -2618,7 +2618,7 @@ const compositionEnd = (editor, data) => {
|
|
|
2618
2618
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
2619
2619
|
};
|
|
2620
2620
|
|
|
2621
|
-
const normalizeLine
|
|
2621
|
+
const normalizeLine = line => {
|
|
2622
2622
|
if (line.startsWith('Error: ')) {
|
|
2623
2623
|
return line.slice('Error: '.length);
|
|
2624
2624
|
}
|
|
@@ -2627,41 +2627,41 @@ const normalizeLine$1 = line => {
|
|
|
2627
2627
|
}
|
|
2628
2628
|
return line;
|
|
2629
2629
|
};
|
|
2630
|
-
const getCombinedMessage
|
|
2631
|
-
const stringifiedError = normalizeLine
|
|
2630
|
+
const getCombinedMessage = (error, message) => {
|
|
2631
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
2632
2632
|
if (message) {
|
|
2633
2633
|
return `${message}: ${stringifiedError}`;
|
|
2634
2634
|
}
|
|
2635
2635
|
return stringifiedError;
|
|
2636
2636
|
};
|
|
2637
|
-
const NewLine$
|
|
2638
|
-
const getNewLineIndex
|
|
2639
|
-
return string.indexOf(NewLine$
|
|
2637
|
+
const NewLine$1 = '\n';
|
|
2638
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
2639
|
+
return string.indexOf(NewLine$1, startIndex);
|
|
2640
2640
|
};
|
|
2641
|
-
const mergeStacks
|
|
2641
|
+
const mergeStacks = (parent, child) => {
|
|
2642
2642
|
if (!child) {
|
|
2643
2643
|
return parent;
|
|
2644
2644
|
}
|
|
2645
|
-
const parentNewLineIndex = getNewLineIndex
|
|
2646
|
-
const childNewLineIndex = getNewLineIndex
|
|
2645
|
+
const parentNewLineIndex = getNewLineIndex(parent);
|
|
2646
|
+
const childNewLineIndex = getNewLineIndex(child);
|
|
2647
2647
|
if (childNewLineIndex === -1) {
|
|
2648
2648
|
return parent;
|
|
2649
2649
|
}
|
|
2650
2650
|
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
2651
2651
|
const childRest = child.slice(childNewLineIndex);
|
|
2652
|
-
const childFirstLine = normalizeLine
|
|
2652
|
+
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
2653
2653
|
if (parentFirstLine.includes(childFirstLine)) {
|
|
2654
2654
|
return parentFirstLine + childRest;
|
|
2655
2655
|
}
|
|
2656
2656
|
return child;
|
|
2657
2657
|
};
|
|
2658
|
-
|
|
2658
|
+
class VError extends Error {
|
|
2659
2659
|
constructor(error, message) {
|
|
2660
|
-
const combinedMessage = getCombinedMessage
|
|
2660
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
2661
2661
|
super(combinedMessage);
|
|
2662
2662
|
this.name = 'VError';
|
|
2663
2663
|
if (error instanceof Error) {
|
|
2664
|
-
this.stack = mergeStacks
|
|
2664
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
2665
2665
|
}
|
|
2666
2666
|
if (error.codeFrame) {
|
|
2667
2667
|
// @ts-ignore
|
|
@@ -2672,14 +2672,14 @@ let VError$1 = class VError extends Error {
|
|
|
2672
2672
|
this.code = error.code;
|
|
2673
2673
|
}
|
|
2674
2674
|
}
|
|
2675
|
-
}
|
|
2675
|
+
}
|
|
2676
2676
|
|
|
2677
2677
|
const writeText = async text => {
|
|
2678
2678
|
try {
|
|
2679
2679
|
string(text);
|
|
2680
2680
|
await invoke$3('ClipBoard.writeText', /* text */text);
|
|
2681
2681
|
} catch (error) {
|
|
2682
|
-
throw new VError
|
|
2682
|
+
throw new VError(error, 'Failed to write text to clipboard');
|
|
2683
2683
|
}
|
|
2684
2684
|
};
|
|
2685
2685
|
|
|
@@ -3817,9 +3817,6 @@ const setPosition$1 = position => {
|
|
|
3817
3817
|
state$5.position = position;
|
|
3818
3818
|
};
|
|
3819
3819
|
|
|
3820
|
-
const Ctrl = 1;
|
|
3821
|
-
const Alt$1 = 2;
|
|
3822
|
-
|
|
3823
3820
|
// TODO first change cursor position, then run go to definition
|
|
3824
3821
|
// cursor should appear at mousedown position immediately
|
|
3825
3822
|
const handleSingleClickWithAlt = async (editor, position) => {
|
|
@@ -3836,6 +3833,7 @@ const handleSingleClickWithAlt = async (editor, position) => {
|
|
|
3836
3833
|
const newEditor2 = await goToDefinition(newEditor);
|
|
3837
3834
|
return newEditor2;
|
|
3838
3835
|
};
|
|
3836
|
+
|
|
3839
3837
|
const handleSingleClickWithCtrl = async (editor, position) => {
|
|
3840
3838
|
const selections = editor.selections;
|
|
3841
3839
|
for (let i = 0; i < selections.length; i += 4) {
|
|
@@ -3859,6 +3857,10 @@ const handleSingleClickWithCtrl = async (editor, position) => {
|
|
|
3859
3857
|
newSelections[insertIndex + 3] = position.columnIndex;
|
|
3860
3858
|
return scheduleSelections(editor, newSelections);
|
|
3861
3859
|
};
|
|
3860
|
+
|
|
3861
|
+
const Ctrl = 1;
|
|
3862
|
+
const Alt$1 = 2;
|
|
3863
|
+
|
|
3862
3864
|
const handleSingleClickDefault = (editor, position) => {
|
|
3863
3865
|
setPosition$1(position);
|
|
3864
3866
|
return {
|
|
@@ -3867,7 +3869,7 @@ const handleSingleClickDefault = (editor, position) => {
|
|
|
3867
3869
|
focused: true
|
|
3868
3870
|
};
|
|
3869
3871
|
};
|
|
3870
|
-
const
|
|
3872
|
+
const getClickHandler = modifier => {
|
|
3871
3873
|
switch (modifier) {
|
|
3872
3874
|
case Alt$1:
|
|
3873
3875
|
return handleSingleClickWithAlt;
|
|
@@ -3877,13 +3879,14 @@ const getFn = modifier => {
|
|
|
3877
3879
|
return handleSingleClickDefault;
|
|
3878
3880
|
}
|
|
3879
3881
|
};
|
|
3882
|
+
|
|
3880
3883
|
const handleSingleClick = async (editor, modifier, x, y) => {
|
|
3881
3884
|
object(editor);
|
|
3882
3885
|
number(modifier);
|
|
3883
3886
|
number(x);
|
|
3884
3887
|
number(y);
|
|
3885
3888
|
const position = at(editor, x, y);
|
|
3886
|
-
const fn =
|
|
3889
|
+
const fn = getClickHandler(modifier);
|
|
3887
3890
|
const newEditor = await fn(editor, position);
|
|
3888
3891
|
// switch (newEditor.completionState) {
|
|
3889
3892
|
// case EditorCompletionState.None:
|
|
@@ -5337,19 +5340,6 @@ const create$4 = () => {
|
|
|
5337
5340
|
return widget;
|
|
5338
5341
|
};
|
|
5339
5342
|
|
|
5340
|
-
// copied from https://github.com/microsoft/vscode/tree/main/src/vs/base/common/strings.ts by Microsoft (License MIT)
|
|
5341
|
-
|
|
5342
|
-
const RE_ESCAPE = /[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g;
|
|
5343
|
-
const escapeRegExpCharacters = value => {
|
|
5344
|
-
return value.replaceAll(RE_ESCAPE, '\\$&');
|
|
5345
|
-
};
|
|
5346
|
-
|
|
5347
|
-
const regexFlags = 'gi';
|
|
5348
|
-
const getSearchRegex = searchString => {
|
|
5349
|
-
const escaped = escapeRegExpCharacters(searchString);
|
|
5350
|
-
return new RegExp(escaped, regexFlags);
|
|
5351
|
-
};
|
|
5352
|
-
|
|
5353
5343
|
const findRegexMatches = (lines, regex) => {
|
|
5354
5344
|
if (!regex.global) {
|
|
5355
5345
|
throw new Error('regex must be global');
|
|
@@ -5372,6 +5362,19 @@ const findRegexMatches = (lines, regex) => {
|
|
|
5372
5362
|
return new Uint32Array(matches);
|
|
5373
5363
|
};
|
|
5374
5364
|
|
|
5365
|
+
// copied from https://github.com/microsoft/vscode/tree/main/src/vs/base/common/strings.ts by Microsoft (License MIT)
|
|
5366
|
+
|
|
5367
|
+
const RE_ESCAPE = /[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g;
|
|
5368
|
+
const escapeRegExpCharacters = value => {
|
|
5369
|
+
return value.replaceAll(RE_ESCAPE, '\\$&');
|
|
5370
|
+
};
|
|
5371
|
+
|
|
5372
|
+
const regexFlags = 'gi';
|
|
5373
|
+
const getSearchRegex = searchString => {
|
|
5374
|
+
const escaped = escapeRegExpCharacters(searchString);
|
|
5375
|
+
return new RegExp(escaped, regexFlags);
|
|
5376
|
+
};
|
|
5377
|
+
|
|
5375
5378
|
const findMatchesCaseInsensitive = (lines, searchString) => {
|
|
5376
5379
|
if (searchString.length === 0) {
|
|
5377
5380
|
return new Uint32Array([]);
|
|
@@ -5946,7 +5949,7 @@ const save = async editor => {
|
|
|
5946
5949
|
return newEditor;
|
|
5947
5950
|
} catch (error) {
|
|
5948
5951
|
// @ts-ignore
|
|
5949
|
-
const betterError = new VError
|
|
5952
|
+
const betterError = new VError(error, `Failed to save file "${editor.uri}"`);
|
|
5950
5953
|
await handleError(betterError);
|
|
5951
5954
|
return editor;
|
|
5952
5955
|
}
|
|
@@ -6235,6 +6238,23 @@ const selectInsideString = editor => {
|
|
|
6235
6238
|
return scheduleSelections(editor, newSelections);
|
|
6236
6239
|
};
|
|
6237
6240
|
|
|
6241
|
+
// import * as ExtensionHostSelection from '../ExtensionHost/ExtensionHostSelection.ts'
|
|
6242
|
+
|
|
6243
|
+
const getNewSelections = async (editor, selections) => {
|
|
6244
|
+
const newSelections = await invoke$3('ExtensionHostSelection.executeGrowSelection', editor, selections);
|
|
6245
|
+
if (newSelections.length === 0) {
|
|
6246
|
+
return selections;
|
|
6247
|
+
}
|
|
6248
|
+
return new Uint32Array(newSelections);
|
|
6249
|
+
};
|
|
6250
|
+
const selectionGrow = async editor => {
|
|
6251
|
+
const {
|
|
6252
|
+
selections
|
|
6253
|
+
} = editor;
|
|
6254
|
+
const newSelections = await getNewSelections(editor, selections);
|
|
6255
|
+
return scheduleSelections(editor, newSelections);
|
|
6256
|
+
};
|
|
6257
|
+
|
|
6238
6258
|
// TODO handle virtual space
|
|
6239
6259
|
|
|
6240
6260
|
// TODO editors behave differently when selecting next occurrence, for example:
|
|
@@ -6446,23 +6466,6 @@ const selectWordRight = editor => {
|
|
|
6446
6466
|
return editorSelectHorizontalRight(editor, wordRight);
|
|
6447
6467
|
};
|
|
6448
6468
|
|
|
6449
|
-
// import * as ExtensionHostSelection from '../ExtensionHost/ExtensionHostSelection.ts'
|
|
6450
|
-
|
|
6451
|
-
const getNewSelections = async (editor, selections) => {
|
|
6452
|
-
const newSelections = await invoke$3('ExtensionHostSelection.executeGrowSelection', editor, selections);
|
|
6453
|
-
if (newSelections.length === 0) {
|
|
6454
|
-
return selections;
|
|
6455
|
-
}
|
|
6456
|
-
return new Uint32Array(newSelections);
|
|
6457
|
-
};
|
|
6458
|
-
const selectionGrow = async editor => {
|
|
6459
|
-
const {
|
|
6460
|
-
selections
|
|
6461
|
-
} = editor;
|
|
6462
|
-
const newSelections = await getNewSelections(editor, selections);
|
|
6463
|
-
return scheduleSelections(editor, newSelections);
|
|
6464
|
-
};
|
|
6465
|
-
|
|
6466
6469
|
const setDecorations = (editor, decorations, diagnostics) => {
|
|
6467
6470
|
if (editor.decorations.length === 0 && decorations.length === 0) {
|
|
6468
6471
|
return editor;
|
|
@@ -6474,6 +6477,19 @@ const setDecorations = (editor, decorations, diagnostics) => {
|
|
|
6474
6477
|
};
|
|
6475
6478
|
};
|
|
6476
6479
|
|
|
6480
|
+
let enabled$1 = false;
|
|
6481
|
+
const setEnabled$1 = value => {
|
|
6482
|
+
enabled$1 = value;
|
|
6483
|
+
};
|
|
6484
|
+
const getEnabled$1 = () => {
|
|
6485
|
+
return enabled$1;
|
|
6486
|
+
};
|
|
6487
|
+
|
|
6488
|
+
const {
|
|
6489
|
+
listen: listen$3,
|
|
6490
|
+
invoke: invoke$1
|
|
6491
|
+
} = createRpc(SyntaxHighlightingWorker);
|
|
6492
|
+
|
|
6477
6493
|
/**
|
|
6478
6494
|
* @enum number
|
|
6479
6495
|
*/
|
|
@@ -6534,19 +6550,6 @@ const isPending = languageId => {
|
|
|
6534
6550
|
return languageId in state$1.pending;
|
|
6535
6551
|
};
|
|
6536
6552
|
|
|
6537
|
-
let enabled$1 = false;
|
|
6538
|
-
const setEnabled$1 = value => {
|
|
6539
|
-
enabled$1 = value;
|
|
6540
|
-
};
|
|
6541
|
-
const getEnabled$1 = () => {
|
|
6542
|
-
return enabled$1;
|
|
6543
|
-
};
|
|
6544
|
-
|
|
6545
|
-
const {
|
|
6546
|
-
listen: listen$5,
|
|
6547
|
-
invoke: invoke$1
|
|
6548
|
-
} = createRpc(SyntaxHighlightingWorker);
|
|
6549
|
-
|
|
6550
6553
|
const tokenMaps = Object.create(null);
|
|
6551
6554
|
const set$1 = (languageId, tokenMap) => {
|
|
6552
6555
|
tokenMaps[languageId] = tokenMap;
|
|
@@ -6666,12 +6669,6 @@ const setSelections = (editor, selections) => {
|
|
|
6666
6669
|
};
|
|
6667
6670
|
};
|
|
6668
6671
|
|
|
6669
|
-
const EditorHover = 'EditorHover';
|
|
6670
|
-
const showHover = async state => {
|
|
6671
|
-
await invoke$3('Viewlet.openWidget', EditorHover);
|
|
6672
|
-
return state;
|
|
6673
|
-
};
|
|
6674
|
-
|
|
6675
6672
|
const create$2 = () => {
|
|
6676
6673
|
const uid = create$8();
|
|
6677
6674
|
const widget = {
|
|
@@ -6725,7 +6722,7 @@ const getHover = async (editor, offset) => {
|
|
|
6725
6722
|
};
|
|
6726
6723
|
|
|
6727
6724
|
let _ipc;
|
|
6728
|
-
const listen$
|
|
6725
|
+
const listen$2 = async () => {
|
|
6729
6726
|
const ipc = await create$a({
|
|
6730
6727
|
method: RendererProcess
|
|
6731
6728
|
});
|
|
@@ -6946,6 +6943,12 @@ const showHover2 = async editor => {
|
|
|
6946
6943
|
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
|
|
6947
6944
|
};
|
|
6948
6945
|
|
|
6946
|
+
const EditorHover = 'EditorHover';
|
|
6947
|
+
const showHover = async state => {
|
|
6948
|
+
await invoke$3('Viewlet.openWidget', EditorHover);
|
|
6949
|
+
return state;
|
|
6950
|
+
};
|
|
6951
|
+
|
|
6949
6952
|
// TODO ask extension host worker instead
|
|
6950
6953
|
const getEditorSourceActions = async () => {
|
|
6951
6954
|
const sourceActions = await invoke$3('GetEditorSourceActions.getEditorSourceActions');
|
|
@@ -8139,16 +8142,31 @@ const SourceActionItem = 'SourceActionItem';
|
|
|
8139
8142
|
const SourceActionItemFocused = 'SourceActionItemFocused';
|
|
8140
8143
|
const Viewlet = 'Viewlet';
|
|
8141
8144
|
|
|
8142
|
-
const
|
|
8143
|
-
const
|
|
8144
|
-
const
|
|
8145
|
-
const
|
|
8146
|
-
const
|
|
8147
|
-
const
|
|
8148
|
-
const
|
|
8149
|
-
|
|
8150
|
-
const
|
|
8151
|
-
|
|
8145
|
+
const HandlePointerDown = 'handlePointerDown';
|
|
8146
|
+
const HandleSashPointerDown = 'handleSashPointerDown';
|
|
8147
|
+
const HandleClose = 'handleClose';
|
|
8148
|
+
const HandleFocusIn = 'handleFocusIn';
|
|
8149
|
+
const HandleClick = 'handleClick';
|
|
8150
|
+
const HandleInput = 'handleInput';
|
|
8151
|
+
const HandleFocus = 'handleFocus';
|
|
8152
|
+
const HandleClickPreviousMatch = 'handleClickPreviousMatch';
|
|
8153
|
+
const HandleClickNextMatch = 'handleClickNextMatch';
|
|
8154
|
+
const HandleClickClose = 'handleClickClose';
|
|
8155
|
+
const HandleClickReplace = 'handleClickReplace';
|
|
8156
|
+
const HandleClickReplaceAll = 'handleClickReplaceAll';
|
|
8157
|
+
const HandleReplaceInput = 'handleReplaceInput';
|
|
8158
|
+
const HandleReplaceFocus = 'handleReplaceFocus';
|
|
8159
|
+
|
|
8160
|
+
const Button = 1;
|
|
8161
|
+
const Div = 4;
|
|
8162
|
+
const Input = 6;
|
|
8163
|
+
const Span = 8;
|
|
8164
|
+
const Text = 12;
|
|
8165
|
+
const Img = 17;
|
|
8166
|
+
const TextArea = 62;
|
|
8167
|
+
|
|
8168
|
+
const text = data => {
|
|
8169
|
+
return {
|
|
8152
8170
|
type: Text,
|
|
8153
8171
|
text: data,
|
|
8154
8172
|
childCount: 0
|
|
@@ -8177,21 +8195,6 @@ const getLineInfosVirtualDom = lineInfos => {
|
|
|
8177
8195
|
return dom;
|
|
8178
8196
|
};
|
|
8179
8197
|
|
|
8180
|
-
const HandlePointerDown = 'handlePointerDown';
|
|
8181
|
-
const HandleSashPointerDown = 'handleSashPointerDown';
|
|
8182
|
-
const HandleClose = 'handleClose';
|
|
8183
|
-
const HandleFocusIn = 'handleFocusIn';
|
|
8184
|
-
const HandleClick = 'handleClick';
|
|
8185
|
-
const HandleInput = 'handleInput';
|
|
8186
|
-
const HandleFocus = 'handleFocus';
|
|
8187
|
-
const HandleClickPreviousMatch = 'handleClickPreviousMatch';
|
|
8188
|
-
const HandleClickNextMatch = 'handleClickNextMatch';
|
|
8189
|
-
const HandleClickClose = 'handleClickClose';
|
|
8190
|
-
const HandleClickReplace = 'handleClickReplace';
|
|
8191
|
-
const HandleClickReplaceAll = 'handleClickReplaceAll';
|
|
8192
|
-
const HandleReplaceInput = 'handleReplaceInput';
|
|
8193
|
-
const HandleReplaceFocus = 'handleReplaceFocus';
|
|
8194
|
-
|
|
8195
8198
|
const hoverProblemMessage = {
|
|
8196
8199
|
type: Span,
|
|
8197
8200
|
className: HoverProblemMessage,
|
|
@@ -8475,7 +8478,7 @@ const loadFont = async (fontName, fontUrl) => {
|
|
|
8475
8478
|
// @ts-ignore
|
|
8476
8479
|
fonts.add(fontFace);
|
|
8477
8480
|
} catch (error) {
|
|
8478
|
-
throw new VError
|
|
8481
|
+
throw new VError(error, `Failed to load font ${fontName}`);
|
|
8479
8482
|
}
|
|
8480
8483
|
};
|
|
8481
8484
|
|
|
@@ -8981,7 +8984,7 @@ const getText = editorUid => {
|
|
|
8981
8984
|
const {
|
|
8982
8985
|
lines
|
|
8983
8986
|
} = editor;
|
|
8984
|
-
return lines.join(NewLine$
|
|
8987
|
+
return lines.join(NewLine$3);
|
|
8985
8988
|
};
|
|
8986
8989
|
|
|
8987
8990
|
const InsertText = 'insertText';
|
|
@@ -9017,15 +9020,15 @@ const getEnabled = () => {
|
|
|
9017
9020
|
};
|
|
9018
9021
|
|
|
9019
9022
|
const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
9020
|
-
await listen$
|
|
9023
|
+
await listen$2();
|
|
9021
9024
|
if (syntaxHighlightingEnabled) {
|
|
9022
9025
|
setEnabled$1(true);
|
|
9023
|
-
await listen$
|
|
9026
|
+
await listen$3();
|
|
9024
9027
|
}
|
|
9025
9028
|
if (syncIncremental) {
|
|
9026
9029
|
setEnabled(true);
|
|
9027
9030
|
}
|
|
9028
|
-
await listen$
|
|
9031
|
+
await listen$4();
|
|
9029
9032
|
};
|
|
9030
9033
|
|
|
9031
9034
|
// TODO move cursor
|
|
@@ -10191,67 +10194,6 @@ const commandMap = {
|
|
|
10191
10194
|
};
|
|
10192
10195
|
wrapCommands(commandMap);
|
|
10193
10196
|
|
|
10194
|
-
const MessagePort$1 = 1;
|
|
10195
|
-
const ModuleWorker = 2;
|
|
10196
|
-
const ReferencePort = 3;
|
|
10197
|
-
const ModuleWorkerAndMessagePort = 8;
|
|
10198
|
-
const Auto = () => {
|
|
10199
|
-
// @ts-ignore
|
|
10200
|
-
if (globalThis.acceptPort) {
|
|
10201
|
-
return MessagePort$1;
|
|
10202
|
-
}
|
|
10203
|
-
// @ts-ignore
|
|
10204
|
-
if (globalThis.acceptReferencePort) {
|
|
10205
|
-
return ReferencePort;
|
|
10206
|
-
}
|
|
10207
|
-
return ModuleWorkerAndMessagePort;
|
|
10208
|
-
};
|
|
10209
|
-
|
|
10210
|
-
const getData$1 = event => {
|
|
10211
|
-
return event.data;
|
|
10212
|
-
};
|
|
10213
|
-
const attachEvents = that => {
|
|
10214
|
-
const handleMessage = (...args) => {
|
|
10215
|
-
const data = that.getData(...args);
|
|
10216
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
10217
|
-
data
|
|
10218
|
-
}));
|
|
10219
|
-
};
|
|
10220
|
-
that.onMessage(handleMessage);
|
|
10221
|
-
const handleClose = event => {
|
|
10222
|
-
that.dispatchEvent(new Event('close'));
|
|
10223
|
-
};
|
|
10224
|
-
that.onClose(handleClose);
|
|
10225
|
-
};
|
|
10226
|
-
class Ipc extends EventTarget {
|
|
10227
|
-
constructor(rawIpc) {
|
|
10228
|
-
super();
|
|
10229
|
-
this._rawIpc = rawIpc;
|
|
10230
|
-
attachEvents(this);
|
|
10231
|
-
}
|
|
10232
|
-
}
|
|
10233
|
-
const readyMessage = 'ready';
|
|
10234
|
-
const walkValue = (value, transferrables, isTransferrable) => {
|
|
10235
|
-
if (!value) {
|
|
10236
|
-
return;
|
|
10237
|
-
}
|
|
10238
|
-
if (isTransferrable(value)) {
|
|
10239
|
-
transferrables.push(value);
|
|
10240
|
-
return;
|
|
10241
|
-
}
|
|
10242
|
-
if (Array.isArray(value)) {
|
|
10243
|
-
for (const item of value) {
|
|
10244
|
-
walkValue(item, transferrables, isTransferrable);
|
|
10245
|
-
}
|
|
10246
|
-
return;
|
|
10247
|
-
}
|
|
10248
|
-
if (typeof value === 'object') {
|
|
10249
|
-
for (const property of Object.values(value)) {
|
|
10250
|
-
walkValue(property, transferrables, isTransferrable);
|
|
10251
|
-
}
|
|
10252
|
-
return;
|
|
10253
|
-
}
|
|
10254
|
-
};
|
|
10255
10197
|
const isMessagePort = value => {
|
|
10256
10198
|
return value && value instanceof MessagePort;
|
|
10257
10199
|
};
|
|
@@ -10276,126 +10218,88 @@ const isTransferrable = value => {
|
|
|
10276
10218
|
}
|
|
10277
10219
|
return false;
|
|
10278
10220
|
};
|
|
10279
|
-
const
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
return transferrables;
|
|
10283
|
-
};
|
|
10284
|
-
const listen$3 = ({
|
|
10285
|
-
port
|
|
10286
|
-
}) => {
|
|
10287
|
-
return port;
|
|
10288
|
-
};
|
|
10289
|
-
const signal$3 = port => {
|
|
10290
|
-
port.postMessage(readyMessage);
|
|
10291
|
-
};
|
|
10292
|
-
class IpcChildWithMessagePort extends Ipc {
|
|
10293
|
-
constructor(port) {
|
|
10294
|
-
super(port);
|
|
10295
|
-
}
|
|
10296
|
-
getData(event) {
|
|
10297
|
-
return getData$1(event);
|
|
10298
|
-
}
|
|
10299
|
-
send(message) {
|
|
10300
|
-
this._rawIpc.postMessage(message);
|
|
10301
|
-
}
|
|
10302
|
-
sendAndTransfer(message) {
|
|
10303
|
-
const transfer = getTransferrables(message);
|
|
10304
|
-
this._rawIpc.postMessage(message, transfer);
|
|
10221
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
10222
|
+
if (!value) {
|
|
10223
|
+
return;
|
|
10305
10224
|
}
|
|
10306
|
-
|
|
10307
|
-
|
|
10225
|
+
if (isTransferrable(value)) {
|
|
10226
|
+
transferrables.push(value);
|
|
10227
|
+
return;
|
|
10308
10228
|
}
|
|
10309
|
-
|
|
10310
|
-
|
|
10229
|
+
if (Array.isArray(value)) {
|
|
10230
|
+
for (const item of value) {
|
|
10231
|
+
walkValue(item, transferrables, isTransferrable);
|
|
10232
|
+
}
|
|
10233
|
+
return;
|
|
10311
10234
|
}
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10235
|
+
if (typeof value === 'object') {
|
|
10236
|
+
for (const property of Object.values(value)) {
|
|
10237
|
+
walkValue(property, transferrables, isTransferrable);
|
|
10238
|
+
}
|
|
10239
|
+
return;
|
|
10315
10240
|
}
|
|
10316
|
-
}
|
|
10317
|
-
const wrap$6 = port => {
|
|
10318
|
-
return new IpcChildWithMessagePort(port);
|
|
10319
10241
|
};
|
|
10320
|
-
const
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
wrap: wrap$6
|
|
10325
|
-
};
|
|
10326
|
-
const listen$2 = () => {
|
|
10327
|
-
// @ts-ignore
|
|
10328
|
-
if (typeof WorkerGlobalScope === 'undefined') {
|
|
10329
|
-
throw new TypeError('module is not in web worker scope');
|
|
10330
|
-
}
|
|
10331
|
-
return globalThis;
|
|
10242
|
+
const getTransferrables = value => {
|
|
10243
|
+
const transferrables = [];
|
|
10244
|
+
walkValue(value, transferrables, isTransferrable);
|
|
10245
|
+
return transferrables;
|
|
10332
10246
|
};
|
|
10333
|
-
const
|
|
10334
|
-
|
|
10247
|
+
const attachEvents = that => {
|
|
10248
|
+
const handleMessage = (...args) => {
|
|
10249
|
+
const data = that.getData(...args);
|
|
10250
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
10251
|
+
data
|
|
10252
|
+
}));
|
|
10253
|
+
};
|
|
10254
|
+
that.onMessage(handleMessage);
|
|
10255
|
+
const handleClose = event => {
|
|
10256
|
+
that.dispatchEvent(new Event('close'));
|
|
10257
|
+
};
|
|
10258
|
+
that.onClose(handleClose);
|
|
10335
10259
|
};
|
|
10336
|
-
class
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
// @ts-ignore
|
|
10342
|
-
this._rawIpc.postMessage(message);
|
|
10343
|
-
}
|
|
10344
|
-
sendAndTransfer(message) {
|
|
10345
|
-
const transfer = getTransferrables(message);
|
|
10346
|
-
// @ts-ignore
|
|
10347
|
-
this._rawIpc.postMessage(message, transfer);
|
|
10348
|
-
}
|
|
10349
|
-
dispose() {
|
|
10350
|
-
// ignore
|
|
10351
|
-
}
|
|
10352
|
-
onClose(callback) {
|
|
10353
|
-
// ignore
|
|
10354
|
-
}
|
|
10355
|
-
onMessage(callback) {
|
|
10356
|
-
this._rawIpc.addEventListener('message', callback);
|
|
10260
|
+
class Ipc extends EventTarget {
|
|
10261
|
+
constructor(rawIpc) {
|
|
10262
|
+
super();
|
|
10263
|
+
this._rawIpc = rawIpc;
|
|
10264
|
+
attachEvents(this);
|
|
10357
10265
|
}
|
|
10358
10266
|
}
|
|
10359
|
-
const wrap$5 = global => {
|
|
10360
|
-
return new IpcChildWithModuleWorker(global);
|
|
10361
|
-
};
|
|
10362
|
-
const IpcChildWithModuleWorker$1 = {
|
|
10363
|
-
__proto__: null,
|
|
10364
|
-
listen: listen$2,
|
|
10365
|
-
signal: signal$2,
|
|
10366
|
-
wrap: wrap$5
|
|
10367
|
-
};
|
|
10368
10267
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
10369
10268
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
10370
10269
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
10371
|
-
const NewLine
|
|
10270
|
+
const NewLine = '\n';
|
|
10372
10271
|
const joinLines = lines => {
|
|
10373
|
-
return lines.join(NewLine
|
|
10272
|
+
return lines.join(NewLine);
|
|
10374
10273
|
};
|
|
10375
|
-
const
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
10274
|
+
const RE_AT = /^\s+at/;
|
|
10275
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
10276
|
+
const isNormalStackLine = line => {
|
|
10277
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
10380
10278
|
};
|
|
10381
|
-
const
|
|
10382
|
-
const
|
|
10383
|
-
|
|
10384
|
-
|
|
10279
|
+
const getDetails = lines => {
|
|
10280
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
10281
|
+
if (index === -1) {
|
|
10282
|
+
return {
|
|
10283
|
+
actualMessage: joinLines(lines),
|
|
10284
|
+
rest: []
|
|
10285
|
+
};
|
|
10286
|
+
}
|
|
10287
|
+
let lastIndex = index - 1;
|
|
10288
|
+
while (++lastIndex < lines.length) {
|
|
10289
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
10290
|
+
break;
|
|
10291
|
+
}
|
|
10292
|
+
}
|
|
10385
10293
|
return {
|
|
10386
|
-
|
|
10387
|
-
|
|
10294
|
+
actualMessage: lines[index - 1],
|
|
10295
|
+
rest: lines.slice(index, lastIndex)
|
|
10388
10296
|
};
|
|
10389
10297
|
};
|
|
10390
|
-
const
|
|
10391
|
-
|
|
10298
|
+
const splitLines = lines => {
|
|
10299
|
+
return lines.split(NewLine);
|
|
10300
|
+
};
|
|
10392
10301
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
10393
10302
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
10394
|
-
const RE_AT = /^\s+at/;
|
|
10395
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
10396
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
10397
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
10398
|
-
};
|
|
10399
10303
|
const isMessageCodeBlockStartIndex = line => {
|
|
10400
10304
|
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
10401
10305
|
};
|
|
@@ -10410,51 +10314,46 @@ const getMessageCodeBlock = stderr => {
|
|
|
10410
10314
|
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
10411
10315
|
return relevantMessage;
|
|
10412
10316
|
};
|
|
10413
|
-
const
|
|
10414
|
-
|
|
10317
|
+
const isModuleNotFoundMessage = line => {
|
|
10318
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
10319
|
+
};
|
|
10320
|
+
const getModuleNotFoundError = stderr => {
|
|
10321
|
+
const lines = splitLines(stderr);
|
|
10322
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
10323
|
+
const message = lines[messageIndex];
|
|
10415
10324
|
return {
|
|
10416
|
-
message
|
|
10417
|
-
code:
|
|
10325
|
+
message,
|
|
10326
|
+
code: ERR_MODULE_NOT_FOUND
|
|
10418
10327
|
};
|
|
10419
10328
|
};
|
|
10420
|
-
const
|
|
10329
|
+
const isModuleNotFoundError = stderr => {
|
|
10421
10330
|
if (!stderr) {
|
|
10422
10331
|
return false;
|
|
10423
10332
|
}
|
|
10424
|
-
return stderr.includes('
|
|
10425
|
-
};
|
|
10426
|
-
const getModuleSyntaxError = () => {
|
|
10427
|
-
return {
|
|
10428
|
-
message: `ES Modules are not supported in electron`,
|
|
10429
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
10430
|
-
};
|
|
10333
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
10431
10334
|
};
|
|
10432
|
-
const
|
|
10335
|
+
const isModulesSyntaxError = stderr => {
|
|
10433
10336
|
if (!stderr) {
|
|
10434
10337
|
return false;
|
|
10435
10338
|
}
|
|
10436
|
-
return stderr.includes('
|
|
10339
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
10437
10340
|
};
|
|
10438
|
-
const
|
|
10439
|
-
|
|
10341
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
10342
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
10343
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
10344
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
10440
10345
|
};
|
|
10441
|
-
const
|
|
10442
|
-
const
|
|
10443
|
-
if (index === -1) {
|
|
10444
|
-
return {
|
|
10445
|
-
actualMessage: joinLines(lines),
|
|
10446
|
-
rest: []
|
|
10447
|
-
};
|
|
10448
|
-
}
|
|
10449
|
-
let lastIndex = index - 1;
|
|
10450
|
-
while (++lastIndex < lines.length) {
|
|
10451
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
10452
|
-
break;
|
|
10453
|
-
}
|
|
10454
|
-
}
|
|
10346
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
10347
|
+
const message = getMessageCodeBlock(stderr);
|
|
10455
10348
|
return {
|
|
10456
|
-
|
|
10457
|
-
|
|
10349
|
+
message: `Incompatible native node module: ${message}`,
|
|
10350
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
10351
|
+
};
|
|
10352
|
+
};
|
|
10353
|
+
const getModuleSyntaxError = () => {
|
|
10354
|
+
return {
|
|
10355
|
+
message: `ES Modules are not supported in electron`,
|
|
10356
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
10458
10357
|
};
|
|
10459
10358
|
};
|
|
10460
10359
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -10473,66 +10372,11 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
10473
10372
|
rest
|
|
10474
10373
|
} = getDetails(lines);
|
|
10475
10374
|
return {
|
|
10476
|
-
message:
|
|
10375
|
+
message: actualMessage,
|
|
10477
10376
|
code: '',
|
|
10478
10377
|
stack: rest
|
|
10479
10378
|
};
|
|
10480
10379
|
};
|
|
10481
|
-
const normalizeLine = line => {
|
|
10482
|
-
if (line.startsWith('Error: ')) {
|
|
10483
|
-
return line.slice('Error: '.length);
|
|
10484
|
-
}
|
|
10485
|
-
if (line.startsWith('VError: ')) {
|
|
10486
|
-
return line.slice('VError: '.length);
|
|
10487
|
-
}
|
|
10488
|
-
return line;
|
|
10489
|
-
};
|
|
10490
|
-
const getCombinedMessage = (error, message) => {
|
|
10491
|
-
const stringifiedError = normalizeLine(`${error}`);
|
|
10492
|
-
if (message) {
|
|
10493
|
-
return `${message}: ${stringifiedError}`;
|
|
10494
|
-
}
|
|
10495
|
-
return stringifiedError;
|
|
10496
|
-
};
|
|
10497
|
-
const NewLine = '\n';
|
|
10498
|
-
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
10499
|
-
return string.indexOf(NewLine, startIndex);
|
|
10500
|
-
};
|
|
10501
|
-
const mergeStacks = (parent, child) => {
|
|
10502
|
-
if (!child) {
|
|
10503
|
-
return parent;
|
|
10504
|
-
}
|
|
10505
|
-
const parentNewLineIndex = getNewLineIndex(parent);
|
|
10506
|
-
const childNewLineIndex = getNewLineIndex(child);
|
|
10507
|
-
if (childNewLineIndex === -1) {
|
|
10508
|
-
return parent;
|
|
10509
|
-
}
|
|
10510
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
10511
|
-
const childRest = child.slice(childNewLineIndex);
|
|
10512
|
-
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
10513
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
10514
|
-
return parentFirstLine + childRest;
|
|
10515
|
-
}
|
|
10516
|
-
return child;
|
|
10517
|
-
};
|
|
10518
|
-
class VError extends Error {
|
|
10519
|
-
constructor(error, message) {
|
|
10520
|
-
const combinedMessage = getCombinedMessage(error, message);
|
|
10521
|
-
super(combinedMessage);
|
|
10522
|
-
this.name = 'VError';
|
|
10523
|
-
if (error instanceof Error) {
|
|
10524
|
-
this.stack = mergeStacks(this.stack, error.stack);
|
|
10525
|
-
}
|
|
10526
|
-
if (error.codeFrame) {
|
|
10527
|
-
// @ts-ignore
|
|
10528
|
-
this.codeFrame = error.codeFrame;
|
|
10529
|
-
}
|
|
10530
|
-
if (error.code) {
|
|
10531
|
-
// @ts-ignore
|
|
10532
|
-
this.code = error.code;
|
|
10533
|
-
}
|
|
10534
|
-
}
|
|
10535
|
-
}
|
|
10536
10380
|
class IpcError extends VError {
|
|
10537
10381
|
// @ts-ignore
|
|
10538
10382
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
@@ -10559,12 +10403,98 @@ class IpcError extends VError {
|
|
|
10559
10403
|
this.stderr = stderr;
|
|
10560
10404
|
}
|
|
10561
10405
|
}
|
|
10406
|
+
const readyMessage = 'ready';
|
|
10407
|
+
const getData$2 = event => {
|
|
10408
|
+
return event.data;
|
|
10409
|
+
};
|
|
10410
|
+
const listen$8 = ({
|
|
10411
|
+
port
|
|
10412
|
+
}) => {
|
|
10413
|
+
return port;
|
|
10414
|
+
};
|
|
10415
|
+
const signal$9 = port => {
|
|
10416
|
+
port.postMessage(readyMessage);
|
|
10417
|
+
};
|
|
10418
|
+
class IpcChildWithMessagePort extends Ipc {
|
|
10419
|
+
getData(event) {
|
|
10420
|
+
return getData$2(event);
|
|
10421
|
+
}
|
|
10422
|
+
send(message) {
|
|
10423
|
+
this._rawIpc.postMessage(message);
|
|
10424
|
+
}
|
|
10425
|
+
sendAndTransfer(message) {
|
|
10426
|
+
const transfer = getTransferrables(message);
|
|
10427
|
+
this._rawIpc.postMessage(message, transfer);
|
|
10428
|
+
}
|
|
10429
|
+
dispose() {
|
|
10430
|
+
// ignore
|
|
10431
|
+
}
|
|
10432
|
+
onClose(callback) {
|
|
10433
|
+
// ignore
|
|
10434
|
+
}
|
|
10435
|
+
onMessage(callback) {
|
|
10436
|
+
this._rawIpc.addEventListener('message', callback);
|
|
10437
|
+
this._rawIpc.start();
|
|
10438
|
+
}
|
|
10439
|
+
}
|
|
10440
|
+
const wrap$g = port => {
|
|
10441
|
+
return new IpcChildWithMessagePort(port);
|
|
10442
|
+
};
|
|
10443
|
+
const IpcChildWithMessagePort$1 = {
|
|
10444
|
+
__proto__: null,
|
|
10445
|
+
listen: listen$8,
|
|
10446
|
+
signal: signal$9,
|
|
10447
|
+
wrap: wrap$g
|
|
10448
|
+
};
|
|
10449
|
+
const listen$7 = () => {
|
|
10450
|
+
// @ts-ignore
|
|
10451
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
10452
|
+
throw new TypeError('module is not in web worker scope');
|
|
10453
|
+
}
|
|
10454
|
+
return globalThis;
|
|
10455
|
+
};
|
|
10456
|
+
const signal$8 = global => {
|
|
10457
|
+
global.postMessage(readyMessage);
|
|
10458
|
+
};
|
|
10459
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
10460
|
+
getData(event) {
|
|
10461
|
+
return getData$2(event);
|
|
10462
|
+
}
|
|
10463
|
+
send(message) {
|
|
10464
|
+
// @ts-ignore
|
|
10465
|
+
this._rawIpc.postMessage(message);
|
|
10466
|
+
}
|
|
10467
|
+
sendAndTransfer(message) {
|
|
10468
|
+
const transfer = getTransferrables(message);
|
|
10469
|
+
// @ts-ignore
|
|
10470
|
+
this._rawIpc.postMessage(message, transfer);
|
|
10471
|
+
}
|
|
10472
|
+
dispose() {
|
|
10473
|
+
// ignore
|
|
10474
|
+
}
|
|
10475
|
+
onClose(callback) {
|
|
10476
|
+
// ignore
|
|
10477
|
+
}
|
|
10478
|
+
onMessage(callback) {
|
|
10479
|
+
this._rawIpc.addEventListener('message', callback);
|
|
10480
|
+
}
|
|
10481
|
+
}
|
|
10482
|
+
const wrap$f = global => {
|
|
10483
|
+
return new IpcChildWithModuleWorker(global);
|
|
10484
|
+
};
|
|
10485
|
+
const IpcChildWithModuleWorker$1 = {
|
|
10486
|
+
__proto__: null,
|
|
10487
|
+
listen: listen$7,
|
|
10488
|
+
signal: signal$8,
|
|
10489
|
+
wrap: wrap$f
|
|
10490
|
+
};
|
|
10562
10491
|
const withResolvers = () => {
|
|
10563
10492
|
let _resolve;
|
|
10564
10493
|
const promise = new Promise(resolve => {
|
|
10565
10494
|
_resolve = resolve;
|
|
10566
10495
|
});
|
|
10567
10496
|
return {
|
|
10497
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10568
10498
|
resolve: _resolve,
|
|
10569
10499
|
promise
|
|
10570
10500
|
};
|
|
@@ -10581,10 +10511,10 @@ const waitForFirstMessage = async port => {
|
|
|
10581
10511
|
// @ts-ignore
|
|
10582
10512
|
return event.data;
|
|
10583
10513
|
};
|
|
10584
|
-
const listen$
|
|
10585
|
-
const parentIpcRaw = listen$
|
|
10586
|
-
signal$
|
|
10587
|
-
const parentIpc = wrap$
|
|
10514
|
+
const listen$6 = async () => {
|
|
10515
|
+
const parentIpcRaw = listen$7();
|
|
10516
|
+
signal$8(parentIpcRaw);
|
|
10517
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
10588
10518
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
10589
10519
|
if (firstMessage.method !== 'initialize') {
|
|
10590
10520
|
throw new IpcError('unexpected first message');
|
|
@@ -10603,11 +10533,8 @@ const listen$1$1 = async () => {
|
|
|
10603
10533
|
return globalThis;
|
|
10604
10534
|
};
|
|
10605
10535
|
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
10606
|
-
constructor(port) {
|
|
10607
|
-
super(port);
|
|
10608
|
-
}
|
|
10609
10536
|
getData(event) {
|
|
10610
|
-
return getData$
|
|
10537
|
+
return getData$2(event);
|
|
10611
10538
|
}
|
|
10612
10539
|
send(message) {
|
|
10613
10540
|
this._rawIpc.postMessage(message);
|
|
@@ -10629,13 +10556,29 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
10629
10556
|
this._rawIpc.start();
|
|
10630
10557
|
}
|
|
10631
10558
|
}
|
|
10632
|
-
const wrap$
|
|
10559
|
+
const wrap$e = port => {
|
|
10633
10560
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
10634
10561
|
};
|
|
10635
10562
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
10636
10563
|
__proto__: null,
|
|
10637
|
-
listen: listen$
|
|
10638
|
-
wrap: wrap$
|
|
10564
|
+
listen: listen$6,
|
|
10565
|
+
wrap: wrap$e
|
|
10566
|
+
};
|
|
10567
|
+
|
|
10568
|
+
const MessagePort$1 = 1;
|
|
10569
|
+
const ModuleWorker = 2;
|
|
10570
|
+
const ReferencePort = 3;
|
|
10571
|
+
const ModuleWorkerAndMessagePort = 8;
|
|
10572
|
+
const Auto = () => {
|
|
10573
|
+
// @ts-ignore
|
|
10574
|
+
if (globalThis.acceptPort) {
|
|
10575
|
+
return MessagePort$1;
|
|
10576
|
+
}
|
|
10577
|
+
// @ts-ignore
|
|
10578
|
+
if (globalThis.acceptReferencePort) {
|
|
10579
|
+
return ReferencePort;
|
|
10580
|
+
}
|
|
10581
|
+
return ModuleWorkerAndMessagePort;
|
|
10639
10582
|
};
|
|
10640
10583
|
|
|
10641
10584
|
const getModule = method => {
|
|
@@ -10656,12 +10599,14 @@ const listen$1 = async ({
|
|
|
10656
10599
|
method
|
|
10657
10600
|
}) => {
|
|
10658
10601
|
const module = await getModule(method);
|
|
10602
|
+
// @ts-ignore
|
|
10659
10603
|
const rawIpc = await module.listen();
|
|
10660
10604
|
// @ts-ignore
|
|
10661
10605
|
if (module.signal) {
|
|
10662
10606
|
// @ts-ignore
|
|
10663
10607
|
module.signal(rawIpc);
|
|
10664
10608
|
}
|
|
10609
|
+
// @ts-ignore
|
|
10665
10610
|
const ipc = module.wrap(rawIpc);
|
|
10666
10611
|
return ipc;
|
|
10667
10612
|
};
|
|
@@ -10672,7 +10617,7 @@ const listen = async () => {
|
|
|
10672
10617
|
method: Auto()
|
|
10673
10618
|
});
|
|
10674
10619
|
handleIpc(ipc);
|
|
10675
|
-
listen$
|
|
10620
|
+
listen$5(ipc);
|
|
10676
10621
|
};
|
|
10677
10622
|
|
|
10678
10623
|
const addWidget = (widget, id, render) => {
|