@lvce-editor/editor-worker 4.10.0 → 4.12.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 +159 -85
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -24,7 +24,7 @@ let AssertionError$1 = class AssertionError extends Error {
|
|
|
24
24
|
this.name = 'AssertionError';
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
const getType$
|
|
27
|
+
const getType$1 = value => {
|
|
28
28
|
switch (typeof value) {
|
|
29
29
|
case 'number':
|
|
30
30
|
return 'number';
|
|
@@ -47,31 +47,31 @@ const getType$2 = value => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const object = value => {
|
|
50
|
-
const type = getType$
|
|
50
|
+
const type = getType$1(value);
|
|
51
51
|
if (type !== 'object') {
|
|
52
52
|
throw new AssertionError$1('expected value to be of type object');
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
const number$1 = value => {
|
|
56
|
-
const type = getType$
|
|
56
|
+
const type = getType$1(value);
|
|
57
57
|
if (type !== 'number') {
|
|
58
58
|
throw new AssertionError$1('expected value to be of type number');
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
const array = value => {
|
|
62
|
-
const type = getType$
|
|
62
|
+
const type = getType$1(value);
|
|
63
63
|
if (type !== 'array') {
|
|
64
64
|
throw new AssertionError$1('expected value to be of type array');
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
const string = value => {
|
|
68
|
-
const type = getType$
|
|
68
|
+
const type = getType$1(value);
|
|
69
69
|
if (type !== 'string') {
|
|
70
70
|
throw new AssertionError$1('expected value to be of type string');
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
const boolean = value => {
|
|
74
|
-
const type = getType$
|
|
74
|
+
const type = getType$1(value);
|
|
75
75
|
if (type !== 'boolean') {
|
|
76
76
|
throw new AssertionError$1('expected value to be of type boolean');
|
|
77
77
|
}
|
|
@@ -1048,7 +1048,7 @@ class AssertionError extends Error {
|
|
|
1048
1048
|
this.name = 'AssertionError';
|
|
1049
1049
|
}
|
|
1050
1050
|
}
|
|
1051
|
-
const getType
|
|
1051
|
+
const getType = value => {
|
|
1052
1052
|
switch (typeof value) {
|
|
1053
1053
|
case 'number':
|
|
1054
1054
|
return 'number';
|
|
@@ -1071,7 +1071,7 @@ const getType$1 = value => {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
};
|
|
1073
1073
|
const number = value => {
|
|
1074
|
-
const type = getType
|
|
1074
|
+
const type = getType(value);
|
|
1075
1075
|
if (type !== 'number') {
|
|
1076
1076
|
throw new AssertionError('expected value to be of type number');
|
|
1077
1077
|
}
|
|
@@ -1085,7 +1085,7 @@ const set$5 = (id, fn) => {
|
|
|
1085
1085
|
const get$5 = id => {
|
|
1086
1086
|
return state$1$1.callbacks[id];
|
|
1087
1087
|
};
|
|
1088
|
-
const remove$
|
|
1088
|
+
const remove$8 = id => {
|
|
1089
1089
|
delete state$1$1.callbacks[id];
|
|
1090
1090
|
};
|
|
1091
1091
|
const state$9 = {
|
|
@@ -1097,25 +1097,12 @@ const create$3$1 = () => {
|
|
|
1097
1097
|
const warn$1 = (...args) => {
|
|
1098
1098
|
console.warn(...args);
|
|
1099
1099
|
};
|
|
1100
|
-
const withResolvers$2 = () => {
|
|
1101
|
-
/**
|
|
1102
|
-
* @type {any}
|
|
1103
|
-
*/
|
|
1104
|
-
let _resolve;
|
|
1105
|
-
const promise = new Promise(resolve => {
|
|
1106
|
-
_resolve = resolve;
|
|
1107
|
-
});
|
|
1108
|
-
return {
|
|
1109
|
-
resolve: _resolve,
|
|
1110
|
-
promise
|
|
1111
|
-
};
|
|
1112
|
-
};
|
|
1113
1100
|
const registerPromise = () => {
|
|
1114
1101
|
const id = create$3$1();
|
|
1115
1102
|
const {
|
|
1116
1103
|
resolve,
|
|
1117
1104
|
promise
|
|
1118
|
-
} = withResolvers
|
|
1105
|
+
} = Promise.withResolvers();
|
|
1119
1106
|
set$5(id, resolve);
|
|
1120
1107
|
return {
|
|
1121
1108
|
id,
|
|
@@ -1131,7 +1118,7 @@ const resolve = (id, args) => {
|
|
|
1131
1118
|
return;
|
|
1132
1119
|
}
|
|
1133
1120
|
fn(args);
|
|
1134
|
-
remove$
|
|
1121
|
+
remove$8(id);
|
|
1135
1122
|
};
|
|
1136
1123
|
const create$2$1 = (method, params) => {
|
|
1137
1124
|
const {
|
|
@@ -1281,7 +1268,7 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
1281
1268
|
throw new JsonRpcError('unexpected response message');
|
|
1282
1269
|
};
|
|
1283
1270
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1284
|
-
const
|
|
1271
|
+
const getErrorType = prettyError => {
|
|
1285
1272
|
if (prettyError && prettyError.type) {
|
|
1286
1273
|
return prettyError.type;
|
|
1287
1274
|
}
|
|
@@ -1304,7 +1291,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1304
1291
|
data: {
|
|
1305
1292
|
stack: prettyError.stack,
|
|
1306
1293
|
codeFrame: prettyError.codeFrame,
|
|
1307
|
-
type:
|
|
1294
|
+
type: getErrorType(prettyError),
|
|
1308
1295
|
code: prettyError.code,
|
|
1309
1296
|
name: prettyError.name
|
|
1310
1297
|
}
|
|
@@ -1323,7 +1310,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
1323
1310
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1324
1311
|
return create$1$1(message, errorProperty);
|
|
1325
1312
|
};
|
|
1326
|
-
const create$
|
|
1313
|
+
const create$e = (message, result) => {
|
|
1327
1314
|
return {
|
|
1328
1315
|
jsonrpc: Two,
|
|
1329
1316
|
id: message.id,
|
|
@@ -1332,7 +1319,7 @@ const create$d = (message, result) => {
|
|
|
1332
1319
|
};
|
|
1333
1320
|
const getSuccessResponse = (message, result) => {
|
|
1334
1321
|
const resultProperty = result ?? null;
|
|
1335
|
-
return create$
|
|
1322
|
+
return create$e(message, resultProperty);
|
|
1336
1323
|
};
|
|
1337
1324
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1338
1325
|
try {
|
|
@@ -1532,7 +1519,7 @@ const waitForFirstMessage$1 = async port => {
|
|
|
1532
1519
|
return event;
|
|
1533
1520
|
};
|
|
1534
1521
|
|
|
1535
|
-
const create$
|
|
1522
|
+
const create$d = async () => {
|
|
1536
1523
|
const {
|
|
1537
1524
|
port1,
|
|
1538
1525
|
port2
|
|
@@ -1577,7 +1564,7 @@ const wrap$3 = port => {
|
|
|
1577
1564
|
|
|
1578
1565
|
const IpcParentWithExtensionHostWorker = {
|
|
1579
1566
|
__proto__: null,
|
|
1580
|
-
create: create$
|
|
1567
|
+
create: create$d,
|
|
1581
1568
|
wrap: wrap$3
|
|
1582
1569
|
};
|
|
1583
1570
|
|
|
@@ -1585,7 +1572,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
|
1585
1572
|
await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
1586
1573
|
};
|
|
1587
1574
|
|
|
1588
|
-
const create$
|
|
1575
|
+
const create$c = async () => {
|
|
1589
1576
|
const {
|
|
1590
1577
|
port1,
|
|
1591
1578
|
port2
|
|
@@ -1630,7 +1617,7 @@ const wrap$1 = port => {
|
|
|
1630
1617
|
|
|
1631
1618
|
const IpcParentWithSyntaxHighlightingWorker = {
|
|
1632
1619
|
__proto__: null,
|
|
1633
|
-
create: create$
|
|
1620
|
+
create: create$c,
|
|
1634
1621
|
wrap: wrap$1
|
|
1635
1622
|
};
|
|
1636
1623
|
|
|
@@ -1638,7 +1625,7 @@ const sendMessagePortToRendererProcess = async port => {
|
|
|
1638
1625
|
await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
|
|
1639
1626
|
};
|
|
1640
1627
|
|
|
1641
|
-
const create$
|
|
1628
|
+
const create$b = async () => {
|
|
1642
1629
|
const {
|
|
1643
1630
|
port1,
|
|
1644
1631
|
port2
|
|
@@ -1683,7 +1670,7 @@ const wrap = port => {
|
|
|
1683
1670
|
|
|
1684
1671
|
const IpcParentWithRendererProcess = {
|
|
1685
1672
|
__proto__: null,
|
|
1686
|
-
create: create$
|
|
1673
|
+
create: create$b,
|
|
1687
1674
|
wrap
|
|
1688
1675
|
};
|
|
1689
1676
|
|
|
@@ -1700,7 +1687,7 @@ const getModule$1 = method => {
|
|
|
1700
1687
|
}
|
|
1701
1688
|
};
|
|
1702
1689
|
|
|
1703
|
-
const create$
|
|
1690
|
+
const create$a = async ({
|
|
1704
1691
|
method,
|
|
1705
1692
|
...options
|
|
1706
1693
|
}) => {
|
|
@@ -1718,7 +1705,7 @@ const create$9 = async ({
|
|
|
1718
1705
|
const createRpc = method => {
|
|
1719
1706
|
let _ipc;
|
|
1720
1707
|
const listen = async () => {
|
|
1721
|
-
const ipc = await create$
|
|
1708
|
+
const ipc = await create$a({
|
|
1722
1709
|
method
|
|
1723
1710
|
});
|
|
1724
1711
|
handleIpc(ipc);
|
|
@@ -1760,6 +1747,7 @@ const FocusFindWidgetReplaceAllButton = 47;
|
|
|
1760
1747
|
const FocusFindWidgetReplaceButton = 46;
|
|
1761
1748
|
const FocusFindWidgetToggleReplace = 42;
|
|
1762
1749
|
const SourceActions = 38;
|
|
1750
|
+
const FocusCodeGenerator = 52;
|
|
1763
1751
|
|
|
1764
1752
|
const measureCharacterWidth = (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
1765
1753
|
return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
|
|
@@ -2012,7 +2000,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
|
|
|
2012
2000
|
const supported = () => {
|
|
2013
2001
|
return 'Segmenter' in Intl;
|
|
2014
2002
|
};
|
|
2015
|
-
const create$
|
|
2003
|
+
const create$9 = () => {
|
|
2016
2004
|
// @ts-ignore
|
|
2017
2005
|
const segmenter = new Intl.Segmenter();
|
|
2018
2006
|
return {
|
|
@@ -2050,7 +2038,7 @@ const create$8 = () => {
|
|
|
2050
2038
|
|
|
2051
2039
|
// @ts-ignore
|
|
2052
2040
|
const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
2053
|
-
const segmenter = create$
|
|
2041
|
+
const segmenter = create$9();
|
|
2054
2042
|
const segments = segmenter.getSegments(line);
|
|
2055
2043
|
const isMonospaceFont = false;
|
|
2056
2044
|
const charWidth = 0;
|
|
@@ -2295,13 +2283,14 @@ const removeEditorWidget = (widgets, id) => {
|
|
|
2295
2283
|
};
|
|
2296
2284
|
|
|
2297
2285
|
// TODO use numeric widget id
|
|
2298
|
-
const
|
|
2299
|
-
const
|
|
2300
|
-
const
|
|
2301
|
-
const
|
|
2302
|
-
const
|
|
2303
|
-
const
|
|
2304
|
-
const
|
|
2286
|
+
const CodeGenerator = 1;
|
|
2287
|
+
const ColorPicker$1 = 2;
|
|
2288
|
+
const Completion = 3;
|
|
2289
|
+
const CompletionDetail = 4;
|
|
2290
|
+
const Find = 5;
|
|
2291
|
+
const Hover = 6;
|
|
2292
|
+
const Rename = 7;
|
|
2293
|
+
const SourceAction = 8;
|
|
2305
2294
|
|
|
2306
2295
|
const isCompletionWidget = widget => {
|
|
2307
2296
|
return widget.id === Completion;
|
|
@@ -2321,14 +2310,14 @@ const closeCompletion = editor => {
|
|
|
2321
2310
|
};
|
|
2322
2311
|
};
|
|
2323
2312
|
|
|
2324
|
-
const isMatchingWidget$
|
|
2313
|
+
const isMatchingWidget$2 = widget => {
|
|
2325
2314
|
return widget.id === Find;
|
|
2326
2315
|
};
|
|
2327
2316
|
const closeFind = editor => {
|
|
2328
2317
|
const {
|
|
2329
2318
|
widgets
|
|
2330
2319
|
} = editor;
|
|
2331
|
-
const index = widgets.findIndex(isMatchingWidget$
|
|
2320
|
+
const index = widgets.findIndex(isMatchingWidget$2);
|
|
2332
2321
|
if (index === -1) {
|
|
2333
2322
|
return editor;
|
|
2334
2323
|
}
|
|
@@ -2359,14 +2348,14 @@ const closeRename = editor => {
|
|
|
2359
2348
|
};
|
|
2360
2349
|
};
|
|
2361
2350
|
|
|
2362
|
-
const isMatchingWidget = widget => {
|
|
2351
|
+
const isMatchingWidget$1 = widget => {
|
|
2363
2352
|
return widget.id === SourceAction;
|
|
2364
2353
|
};
|
|
2365
2354
|
const closeSourceAction = editor => {
|
|
2366
2355
|
const {
|
|
2367
2356
|
widgets
|
|
2368
2357
|
} = editor;
|
|
2369
|
-
const index = widgets.findIndex(isMatchingWidget);
|
|
2358
|
+
const index = widgets.findIndex(isMatchingWidget$1);
|
|
2370
2359
|
if (index === -1) {
|
|
2371
2360
|
return editor;
|
|
2372
2361
|
}
|
|
@@ -2431,12 +2420,12 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
2431
2420
|
return newEditor;
|
|
2432
2421
|
};
|
|
2433
2422
|
|
|
2434
|
-
const create$
|
|
2423
|
+
const create$8 = () => {
|
|
2435
2424
|
return Math.random();
|
|
2436
2425
|
};
|
|
2437
2426
|
|
|
2438
|
-
const create$
|
|
2439
|
-
const completionUid = create$
|
|
2427
|
+
const create$7 = () => {
|
|
2428
|
+
const completionUid = create$8();
|
|
2440
2429
|
const widget = {
|
|
2441
2430
|
id: ColorPicker$1,
|
|
2442
2431
|
oldState: {
|
|
@@ -2465,11 +2454,11 @@ const create$6 = () => {
|
|
|
2465
2454
|
return widget;
|
|
2466
2455
|
};
|
|
2467
2456
|
|
|
2468
|
-
const newStateGenerator$
|
|
2457
|
+
const newStateGenerator$2 = state => {
|
|
2469
2458
|
return loadContent$3(state);
|
|
2470
2459
|
};
|
|
2471
2460
|
const openColorPicker = async editor => {
|
|
2472
|
-
return addWidgetToEditor(ColorPicker$1, ColorPicker$2, editor, create$
|
|
2461
|
+
return addWidgetToEditor(ColorPicker$1, ColorPicker$2, editor, create$7, newStateGenerator$2);
|
|
2473
2462
|
};
|
|
2474
2463
|
|
|
2475
2464
|
const state$6 = {
|
|
@@ -2766,7 +2755,7 @@ const characterLeft = (line, columnIndex) => {
|
|
|
2766
2755
|
if (!supported()) {
|
|
2767
2756
|
return 1;
|
|
2768
2757
|
}
|
|
2769
|
-
const segmenter = create$
|
|
2758
|
+
const segmenter = create$9();
|
|
2770
2759
|
const last = segmenter.at(line, columnIndex - 1);
|
|
2771
2760
|
return columnIndex - last.index;
|
|
2772
2761
|
};
|
|
@@ -2777,7 +2766,7 @@ const characterRight = (line, columnIndex) => {
|
|
|
2777
2766
|
if (!supported()) {
|
|
2778
2767
|
return 1;
|
|
2779
2768
|
}
|
|
2780
|
-
const segmenter = create$
|
|
2769
|
+
const segmenter = create$9();
|
|
2781
2770
|
const next = segmenter.at(line, columnIndex);
|
|
2782
2771
|
return next.segment.length;
|
|
2783
2772
|
};
|
|
@@ -4528,8 +4517,8 @@ const moveSelectionPx = (editor, x, y) => {
|
|
|
4528
4517
|
return editorMoveSelection(editor, position);
|
|
4529
4518
|
};
|
|
4530
4519
|
|
|
4531
|
-
const create$
|
|
4532
|
-
const completionUid = create$
|
|
4520
|
+
const create$6 = () => {
|
|
4521
|
+
const completionUid = create$8();
|
|
4533
4522
|
const completionWidget = {
|
|
4534
4523
|
id: Completion,
|
|
4535
4524
|
oldState: {
|
|
@@ -5044,7 +5033,7 @@ const openCompletion = async editor => {
|
|
|
5044
5033
|
if (hasWidget(widgets, Completion)) {
|
|
5045
5034
|
return editor;
|
|
5046
5035
|
}
|
|
5047
|
-
const completionWidget = create$
|
|
5036
|
+
const completionWidget = create$6();
|
|
5048
5037
|
const newWidgets = [...widgets, completionWidget];
|
|
5049
5038
|
const newEditor = {
|
|
5050
5039
|
...editor,
|
|
@@ -5073,8 +5062,8 @@ const User = 1;
|
|
|
5073
5062
|
const Script = 2;
|
|
5074
5063
|
const Unknown$1 = 0;
|
|
5075
5064
|
|
|
5076
|
-
const create$
|
|
5077
|
-
const uid = create$
|
|
5065
|
+
const create$5 = () => {
|
|
5066
|
+
const uid = create$8();
|
|
5078
5067
|
const widget = {
|
|
5079
5068
|
id: Find,
|
|
5080
5069
|
oldState: {
|
|
@@ -5479,7 +5468,7 @@ const openFind2 = async editor => {
|
|
|
5479
5468
|
return latestState;
|
|
5480
5469
|
};
|
|
5481
5470
|
const fullFocus = true;
|
|
5482
|
-
return addWidgetToEditor(Find, FindWidget, editor, create$
|
|
5471
|
+
return addWidgetToEditor(Find, FindWidget, editor, create$5, newStateGenerator, fullFocus);
|
|
5483
5472
|
};
|
|
5484
5473
|
|
|
5485
5474
|
const openFind = async state => {
|
|
@@ -5501,8 +5490,8 @@ const getRenamePosition = editor => {
|
|
|
5501
5490
|
};
|
|
5502
5491
|
};
|
|
5503
5492
|
|
|
5504
|
-
const create$
|
|
5505
|
-
const completionUid = create$
|
|
5493
|
+
const create$4 = () => {
|
|
5494
|
+
const completionUid = create$8();
|
|
5506
5495
|
const renameWidget = {
|
|
5507
5496
|
id: Rename,
|
|
5508
5497
|
oldState: {
|
|
@@ -5562,7 +5551,7 @@ const openRename = async editor => {
|
|
|
5562
5551
|
return latestState;
|
|
5563
5552
|
};
|
|
5564
5553
|
const fullFocus = true;
|
|
5565
|
-
return addWidgetToEditor(Rename, FocusEditorRename, editor, create$
|
|
5554
|
+
return addWidgetToEditor(Rename, FocusEditorRename, editor, create$4, newStateGenerator, fullFocus);
|
|
5566
5555
|
};
|
|
5567
5556
|
|
|
5568
5557
|
const organizeImports = async editor => {
|
|
@@ -6450,8 +6439,8 @@ const showHover = async state => {
|
|
|
6450
6439
|
return state;
|
|
6451
6440
|
};
|
|
6452
6441
|
|
|
6453
|
-
const create$
|
|
6454
|
-
const uid = create$
|
|
6442
|
+
const create$3 = () => {
|
|
6443
|
+
const uid = create$8();
|
|
6455
6444
|
const widget = {
|
|
6456
6445
|
id: Hover,
|
|
6457
6446
|
oldState: {
|
|
@@ -6504,7 +6493,7 @@ const getHover = async (editor, offset) => {
|
|
|
6504
6493
|
|
|
6505
6494
|
let _ipc;
|
|
6506
6495
|
const listen$5 = async () => {
|
|
6507
|
-
const ipc = await create$
|
|
6496
|
+
const ipc = await create$a({
|
|
6508
6497
|
method: RendererProcess
|
|
6509
6498
|
});
|
|
6510
6499
|
handleIpc(ipc);
|
|
@@ -6716,11 +6705,11 @@ const loadHoverContent = async state => {
|
|
|
6716
6705
|
};
|
|
6717
6706
|
};
|
|
6718
6707
|
|
|
6719
|
-
const newStateGenerator = state => {
|
|
6708
|
+
const newStateGenerator$1 = state => {
|
|
6720
6709
|
return loadHoverContent(state);
|
|
6721
6710
|
};
|
|
6722
6711
|
const showHover2 = async editor => {
|
|
6723
|
-
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$
|
|
6712
|
+
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$3, newStateGenerator$1);
|
|
6724
6713
|
};
|
|
6725
6714
|
|
|
6726
6715
|
// TODO ask extension host worker instead
|
|
@@ -6773,8 +6762,8 @@ const loadSourceActions = async (editor, state) => {
|
|
|
6773
6762
|
};
|
|
6774
6763
|
};
|
|
6775
6764
|
|
|
6776
|
-
const create$
|
|
6777
|
-
const completionUid = create$
|
|
6765
|
+
const create$2 = () => {
|
|
6766
|
+
const completionUid = create$8();
|
|
6778
6767
|
const widget = {
|
|
6779
6768
|
id: SourceAction,
|
|
6780
6769
|
oldState: {
|
|
@@ -6805,7 +6794,7 @@ const showSourceActions = async editor => {
|
|
|
6805
6794
|
const newStateGenerator = state => {
|
|
6806
6795
|
return loadSourceActions(editor, state);
|
|
6807
6796
|
};
|
|
6808
|
-
return addWidgetToEditor(SourceAction, SourceActions, editor, create$
|
|
6797
|
+
return addWidgetToEditor(SourceAction, SourceActions, editor, create$2, newStateGenerator);
|
|
6809
6798
|
};
|
|
6810
6799
|
|
|
6811
6800
|
const compareString = (a, b) => {
|
|
@@ -7682,8 +7671,8 @@ const handelWheel = (state, deltaMode, deltaY) => {
|
|
|
7682
7671
|
return newState;
|
|
7683
7672
|
};
|
|
7684
7673
|
|
|
7685
|
-
const create = () => {
|
|
7686
|
-
const completionUid = create$
|
|
7674
|
+
const create$1 = () => {
|
|
7675
|
+
const completionUid = create$8();
|
|
7687
7676
|
const completionWidget = {
|
|
7688
7677
|
id: CompletionDetail,
|
|
7689
7678
|
oldState: {
|
|
@@ -7736,7 +7725,7 @@ const openDetails = editor => {
|
|
|
7736
7725
|
};
|
|
7737
7726
|
return newestState;
|
|
7738
7727
|
};
|
|
7739
|
-
return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create, newStateGenerator);
|
|
7728
|
+
return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create$1, newStateGenerator);
|
|
7740
7729
|
};
|
|
7741
7730
|
|
|
7742
7731
|
const getEdits = async (editor, completionItem) => {
|
|
@@ -8049,10 +8038,10 @@ const renderBounds$6 = {
|
|
|
8049
8038
|
return [SetBounds, x, y, renderWidth, height];
|
|
8050
8039
|
}
|
|
8051
8040
|
};
|
|
8052
|
-
const render$
|
|
8041
|
+
const render$f = [renderHoverDom, renderBounds$6];
|
|
8053
8042
|
const renderHover = (oldState, newState) => {
|
|
8054
8043
|
const commands = [];
|
|
8055
|
-
for (const item of render$
|
|
8044
|
+
for (const item of render$f) {
|
|
8056
8045
|
if (!item.isEqual(oldState, newState)) {
|
|
8057
8046
|
commands.push(item.apply(oldState, newState));
|
|
8058
8047
|
}
|
|
@@ -8346,6 +8335,33 @@ const moveLineDown = editor => {
|
|
|
8346
8335
|
undefined(editor, documentEdits, cursorEdits);
|
|
8347
8336
|
};
|
|
8348
8337
|
|
|
8338
|
+
const create = () => {
|
|
8339
|
+
const completionUid = create$8();
|
|
8340
|
+
const widget = {
|
|
8341
|
+
id: CodeGenerator,
|
|
8342
|
+
oldState: {
|
|
8343
|
+
uid: completionUid,
|
|
8344
|
+
questions: []
|
|
8345
|
+
},
|
|
8346
|
+
newState: {
|
|
8347
|
+
uid: completionUid,
|
|
8348
|
+
questions: []
|
|
8349
|
+
}
|
|
8350
|
+
};
|
|
8351
|
+
return widget;
|
|
8352
|
+
};
|
|
8353
|
+
|
|
8354
|
+
const newStateGenerator = async state => {
|
|
8355
|
+
const latestState = {
|
|
8356
|
+
...state
|
|
8357
|
+
};
|
|
8358
|
+
return latestState;
|
|
8359
|
+
};
|
|
8360
|
+
const openCodeGenerator = async editor => {
|
|
8361
|
+
const fullFocus = true;
|
|
8362
|
+
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create, newStateGenerator, fullFocus);
|
|
8363
|
+
};
|
|
8364
|
+
|
|
8349
8365
|
// TODO handle multiple cursors
|
|
8350
8366
|
const moveLineUp = editor => {
|
|
8351
8367
|
const rowIndex = editor.cursor.rowIndex;
|
|
@@ -9156,7 +9172,7 @@ const renderWidgets = {
|
|
|
9156
9172
|
},
|
|
9157
9173
|
multiple: true
|
|
9158
9174
|
};
|
|
9159
|
-
const render$
|
|
9175
|
+
const render$e = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$2, renderDecorations, renderGutterInfo, renderWidgets];
|
|
9160
9176
|
const renderEditor = async id => {
|
|
9161
9177
|
const instance = get$6(id);
|
|
9162
9178
|
if (!instance) {
|
|
@@ -9168,7 +9184,7 @@ const renderEditor = async id => {
|
|
|
9168
9184
|
} = instance;
|
|
9169
9185
|
const commands = [];
|
|
9170
9186
|
set$6(id, newState, newState);
|
|
9171
|
-
for (const item of render$
|
|
9187
|
+
for (const item of render$e) {
|
|
9172
9188
|
if (!item.isEqual(oldState, newState)) {
|
|
9173
9189
|
const result = await item.apply(oldState, newState);
|
|
9174
9190
|
// @ts-ignore
|
|
@@ -9182,6 +9198,24 @@ const renderEditor = async id => {
|
|
|
9182
9198
|
return commands;
|
|
9183
9199
|
};
|
|
9184
9200
|
|
|
9201
|
+
const isMatchingWidget = widget => {
|
|
9202
|
+
return widget.id === CodeGenerator;
|
|
9203
|
+
};
|
|
9204
|
+
const closeCodeGenerator = editor => {
|
|
9205
|
+
const {
|
|
9206
|
+
widgets
|
|
9207
|
+
} = editor;
|
|
9208
|
+
const index = widgets.findIndex(isMatchingWidget);
|
|
9209
|
+
if (index === -1) {
|
|
9210
|
+
return editor;
|
|
9211
|
+
}
|
|
9212
|
+
const newWidgets = removeEditorWidget(widgets, CodeGenerator);
|
|
9213
|
+
return {
|
|
9214
|
+
...editor,
|
|
9215
|
+
widgets: newWidgets
|
|
9216
|
+
};
|
|
9217
|
+
};
|
|
9218
|
+
|
|
9185
9219
|
const keep = [
|
|
9186
9220
|
// 'ColorPicker.handleSliderPointerDown',
|
|
9187
9221
|
// 'ColorPicker.handleSliderPointerMove',
|
|
@@ -9269,6 +9303,7 @@ const commandMap = {
|
|
|
9269
9303
|
'Editor.applyEdit': applyEdit,
|
|
9270
9304
|
'Editor.braceCompletion': braceCompletion,
|
|
9271
9305
|
'Editor.cancelSelection': cancelSelection,
|
|
9306
|
+
'Editor.closeCodeGenerator': closeCodeGenerator,
|
|
9272
9307
|
'Editor.closeCompletion': closeCompletion,
|
|
9273
9308
|
'Editor.closeFind': closeFind,
|
|
9274
9309
|
'Editor.closeRename': closeRename,
|
|
@@ -9349,6 +9384,7 @@ const commandMap = {
|
|
|
9349
9384
|
'Editor.moveSelection': editorMoveSelection,
|
|
9350
9385
|
'Editor.moveSelectionPx': moveSelectionPx,
|
|
9351
9386
|
'Editor.offsetAt': offsetAt,
|
|
9387
|
+
'Editor.openCodeGenerator': openCodeGenerator,
|
|
9352
9388
|
'Editor.openColorPicker': openColorPicker,
|
|
9353
9389
|
'Editor.openCompletion': openCompletion,
|
|
9354
9390
|
'Editor.openFind': openFind,
|
|
@@ -9958,6 +9994,48 @@ const addWidget = (widget, id, render) => {
|
|
|
9958
9994
|
return allCommands;
|
|
9959
9995
|
};
|
|
9960
9996
|
|
|
9997
|
+
const removeWidget = widget => {
|
|
9998
|
+
// @ts-ignore
|
|
9999
|
+
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
10000
|
+
};
|
|
10001
|
+
|
|
10002
|
+
const getCodeGeneratorVirtualDom = state => {
|
|
10003
|
+
return [{
|
|
10004
|
+
type: Div,
|
|
10005
|
+
className: 'Viewlet CodeGeneratorWidget',
|
|
10006
|
+
childCount: 0
|
|
10007
|
+
}];
|
|
10008
|
+
};
|
|
10009
|
+
const renderCodeGeneratorWidget = (oldState, newState) => {
|
|
10010
|
+
const dom = getCodeGeneratorVirtualDom();
|
|
10011
|
+
return dom;
|
|
10012
|
+
};
|
|
10013
|
+
|
|
10014
|
+
const render$d = widget => {
|
|
10015
|
+
const commands = renderCodeGeneratorWidget();
|
|
10016
|
+
const wrappedCommands = [];
|
|
10017
|
+
const uid = widget.newState.uid;
|
|
10018
|
+
for (const command of commands) {
|
|
10019
|
+
if (command[0] === 'Viewlet.setDom2') {
|
|
10020
|
+
wrappedCommands.push(command);
|
|
10021
|
+
} else {
|
|
10022
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
10023
|
+
}
|
|
10024
|
+
}
|
|
10025
|
+
return wrappedCommands;
|
|
10026
|
+
};
|
|
10027
|
+
const add$7 = widget => {
|
|
10028
|
+
return addWidget(widget, 'EditorCodeGenerator', render$d);
|
|
10029
|
+
};
|
|
10030
|
+
const remove$7 = removeWidget;
|
|
10031
|
+
|
|
10032
|
+
const EditorCodeGeneratorWidget = {
|
|
10033
|
+
__proto__: null,
|
|
10034
|
+
add: add$7,
|
|
10035
|
+
remove: remove$7,
|
|
10036
|
+
render: render$d
|
|
10037
|
+
};
|
|
10038
|
+
|
|
9961
10039
|
const mergeClassNames = (...classNames) => {
|
|
9962
10040
|
return classNames.filter(Boolean).join(' ');
|
|
9963
10041
|
};
|
|
@@ -10045,11 +10123,6 @@ const renderFull$2 = (oldState, newState) => {
|
|
|
10045
10123
|
return commands;
|
|
10046
10124
|
};
|
|
10047
10125
|
|
|
10048
|
-
const removeWidget = widget => {
|
|
10049
|
-
// @ts-ignore
|
|
10050
|
-
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
10051
|
-
};
|
|
10052
|
-
|
|
10053
10126
|
const render$b = widget => {
|
|
10054
10127
|
const commands = renderFull$2(widget.oldState, widget.newState);
|
|
10055
10128
|
const wrappedCommands = [];
|
|
@@ -11196,6 +11269,7 @@ const registerWidgets = () => {
|
|
|
11196
11269
|
set$7(Hover, EditorHoverWidget);
|
|
11197
11270
|
set$7(Rename, EditorRenameWidget);
|
|
11198
11271
|
set$7(SourceAction, EditorSourceActionWidget);
|
|
11272
|
+
set$7(CodeGenerator, EditorCodeGeneratorWidget);
|
|
11199
11273
|
};
|
|
11200
11274
|
|
|
11201
11275
|
const main = async () => {
|