@lvce-editor/editor-worker 18.23.0 → 18.24.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.
@@ -1,58 +1,122 @@
1
- const normalizeLine = line => {
2
- if (line.startsWith('Error: ')) {
3
- return line.slice('Error: '.length);
4
- }
5
- if (line.startsWith('VError: ')) {
6
- return line.slice('VError: '.length);
7
- }
8
- return line;
9
- };
10
- const getCombinedMessage = (error, message) => {
11
- const stringifiedError = normalizeLine(`${error}`);
12
- if (message) {
13
- return `${message}: ${stringifiedError}`;
14
- }
15
- return stringifiedError;
1
+ const toCommandId = key => {
2
+ const dotIndex = key.indexOf('.');
3
+ return key.slice(dotIndex + 1);
16
4
  };
17
- const NewLine$3 = '\n';
18
- const getNewLineIndex$1 = (string, startIndex = undefined) => {
19
- return string.indexOf(NewLine$3, startIndex);
5
+ const create$j = () => {
6
+ const states = Object.create(null);
7
+ const commandMapRef = {};
8
+ return {
9
+ clear() {
10
+ for (const key of Object.keys(states)) {
11
+ delete states[key];
12
+ }
13
+ },
14
+ diff(uid, modules, numbers) {
15
+ const {
16
+ newState,
17
+ oldState
18
+ } = states[uid];
19
+ const diffResult = [];
20
+ for (let i = 0; i < modules.length; i++) {
21
+ const fn = modules[i];
22
+ if (!fn(oldState, newState)) {
23
+ diffResult.push(numbers[i]);
24
+ }
25
+ }
26
+ return diffResult;
27
+ },
28
+ dispose(uid) {
29
+ delete states[uid];
30
+ },
31
+ get(uid) {
32
+ return states[uid];
33
+ },
34
+ getCommandIds() {
35
+ const keys = Object.keys(commandMapRef);
36
+ const ids = keys.map(toCommandId);
37
+ return ids;
38
+ },
39
+ getKeys() {
40
+ return Object.keys(states).map(key => {
41
+ return Number.parseFloat(key);
42
+ });
43
+ },
44
+ registerCommands(commandMap) {
45
+ Object.assign(commandMapRef, commandMap);
46
+ },
47
+ set(uid, oldState, newState) {
48
+ states[uid] = {
49
+ newState,
50
+ oldState
51
+ };
52
+ },
53
+ wrapCommand(fn) {
54
+ const wrapped = async (uid, ...args) => {
55
+ const {
56
+ newState,
57
+ oldState
58
+ } = states[uid];
59
+ const newerState = await fn(newState, ...args);
60
+ if (oldState === newerState || newState === newerState) {
61
+ return;
62
+ }
63
+ const latestOld = states[uid];
64
+ const latestNew = {
65
+ ...latestOld.newState,
66
+ ...newerState
67
+ };
68
+ states[uid] = {
69
+ newState: latestNew,
70
+ oldState: latestOld.oldState
71
+ };
72
+ };
73
+ return wrapped;
74
+ },
75
+ wrapGetter(fn) {
76
+ const wrapped = (uid, ...args) => {
77
+ const {
78
+ newState
79
+ } = states[uid];
80
+ return fn(newState, ...args);
81
+ };
82
+ return wrapped;
83
+ },
84
+ wrapLoadContent(fn) {
85
+ const wrapped = async (uid, ...args) => {
86
+ const {
87
+ newState,
88
+ oldState
89
+ } = states[uid];
90
+ const result = await fn(newState, ...args);
91
+ const {
92
+ error,
93
+ state
94
+ } = result;
95
+ if (oldState === state || newState === state) {
96
+ return {
97
+ error
98
+ };
99
+ }
100
+ const latestOld = states[uid];
101
+ const latestNew = {
102
+ ...latestOld.newState,
103
+ ...state
104
+ };
105
+ states[uid] = {
106
+ newState: latestNew,
107
+ oldState: latestOld.oldState
108
+ };
109
+ return {
110
+ error
111
+ };
112
+ };
113
+ return wrapped;
114
+ }
115
+ };
20
116
  };
21
- const mergeStacks = (parent, child) => {
22
- if (!child) {
23
- return parent;
24
- }
25
- const parentNewLineIndex = getNewLineIndex$1(parent);
26
- const childNewLineIndex = getNewLineIndex$1(child);
27
- if (childNewLineIndex === -1) {
28
- return parent;
29
- }
30
- const parentFirstLine = parent.slice(0, parentNewLineIndex);
31
- const childRest = child.slice(childNewLineIndex);
32
- const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
33
- if (parentFirstLine.includes(childFirstLine)) {
34
- return parentFirstLine + childRest;
35
- }
36
- return child;
117
+ const terminate = () => {
118
+ globalThis.close();
37
119
  };
38
- class VError extends Error {
39
- constructor(error, message) {
40
- const combinedMessage = getCombinedMessage(error, message);
41
- super(combinedMessage);
42
- this.name = 'VError';
43
- if (error instanceof Error) {
44
- this.stack = mergeStacks(this.stack, error.stack);
45
- }
46
- if (error.codeFrame) {
47
- // @ts-ignore
48
- this.codeFrame = error.codeFrame;
49
- }
50
- if (error.code) {
51
- // @ts-ignore
52
- this.code = error.code;
53
- }
54
- }
55
- }
56
120
 
57
121
  class AssertionError extends Error {
58
122
  constructor(message) {
@@ -121,6 +185,62 @@ const boolean = value => {
121
185
  }
122
186
  };
123
187
 
188
+ const normalizeLine = line => {
189
+ if (line.startsWith('Error: ')) {
190
+ return line.slice('Error: '.length);
191
+ }
192
+ if (line.startsWith('VError: ')) {
193
+ return line.slice('VError: '.length);
194
+ }
195
+ return line;
196
+ };
197
+ const getCombinedMessage = (error, message) => {
198
+ const stringifiedError = normalizeLine(`${error}`);
199
+ if (message) {
200
+ return `${message}: ${stringifiedError}`;
201
+ }
202
+ return stringifiedError;
203
+ };
204
+ const NewLine$3 = '\n';
205
+ const getNewLineIndex$1 = (string, startIndex = undefined) => {
206
+ return string.indexOf(NewLine$3, startIndex);
207
+ };
208
+ const mergeStacks = (parent, child) => {
209
+ if (!child) {
210
+ return parent;
211
+ }
212
+ const parentNewLineIndex = getNewLineIndex$1(parent);
213
+ const childNewLineIndex = getNewLineIndex$1(child);
214
+ if (childNewLineIndex === -1) {
215
+ return parent;
216
+ }
217
+ const parentFirstLine = parent.slice(0, parentNewLineIndex);
218
+ const childRest = child.slice(childNewLineIndex);
219
+ const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
220
+ if (parentFirstLine.includes(childFirstLine)) {
221
+ return parentFirstLine + childRest;
222
+ }
223
+ return child;
224
+ };
225
+ class VError extends Error {
226
+ constructor(error, message) {
227
+ const combinedMessage = getCombinedMessage(error, message);
228
+ super(combinedMessage);
229
+ this.name = 'VError';
230
+ if (error instanceof Error) {
231
+ this.stack = mergeStacks(this.stack, error.stack);
232
+ }
233
+ if (error.codeFrame) {
234
+ // @ts-ignore
235
+ this.codeFrame = error.codeFrame;
236
+ }
237
+ if (error.code) {
238
+ // @ts-ignore
239
+ this.code = error.code;
240
+ }
241
+ }
242
+ }
243
+
124
244
  const isMessagePort = value => {
125
245
  return value && value instanceof MessagePort;
126
246
  };
@@ -765,7 +885,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
765
885
  const errorProperty = getErrorProperty(error, prettyError);
766
886
  return create$1$1(id, errorProperty);
767
887
  };
768
- const create$j = (message, result) => {
888
+ const create$i = (message, result) => {
769
889
  return {
770
890
  id: message.id,
771
891
  jsonrpc: Two$1,
@@ -774,7 +894,7 @@ const create$j = (message, result) => {
774
894
  };
775
895
  const getSuccessResponse = (message, result) => {
776
896
  const resultProperty = result ?? null;
777
- return create$j(message, resultProperty);
897
+ return create$i(message, resultProperty);
778
898
  };
779
899
  const getErrorResponseSimple = (id, error) => {
780
900
  return {
@@ -868,7 +988,7 @@ const handleJsonRpcMessage = async (...args) => {
868
988
 
869
989
  const Two = '2.0';
870
990
 
871
- const create$i = (method, params) => {
991
+ const create$h = (method, params) => {
872
992
  return {
873
993
  jsonrpc: Two,
874
994
  method,
@@ -876,7 +996,7 @@ const create$i = (method, params) => {
876
996
  };
877
997
  };
878
998
 
879
- const create$h = (id, method, params) => {
999
+ const create$g = (id, method, params) => {
880
1000
  const message = {
881
1001
  id,
882
1002
  jsonrpc: Two,
@@ -887,12 +1007,12 @@ const create$h = (id, method, params) => {
887
1007
  };
888
1008
 
889
1009
  let id = 0;
890
- const create$g = () => {
1010
+ const create$f = () => {
891
1011
  return ++id;
892
1012
  };
893
1013
 
894
1014
  const registerPromise = map => {
895
- const id = create$g();
1015
+ const id = create$f();
896
1016
  const {
897
1017
  promise,
898
1018
  resolve
@@ -909,7 +1029,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
909
1029
  id,
910
1030
  promise
911
1031
  } = registerPromise(callbacks);
912
- const message = create$h(id, method, params);
1032
+ const message = create$g(id, method, params);
913
1033
  if (useSendAndTransfer && ipc.sendAndTransfer) {
914
1034
  ipc.sendAndTransfer(message);
915
1035
  } else {
@@ -945,7 +1065,7 @@ const createRpc = ipc => {
945
1065
  * @deprecated
946
1066
  */
947
1067
  send(method, ...params) {
948
- const message = create$i(method, params);
1068
+ const message = create$h(method, params);
949
1069
  ipc.send(message);
950
1070
  }
951
1071
  };
@@ -985,7 +1105,7 @@ const listen$1 = async (module, options) => {
985
1105
  return ipc;
986
1106
  };
987
1107
 
988
- const create$f = async ({
1108
+ const create$e = async ({
989
1109
  commandMap,
990
1110
  isMessagePortOpen = true,
991
1111
  messagePort
@@ -1003,7 +1123,7 @@ const create$f = async ({
1003
1123
  return rpc;
1004
1124
  };
1005
1125
 
1006
- const create$e = async ({
1126
+ const create$d = async ({
1007
1127
  commandMap,
1008
1128
  isMessagePortOpen,
1009
1129
  send
@@ -1013,7 +1133,7 @@ const create$e = async ({
1013
1133
  port2
1014
1134
  } = new MessageChannel();
1015
1135
  await send(port1);
1016
- return create$f({
1136
+ return create$e({
1017
1137
  commandMap,
1018
1138
  isMessagePortOpen,
1019
1139
  messagePort: port2
@@ -1048,13 +1168,13 @@ const createSharedLazyRpc = factory => {
1048
1168
  };
1049
1169
  };
1050
1170
 
1051
- const create$d = async ({
1171
+ const create$c = async ({
1052
1172
  commandMap,
1053
1173
  isMessagePortOpen,
1054
1174
  send
1055
1175
  }) => {
1056
1176
  return createSharedLazyRpc(() => {
1057
- return create$e({
1177
+ return create$d({
1058
1178
  commandMap,
1059
1179
  isMessagePortOpen,
1060
1180
  send
@@ -1062,17 +1182,17 @@ const create$d = async ({
1062
1182
  });
1063
1183
  };
1064
1184
 
1065
- const create$c = async ({
1185
+ const create$b = async ({
1066
1186
  commandMap,
1067
1187
  messagePort
1068
1188
  }) => {
1069
- return create$f({
1189
+ return create$e({
1070
1190
  commandMap,
1071
1191
  messagePort
1072
1192
  });
1073
1193
  };
1074
1194
 
1075
- const create$b = async ({
1195
+ const create$a = async ({
1076
1196
  commandMap
1077
1197
  }) => {
1078
1198
  // TODO create a commandMap per rpc instance
@@ -1115,7 +1235,7 @@ const remove$8 = id => {
1115
1235
  };
1116
1236
 
1117
1237
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
1118
- const create$a = rpcId => {
1238
+ const create$9 = rpcId => {
1119
1239
  return {
1120
1240
  async dispose() {
1121
1241
  const rpc = get$7(rpcId);
@@ -1233,7 +1353,7 @@ const FocusEditorText$1 = 12;
1233
1353
  const {
1234
1354
  invoke: invoke$f,
1235
1355
  set: set$d
1236
- } = create$a(ExtensionHostWorker);
1356
+ } = create$9(ExtensionHostWorker);
1237
1357
 
1238
1358
  const ExtensionHost = {
1239
1359
  __proto__: null,
@@ -1244,7 +1364,7 @@ const ExtensionHost = {
1244
1364
  const {
1245
1365
  invoke: invoke$e,
1246
1366
  set: set$c
1247
- } = create$a(ExtensionManagementWorker);
1367
+ } = create$9(ExtensionManagementWorker);
1248
1368
  const getLanguages$1 = (platform, assetDir) => {
1249
1369
  return invoke$e('Extensions.getLanguages', platform, assetDir);
1250
1370
  };
@@ -1252,45 +1372,50 @@ const getLanguages$1 = (platform, assetDir) => {
1252
1372
  const {
1253
1373
  invoke: invoke$d,
1254
1374
  set: set$b
1255
- } = create$a(OpenerWorker);
1375
+ } = create$9(OpenerWorker);
1256
1376
  const openUrl = async (url, platform) => {
1257
1377
  return invoke$d('Open.openUrl', url, platform);
1258
1378
  };
1259
1379
 
1260
1380
  const {
1261
1381
  invoke: invoke$c,
1262
- invokeAndTransfer,
1263
1382
  set: set$a
1264
- } = create$a(RendererWorker$1);
1383
+ } = create$9(IconThemeWorker);
1384
+
1385
+ const {
1386
+ invoke: invoke$b,
1387
+ invokeAndTransfer,
1388
+ set: set$9
1389
+ } = create$9(RendererWorker$1);
1265
1390
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1266
1391
  number(uid);
1267
1392
  number(menuId);
1268
1393
  number(x);
1269
1394
  number(y);
1270
- await invoke$c('ContextMenu.show2', uid, menuId, x, y, args);
1395
+ await invoke$b('ContextMenu.show2', uid, menuId, x, y, args);
1271
1396
  };
1272
1397
  const sendMessagePortToOpenerWorker = async (port, rpcId) => {
1273
1398
  const command = 'HandleMessagePort.handleMessagePort';
1274
1399
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
1275
1400
  };
1276
1401
  const readFile = async uri => {
1277
- return invoke$c('FileSystem.readFile', uri);
1402
+ return invoke$b('FileSystem.readFile', uri);
1278
1403
  };
1279
1404
  const handleWorkspaceRefresh = async () => {
1280
- return invoke$c('Layout.handleWorkspaceRefresh');
1405
+ return invoke$b('Layout.handleWorkspaceRefresh');
1281
1406
  };
1282
1407
  const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1283
1408
  const command = 'HandleMessagePort.handleMessagePort2';
1284
1409
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1285
1410
  };
1286
1411
  const writeClipBoardText = async text => {
1287
- await invoke$c('ClipBoard.writeText', /* text */text);
1412
+ await invoke$b('ClipBoard.writeText', /* text */text);
1288
1413
  };
1289
1414
  const readClipBoardText = async () => {
1290
- return invoke$c('ClipBoard.readText');
1415
+ return invoke$b('ClipBoard.readText');
1291
1416
  };
1292
1417
  const activateByEvent$1 = (event, assetDir, platform) => {
1293
- return invoke$c('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
1418
+ return invoke$b('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
1294
1419
  };
1295
1420
  const sendMessagePortToTextMeasurementWorker = async port => {
1296
1421
  const command = 'TextMeasurement.handleMessagePort';
@@ -1301,10 +1426,10 @@ const sendMessagePortToExtensionManagementWorker$1 = async (port, rpcId) => {
1301
1426
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
1302
1427
  };
1303
1428
  const getPreference = async key => {
1304
- return await invoke$c('Preferences.get', key);
1429
+ return await invoke$b('Preferences.get', key);
1305
1430
  };
1306
1431
  const openUri = async (uri, focus, options) => {
1307
- await invoke$c('Main.openUri', uri, focus, options);
1432
+ await invoke$b('Main.openUri', uri, focus, options);
1308
1433
  };
1309
1434
  const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
1310
1435
  await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
@@ -1315,7 +1440,7 @@ const RendererWorker = {
1315
1440
  activateByEvent: activateByEvent$1,
1316
1441
  getPreference,
1317
1442
  handleWorkspaceRefresh,
1318
- invoke: invoke$c,
1443
+ invoke: invoke$b,
1319
1444
  invokeAndTransfer,
1320
1445
  openUri,
1321
1446
  readClipBoardText,
@@ -1325,20 +1450,15 @@ const RendererWorker = {
1325
1450
  sendMessagePortToOpenerWorker,
1326
1451
  sendMessagePortToSyntaxHighlightingWorker: sendMessagePortToSyntaxHighlightingWorker$1,
1327
1452
  sendMessagePortToTextMeasurementWorker,
1328
- set: set$a,
1453
+ set: set$9,
1329
1454
  showContextMenu2,
1330
1455
  writeClipBoardText
1331
1456
  };
1332
1457
 
1333
- const {
1334
- invoke: invoke$b,
1335
- set: set$9
1336
- } = create$a(IconThemeWorker);
1337
-
1338
1458
  const {
1339
1459
  invoke: invoke$a,
1340
1460
  set: set$8
1341
- } = create$a(MarkdownWorker);
1461
+ } = create$9(MarkdownWorker);
1342
1462
 
1343
1463
  const SyntaxHighlightingWorker = {
1344
1464
  __proto__: null,
@@ -1367,134 +1487,14 @@ const createLazyRpc = rpcId => {
1367
1487
  },
1368
1488
  async invokeAndTransfer(method, ...params) {
1369
1489
  await ensureRpc();
1370
- const rpc = get$7(rpcId);
1371
- return rpc.invokeAndTransfer(method, ...params);
1372
- },
1373
- setFactory(value) {
1374
- factory = value;
1375
- }
1376
- };
1377
- };
1378
-
1379
- const toCommandId = key => {
1380
- const dotIndex = key.indexOf('.');
1381
- return key.slice(dotIndex + 1);
1382
- };
1383
- const create$9 = () => {
1384
- const states = Object.create(null);
1385
- const commandMapRef = {};
1386
- return {
1387
- clear() {
1388
- for (const key of Object.keys(states)) {
1389
- delete states[key];
1390
- }
1391
- },
1392
- diff(uid, modules, numbers) {
1393
- const {
1394
- newState,
1395
- oldState
1396
- } = states[uid];
1397
- const diffResult = [];
1398
- for (let i = 0; i < modules.length; i++) {
1399
- const fn = modules[i];
1400
- if (!fn(oldState, newState)) {
1401
- diffResult.push(numbers[i]);
1402
- }
1403
- }
1404
- return diffResult;
1405
- },
1406
- dispose(uid) {
1407
- delete states[uid];
1408
- },
1409
- get(uid) {
1410
- return states[uid];
1411
- },
1412
- getCommandIds() {
1413
- const keys = Object.keys(commandMapRef);
1414
- const ids = keys.map(toCommandId);
1415
- return ids;
1416
- },
1417
- getKeys() {
1418
- return Object.keys(states).map(key => {
1419
- return Number.parseFloat(key);
1420
- });
1421
- },
1422
- registerCommands(commandMap) {
1423
- Object.assign(commandMapRef, commandMap);
1424
- },
1425
- set(uid, oldState, newState) {
1426
- states[uid] = {
1427
- newState,
1428
- oldState
1429
- };
1430
- },
1431
- wrapCommand(fn) {
1432
- const wrapped = async (uid, ...args) => {
1433
- const {
1434
- newState,
1435
- oldState
1436
- } = states[uid];
1437
- const newerState = await fn(newState, ...args);
1438
- if (oldState === newerState || newState === newerState) {
1439
- return;
1440
- }
1441
- const latestOld = states[uid];
1442
- const latestNew = {
1443
- ...latestOld.newState,
1444
- ...newerState
1445
- };
1446
- states[uid] = {
1447
- newState: latestNew,
1448
- oldState: latestOld.oldState
1449
- };
1450
- };
1451
- return wrapped;
1452
- },
1453
- wrapGetter(fn) {
1454
- const wrapped = (uid, ...args) => {
1455
- const {
1456
- newState
1457
- } = states[uid];
1458
- return fn(newState, ...args);
1459
- };
1460
- return wrapped;
1461
- },
1462
- wrapLoadContent(fn) {
1463
- const wrapped = async (uid, ...args) => {
1464
- const {
1465
- newState,
1466
- oldState
1467
- } = states[uid];
1468
- const result = await fn(newState, ...args);
1469
- const {
1470
- error,
1471
- state
1472
- } = result;
1473
- if (oldState === state || newState === state) {
1474
- return {
1475
- error
1476
- };
1477
- }
1478
- const latestOld = states[uid];
1479
- const latestNew = {
1480
- ...latestOld.newState,
1481
- ...state
1482
- };
1483
- states[uid] = {
1484
- newState: latestNew,
1485
- oldState: latestOld.oldState
1486
- };
1487
- return {
1488
- error
1489
- };
1490
- };
1491
- return wrapped;
1490
+ const rpc = get$7(rpcId);
1491
+ return rpc.invokeAndTransfer(method, ...params);
1492
+ },
1493
+ setFactory(value) {
1494
+ factory = value;
1492
1495
  }
1493
1496
  };
1494
1497
  };
1495
- const terminate = () => {
1496
- globalThis.close();
1497
- };
1498
1498
 
1499
1499
  // TODO add tests for this
1500
1500
  const activateByEvent = async (event, assetDir, platform) => {
@@ -1512,7 +1512,7 @@ const codeGeneratorAccept = state => {
1512
1512
  const ModuleWorkerAndWorkaroundForChromeDevtoolsBug = 6;
1513
1513
 
1514
1514
  const launchWorker = async (name, url, intializeCommand) => {
1515
- const rpc = await create$e({
1515
+ const rpc = await create$d({
1516
1516
  commandMap: {},
1517
1517
  isMessagePortOpen: true,
1518
1518
  async send(port) {
@@ -1567,7 +1567,7 @@ const loadContent$3 = async (state, parentUid) => {
1567
1567
  };
1568
1568
  };
1569
1569
 
1570
- const editorStates = create$9();
1570
+ const editorStates = create$j();
1571
1571
  const {
1572
1572
  getCommandIds,
1573
1573
  registerCommands,
@@ -1939,7 +1939,7 @@ const state$7 = {
1939
1939
  tokenizers: Object.create(null)
1940
1940
  };
1941
1941
  const has = languageId => {
1942
- return languageId in state$7.tokenizers;
1942
+ return Object.hasOwn(state$7.tokenizers, languageId);
1943
1943
  };
1944
1944
  const set$4 = (languageId, tokenizer) => {
1945
1945
  state$7.tokenizers[languageId] = tokenizer;
@@ -1948,7 +1948,7 @@ const get$4 = languageId => {
1948
1948
  return state$7.tokenizers[languageId];
1949
1949
  };
1950
1950
  const isPending = languageId => {
1951
- return languageId in state$7.pending;
1951
+ return Object.hasOwn(state$7.pending, languageId);
1952
1952
  };
1953
1953
 
1954
1954
  const tokenMaps = Object.create(null);
@@ -2169,7 +2169,7 @@ const Tab = '\t';
2169
2169
 
2170
2170
  const normalizeText = (text, normalize, tabSize) => {
2171
2171
  if (normalize) {
2172
- return text.replaceAll(Tab, Space.repeat(tabSize));
2172
+ return text.replaceAll(Tab, () => Space.repeat(tabSize));
2173
2173
  }
2174
2174
  return text;
2175
2175
  };
@@ -2232,11 +2232,9 @@ const applyEdits = (textDocument, changes) => {
2232
2232
  const startColumnIndex = change.start.columnIndex;
2233
2233
  const endColumnIndex = change.end.columnIndex;
2234
2234
  const {
2235
+ deleted,
2235
2236
  inserted
2236
2237
  } = change;
2237
- const {
2238
- deleted
2239
- } = change;
2240
2238
  number(startRowIndex);
2241
2239
  number(endRowIndex);
2242
2240
  number(startColumnIndex);
@@ -2418,6 +2416,24 @@ const getStartDefaults = (tokens, minOffset) => {
2418
2416
  startIndex
2419
2417
  };
2420
2418
  };
2419
+ const hasDecorationOverlap = (decorationMap, tokenStart, tokenEnd) => {
2420
+ for (const [decorationStart, {
2421
+ end: decorationEnd
2422
+ }] of decorationMap) {
2423
+ if (decorationStart < tokenEnd && decorationEnd > tokenStart) {
2424
+ return true;
2425
+ }
2426
+ }
2427
+ return false;
2428
+ };
2429
+ const getActiveDecoration = (decorationMap, currentPos) => {
2430
+ for (const [decorationStart, decoration] of decorationMap) {
2431
+ if (decorationStart <= currentPos && decoration.end > currentPos) {
2432
+ return decoration;
2433
+ }
2434
+ }
2435
+ return undefined;
2436
+ };
2421
2437
  const getLineInfoEmbeddedFull = (embeddedResults, tokenResults, line, decorations, lineOffset, normalize, tabSize, width, deltaX, averageCharWidth, minOffset, maxOffset) => {
2422
2438
  const lineInfo = [];
2423
2439
 
@@ -2455,29 +2471,13 @@ const getLineInfoEmbeddedFull = (embeddedResults, tokenResults, line, decoration
2455
2471
  const tokenType = embeddedTokens[i];
2456
2472
  const tokenLength = embeddedTokens[i + 1];
2457
2473
  const tokenEnd = start + tokenLength;
2458
-
2459
- // Check if any decorations overlap with this token
2460
- let hasOverlap = false;
2461
- for (const [decorationStart, {
2462
- end: decorationEnd
2463
- }] of decorationMap) {
2464
- if (decorationStart < tokenEnd && decorationEnd > start) {
2465
- hasOverlap = true;
2466
- break;
2467
- }
2468
- }
2474
+ const hasOverlap = hasDecorationOverlap(decorationMap, start, tokenEnd);
2469
2475
  if (hasOverlap) {
2470
2476
  // Token has decoration overlap - split into parts
2471
2477
  let currentPos = start;
2472
2478
  while (currentPos < tokenEnd) {
2473
2479
  // Find if current position is inside a decoration
2474
- let activeDecoration = null;
2475
- for (const [decorationStart, decoration] of decorationMap) {
2476
- if (decorationStart <= currentPos && decoration.end > currentPos) {
2477
- activeDecoration = decoration;
2478
- break;
2479
- }
2480
- }
2480
+ const activeDecoration = getActiveDecoration(decorationMap, currentPos);
2481
2481
  if (activeDecoration) {
2482
2482
  // Render decorated part
2483
2483
  const partEnd = Math.min(tokenEnd, activeDecoration.end);
@@ -2525,7 +2525,7 @@ const getLineInfoEmbeddedFull = (embeddedResults, tokenResults, line, decoration
2525
2525
  };
2526
2526
  const getOffsets = (deltaX, width, averageCharWidth) => {
2527
2527
  // TODO accurately measure char widths using offscreen canvas
2528
- // and use fast measurements for monospace ascii text
2528
+ // and use fast measurements for monospace ASCII text
2529
2529
  if (deltaX === 0) {
2530
2530
  return {
2531
2531
  maxOffset: Math.ceil(width / averageCharWidth),
@@ -2581,29 +2581,13 @@ const getLineInfoDefault = (line, tokenResults, embeddedResults, decorations, To
2581
2581
  const tokenType = tokens[i];
2582
2582
  const tokenLength = tokens[i + 1];
2583
2583
  const tokenEnd = start + tokenLength;
2584
-
2585
- // Check if any decorations overlap with this token
2586
- let hasOverlap = false;
2587
- for (const [decorationStart, {
2588
- end: decorationEnd
2589
- }] of decorationMap) {
2590
- if (decorationStart < tokenEnd && decorationEnd > start) {
2591
- hasOverlap = true;
2592
- break;
2593
- }
2594
- }
2584
+ const hasOverlap = hasDecorationOverlap(decorationMap, start, tokenEnd);
2595
2585
  if (hasOverlap) {
2596
2586
  // Token has decoration overlap - split into parts
2597
2587
  let currentPos = start;
2598
2588
  while (currentPos < tokenEnd) {
2599
2589
  // Find if current position is inside a decoration
2600
- let activeDecoration = null;
2601
- for (const [decorationStart, decoration] of decorationMap) {
2602
- if (decorationStart <= currentPos && decoration.end > currentPos) {
2603
- activeDecoration = decoration;
2604
- break;
2605
- }
2606
- }
2590
+ const activeDecoration = getActiveDecoration(decorationMap, currentPos);
2607
2591
  if (activeDecoration) {
2608
2592
  // Render decorated part
2609
2593
  const partEnd = Math.min(tokenEnd, activeDecoration.end);
@@ -2875,7 +2859,7 @@ const getIncrementalEdits = async (oldState, newState) => {
2875
2859
  * @returns Array of regex matches
2876
2860
  */
2877
2861
  const getRegexMatches = (text, regex) => {
2878
- return [...text.matchAll(regex)];
2862
+ return text.matchAll(regex).toArray();
2879
2863
  };
2880
2864
 
2881
2865
  // URL matching regex pattern - matches common URL schemes
@@ -2983,7 +2967,7 @@ const state$6 = Object.create(null);
2983
2967
  const registerListener$1 = (listenerType, rpcId) => {
2984
2968
  number(listenerType);
2985
2969
  number(rpcId);
2986
- if (!state$6[listenerType]) {
2970
+ if (!Object.hasOwn(state$6, listenerType)) {
2987
2971
  state$6[listenerType] = [];
2988
2972
  }
2989
2973
 
@@ -3001,7 +2985,7 @@ const registerListener$1 = (listenerType, rpcId) => {
3001
2985
  const unregisterListener$1 = (listenerType, rpcId) => {
3002
2986
  number(listenerType);
3003
2987
  number(rpcId);
3004
- if (state$6[listenerType]) {
2988
+ if (Object.hasOwn(state$6, listenerType)) {
3005
2989
  const index = state$6[listenerType].indexOf(rpcId);
3006
2990
  if (index !== -1) {
3007
2991
  state$6[listenerType].splice(index, 1);
@@ -3126,13 +3110,13 @@ const measureTextWidthFast = async (text, charWidth) => {
3126
3110
  };
3127
3111
 
3128
3112
  const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
3129
- const width = await invoke$b('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
3113
+ const width = await invoke$c('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
3130
3114
  return width;
3131
3115
  };
3132
3116
 
3133
3117
  const measureTextWidth = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
3134
3118
  // TODO maybe have a property for the whole text document
3135
- // whether the document is ascii or not
3119
+ // whether the document is ASCII or not
3136
3120
  // so that it doesn't need to be checked on every cursor change
3137
3121
  // or scroll position change
3138
3122
  if (isMonoSpaceFont && isAscii(text)) {
@@ -3486,7 +3470,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
3486
3470
  // invalidStartIndex, lineCache, etc. just for testing editorType
3487
3471
  const invalidStartIndex = Math.min(editor.invalidStartIndex, changes[0].start.rowIndex);
3488
3472
 
3489
- // TODO maybe put undostack into indexeddb so that there is no memory leak in application
3473
+ // TODO maybe put undostack into indexeddb so that there is no memory leak in app
3490
3474
  // then clear old undostack from indexeddb after 3 days
3491
3475
  // TODO should push to undostack after rendering
3492
3476
  const autoClosingRanges = applyAutoClosingRangesEdit(editor, changes);
@@ -3513,10 +3497,12 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
3513
3497
  }
3514
3498
 
3515
3499
  // Notify registered listeners about editor changes
3516
- notifyListeners(EditorChange, 'handleEditorChanged', editor.uid, editor.uri, changes).catch(error => {
3500
+ try {
3501
+ await notifyListeners(EditorChange, 'handleEditorChanged', editor.uid, editor.uri, changes);
3502
+ } catch (error) {
3517
3503
  // Silently ignore notification errors to not interrupt the edit flow
3518
3504
  console.warn('Failed to notify editor change listeners:', error);
3519
- });
3505
+ }
3520
3506
  const incrementalEdits = await getIncrementalEdits(editor, newEditorWithDecorations);
3521
3507
  const editorWithNewWidgets = await applyWidgetChanges(newEditorWithDecorations, changes);
3522
3508
  const newEditor2 = {
@@ -3936,7 +3922,7 @@ const updateDiagnostics = async newState => {
3936
3922
  };
3937
3923
  set$7(newState.id, latest.oldState, newEditor);
3938
3924
  // @ts-ignore
3939
- await invoke$c('Editor.rerender', newState.id);
3925
+ await invoke$b('Editor.rerender', newState.id);
3940
3926
  return newEditor;
3941
3927
  } catch (error) {
3942
3928
  // @ts-ignore
@@ -4285,7 +4271,7 @@ const applyWorkspaceEdit = async (editor, changes) => {
4285
4271
  return editor;
4286
4272
  }
4287
4273
  // TODO
4288
- // for now only apply edits to single file, if it matches the uri
4274
+ // for now only apply edits to single file, if it matches the URI
4289
4275
  //
4290
4276
  // in the future:
4291
4277
  // 1. if a change targets the current editor, apply an edit to this editor
@@ -4360,9 +4346,7 @@ const create$8 = () => {
4360
4346
  const segments = segmenter.segment(line);
4361
4347
  return segments.containing(index);
4362
4348
  },
4363
- getSegments(line) {
4364
- return segmenter.segment(line);
4365
- },
4349
+ getSegments: line => segmenter.segment(line),
4366
4350
  modelIndex(line, visualIndex) {
4367
4351
  const segments = segmenter.segment(line);
4368
4352
  let currentVisualIndex = 0;
@@ -4462,13 +4446,13 @@ const at = async (editor, eventX, eventY) => {
4462
4446
  y
4463
4447
  } = editor;
4464
4448
  const rowIndex = Math.floor((eventY - y + deltaY) / rowHeight);
4465
- const relativeX = eventX - x + deltaX;
4466
4449
  if (rowIndex < 0) {
4467
4450
  return {
4468
4451
  columnIndex: 0,
4469
4452
  rowIndex: 0
4470
4453
  };
4471
4454
  }
4455
+ const relativeX = eventX - x + deltaX;
4472
4456
  const clampedRowIndex = clamp(rowIndex, 0, lines.length - 1);
4473
4457
  const line = lines[clampedRowIndex];
4474
4458
  const columnIndex = await getAccurateColumnIndex(line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, relativeX);
@@ -4479,7 +4463,7 @@ const at = async (editor, eventX, eventY) => {
4479
4463
  };
4480
4464
 
4481
4465
  /**
4482
- * @deprecated this doesn't work for variable width characters (unicode/emoji).
4466
+ * @deprecated this doesn't work for variable width characters (Unicode/emoji).
4483
4467
  * Use position computation in renderer process instead
4484
4468
  *
4485
4469
  * @param {object} editor
@@ -4527,7 +4511,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
4527
4511
  const y$1 = y(editor, rowIndex);
4528
4512
  const displayErrorMessage = message;
4529
4513
  // @ts-ignore
4530
- await invoke$c('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
4514
+ await invoke$b('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
4531
4515
  if (!isError) {
4532
4516
  const handleTimeout = () => {
4533
4517
  editorHideMessage(editor);
@@ -4562,9 +4546,7 @@ const editorHideMessage = async editor => {
4562
4546
  };
4563
4547
 
4564
4548
  // @ts-ignore
4565
- const getErrorMessage$4 = error => {
4566
- return `${error}`;
4567
- };
4549
+ const getErrorMessage$4 = String;
4568
4550
 
4569
4551
  // @ts-ignore
4570
4552
  const getMatchingClosingBrace$1 = brace => {
@@ -4584,7 +4566,7 @@ const braceCompletion = async (editor, text) => {
4584
4566
  // @ts-ignore
4585
4567
  const offset = offsetAt(editor, editor.cursor);
4586
4568
  // @ts-ignore
4587
- const result = await invoke$c('ExtensionHostBraceCompletion.executeBraceCompletionProvider', editor, offset, text);
4569
+ const result = await invoke$b('ExtensionHostBraceCompletion.executeBraceCompletionProvider', editor, offset, text);
4588
4570
  if (result) {
4589
4571
  const closingBrace = getMatchingClosingBrace$1(text);
4590
4572
  const insertText = text + closingBrace;
@@ -5085,7 +5067,7 @@ const tryRegexArray = (partialLine, regexArray) => {
5085
5067
  return 1;
5086
5068
  };
5087
5069
  const RE_WORD_LEFT_1 = /(?<![A-Z])[A-Z]+\s*$/;
5088
- const RE_WORD_LEFT_2 = /[\u00C0-\u017F\w\-]+>?\s*$/;
5070
+ const RE_WORD_LEFT_2 = /[\u{C0}-\u{17F}\w\-]+>?\s*$/u;
5089
5071
  const RE_WORD_LEFT_3 = /[a-zA-Z]+[^a-zA-Z\d]+\s*$/;
5090
5072
  const RE_WORD_LEFT_4 = /\s+$/;
5091
5073
  const RE_WORD_LEFT_5 = /[^a-zA-Z\d]+\s*$/;
@@ -5096,7 +5078,7 @@ const wordLeft = (line, columnIndex) => {
5096
5078
  const partialLine = line.slice(0, columnIndex);
5097
5079
  return tryRegexArray(partialLine, RE_WORD_LEFT);
5098
5080
  };
5099
- const RE_WORD_RIGHT_1 = /^\s*[\u00C0-\u017F\w]+/i;
5081
+ const RE_WORD_RIGHT_1 = /^\s*[\u{C0}-\u{17F}\w]+/iu;
5100
5082
  const RE_WORD_RIGHT_2 = /^[^a-zA-Z\d]+\w*/;
5101
5083
  const RE_WORD_RIGHT = [RE_WORD_RIGHT_1, RE_WORD_RIGHT_2];
5102
5084
  const wordRight = (line, columnIndex) => {
@@ -5517,7 +5499,7 @@ const deleteWordRight = editor => {
5517
5499
 
5518
5500
  const findAllReferences$1 = async editor => {
5519
5501
  // @ts-ignore
5520
- await invoke$c('SideBar.show', 'References', /* focus */true);
5502
+ await invoke$b('SideBar.show', 'References', /* focus */true);
5521
5503
  return editor;
5522
5504
  };
5523
5505
 
@@ -5554,7 +5536,7 @@ const format = async editor => {
5554
5536
  console.error(error);
5555
5537
 
5556
5538
  // TODO configure editor message as widget
5557
- const displayErrorMessage = `${error}`;
5539
+ const displayErrorMessage = String(error);
5558
5540
  await editorShowMessage(editor, 0, 0, displayErrorMessage, true);
5559
5541
  return editor;
5560
5542
  }
@@ -5605,7 +5587,7 @@ const getWordBefore = (editor, rowIndex, columnIndex) => {
5605
5587
  // @ts-ignore
5606
5588
  const getDefinition = async (editor, offset) => {
5607
5589
  // @ts-ignore
5608
- const definition = await invoke$c('ExtensionHostDefinition.executeDefinitionProvider', editor, offset);
5590
+ const definition = await invoke$b('ExtensionHostDefinition.executeDefinitionProvider', editor, offset);
5609
5591
  return definition;
5610
5592
  };
5611
5593
 
@@ -5838,7 +5820,7 @@ const goTo = async ({
5838
5820
  // TODO possible to do this with events/state machine instead of promises -> enables canceling operations / concurrent calls
5839
5821
 
5840
5822
  // TODO there are still race conditions in this function:
5841
- // - when open is called twice, previous dom nodes can either be reused or the previous dom nodes must be disposed
5823
+ // - when open is called twice, previous DOM nodes can either be reused or the previous DOM nodes must be disposed
5842
5824
 
5843
5825
  // @ts-ignore
5844
5826
  const getLocation$1 = async (editor, rowIndex, columnIndex) => {
@@ -5854,18 +5836,7 @@ const getNoLocationFoundMessage$1 = info => {
5854
5836
  }
5855
5837
  return noDefinitionFound();
5856
5838
  };
5857
-
5858
- // @ts-ignore
5859
- const getErrorMessage$3 = error => {
5860
- // if (
5861
- // error &&
5862
- // error.message &&
5863
- // error.message.startsWith('Failed to execute definition provider: ')
5864
- // ) {
5865
- // return error.message.replace('Failed to execute definition provider: ', '')
5866
- // }
5867
- return `${error}`;
5868
- };
5839
+ const getErrorMessage$3 = String;
5869
5840
 
5870
5841
  // @ts-ignore
5871
5842
  const isNoProviderFoundError$1 = error => {
@@ -5890,7 +5861,7 @@ const getNoLocationFoundMessage = info => {
5890
5861
 
5891
5862
  const getTypeDefinition = async (editor, offset) => {
5892
5863
  // @ts-ignore
5893
- const definition = await invoke$c('ExtensionHostTypeDefinition.executeTypeDefinitionProvider', editor, offset);
5864
+ const definition = await invoke$b('ExtensionHostTypeDefinition.executeTypeDefinitionProvider', editor, offset);
5894
5865
  return definition;
5895
5866
  };
5896
5867
 
@@ -5899,21 +5870,7 @@ const getLocation = async (editor, rowIndex, columnIndex) => {
5899
5870
  const definition = await getTypeDefinition(editor, offset);
5900
5871
  return definition;
5901
5872
  };
5902
-
5903
- // @ts-ignore
5904
- const getErrorMessage$2 = error => {
5905
- // if (
5906
- // error &&
5907
- // error.message &&
5908
- // error.message.startsWith('Failed to execute type definition provider: ')
5909
- // ) {
5910
- // return error.message.replace(
5911
- // 'Failed to execute type definition provider: ',
5912
- // ''
5913
- // )
5914
- // }
5915
- return `${error}`;
5916
- };
5873
+ const getErrorMessage$2 = String;
5917
5874
  const isNoProviderFoundError = error => {
5918
5875
  return error?.message?.startsWith('Failed to execute type definition provider: No type definition provider found');
5919
5876
  };
@@ -6073,8 +6030,8 @@ const handleContextMenu = async (editor, button, x, y) => {
6073
6030
  // @ts-ignore
6074
6031
 
6075
6032
  // match all words, including umlauts, see https://stackoverflow.com/questions/5436824/matching-accented-characters-with-javascript-regexes/#answer-11550799
6076
- const RE_WORD_START = /^[a-z\u00C0-\u017F\d]+/i;
6077
- const RE_WORD_END = /[a-z\u00C0-\u017F\d]+$/i;
6033
+ const RE_WORD_START = /^[a-zA-Z\u{C0}-\u{17F}\d]+/u;
6034
+ const RE_WORD_END = /[a-zA-Z\u{C0}-\u{17F}\d]+$/u;
6078
6035
 
6079
6036
  // @ts-ignore
6080
6037
  const getNewSelections$7 = (line, rowIndex, columnIndex) => {
@@ -6336,6 +6293,7 @@ const state$1 = {
6336
6293
  */
6337
6294
  currentEditor: undefined,
6338
6295
  hasListener: false,
6296
+ isSelecting: false,
6339
6297
  position: {
6340
6298
  columnIndex: 0,
6341
6299
  rowIndex: 0
@@ -6350,6 +6308,13 @@ const setEditor = editor => {
6350
6308
  const clearEditor = () => {
6351
6309
  state$1.currentEditor = undefined;
6352
6310
  state$1.hasListener = false;
6311
+ state$1.isSelecting = false;
6312
+ };
6313
+ const startSelecting = () => {
6314
+ state$1.isSelecting = true;
6315
+ };
6316
+ const isSelecting = () => {
6317
+ return state$1.isSelecting;
6353
6318
  };
6354
6319
 
6355
6320
  // @ts-ignore
@@ -6373,6 +6338,7 @@ const handlePointerCaptureLost = editor => {
6373
6338
  };
6374
6339
 
6375
6340
  const handlePointerDown$1 = (state, button, altKey, ctrlKey, x, y, detail) => {
6341
+ startSelecting();
6376
6342
  return handleMouseDown(state, button, altKey, ctrlKey, x, y, detail);
6377
6343
  };
6378
6344
 
@@ -6554,6 +6520,9 @@ const moveSelectionPx = async (editor, x, y) => {
6554
6520
  };
6555
6521
 
6556
6522
  const handlePointerMove = async (editor, x, y, altKey) => {
6523
+ if (!isSelecting()) {
6524
+ return editor;
6525
+ }
6557
6526
  if (altKey) {
6558
6527
  return moveRectangleSelectionPx(editor, x, y);
6559
6528
  }
@@ -6592,8 +6561,6 @@ const handleScrollBarHorizontalMove = (state, eventX) => {
6592
6561
  width,
6593
6562
  x
6594
6563
  } = state;
6595
- const spaceRight = 20; // TODO make this configurable
6596
- const normalizedEventX = clamp(eventX, x, x + width);
6597
6564
  if (width > longestLineWidth) {
6598
6565
  return {
6599
6566
  ...state,
@@ -6601,6 +6568,8 @@ const handleScrollBarHorizontalMove = (state, eventX) => {
6601
6568
  scrollBarWidth: 0
6602
6569
  };
6603
6570
  }
6571
+ const spaceRight = 20; // TODO make this configurable
6572
+ const normalizedEventX = clamp(eventX, x, x + width);
6604
6573
  const relativeX = normalizedEventX - x - handleOffsetX;
6605
6574
  const scrollBarWidth = getScrollBarWidth(width, longestLineWidth);
6606
6575
  const finalDeltaX = longestLineWidth - width + spaceRight;
@@ -6779,7 +6748,7 @@ const setDelta = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
6779
6748
  if (eventDeltaX === 0) {
6780
6749
  return setDeltaY(editor, eventDeltaY);
6781
6750
  }
6782
- const newDeltaX = clamp(deltaX + eventDeltaX, 0, Number.POSITIVE_INFINITY);
6751
+ const newDeltaX = clamp(deltaX + eventDeltaX, 0, Infinity);
6783
6752
  return {
6784
6753
  ...setDeltaY(editor, eventDeltaY),
6785
6754
  deltaX: newDeltaX
@@ -6850,22 +6819,19 @@ const getChanges$1 = selections => {
6850
6819
  rowsToIndent.push(i);
6851
6820
  }
6852
6821
  }
6853
- const changes = [];
6854
- for (const rowToIndent of rowsToIndent) {
6855
- changes.push({
6856
- deleted: [''],
6857
- end: {
6858
- columnIndex: 0,
6859
- rowIndex: rowToIndent
6860
- },
6861
- inserted: [' '],
6862
- origin: IndentMore,
6863
- start: {
6864
- columnIndex: 0,
6865
- rowIndex: rowToIndent
6866
- }
6867
- });
6868
- }
6822
+ const changes = Array.from(rowsToIndent, rowToIndent => ({
6823
+ deleted: [''],
6824
+ end: {
6825
+ columnIndex: 0,
6826
+ rowIndex: rowToIndent
6827
+ },
6828
+ inserted: [' '],
6829
+ origin: IndentMore,
6830
+ start: {
6831
+ columnIndex: 0,
6832
+ rowIndex: rowToIndent
6833
+ }
6834
+ }));
6869
6835
  return changes;
6870
6836
  };
6871
6837
  const indentMore = editor => {
@@ -6878,7 +6844,7 @@ const indentMore = editor => {
6878
6844
 
6879
6845
  const getLanguageConfiguration = async editor => {
6880
6846
  // @ts-ignore
6881
- return invoke$c('Languages.getLanguageConfiguration', {
6847
+ return invoke$b('Languages.getLanguageConfiguration', {
6882
6848
  languageId: editor.languageId,
6883
6849
  uri: editor.uri
6884
6850
  });
@@ -7385,12 +7351,12 @@ const print = error => {
7385
7351
  return `${error.type}: ${error.message}\n${error.stack}`;
7386
7352
  }
7387
7353
  if (error && error.stack) {
7388
- return `${error.stack}`;
7354
+ return error.stack;
7389
7355
  }
7390
7356
  if (error === null) {
7391
7357
  return null;
7392
7358
  }
7393
- return `${error}`;
7359
+ return String(error);
7394
7360
  };
7395
7361
 
7396
7362
  // @ts-nocheck
@@ -7420,7 +7386,7 @@ const isUntitledFile = uri => {
7420
7386
  };
7421
7387
 
7422
7388
  const saveNormalFile = async (uri, content) => {
7423
- await invoke$c('FileSystem.writeFile', uri, content);
7389
+ await invoke$b('FileSystem.writeFile', uri, content);
7424
7390
  };
7425
7391
 
7426
7392
  const showFilePicker = async platform => {
@@ -7440,9 +7406,9 @@ const saveUntitledFile = async (uri, content, platform) => {
7440
7406
  if (!filePath) {
7441
7407
  return;
7442
7408
  }
7443
- await invoke$c('FileSystem.writeFile', filePath, content);
7409
+ await invoke$b('FileSystem.writeFile', filePath, content);
7444
7410
  await handleWorkspaceRefresh();
7445
- await invoke$c('Main.handleUriChange', uri, filePath);
7411
+ await invoke$b('Main.handleUriChange', uri, filePath);
7446
7412
  return filePath;
7447
7413
  };
7448
7414
 
@@ -7464,9 +7430,8 @@ const save = async editor => {
7464
7430
  };
7465
7431
  }
7466
7432
  return newEditor;
7467
- } else {
7468
- await saveNormalFile(uri, content);
7469
7433
  }
7434
+ await saveNormalFile(uri, content);
7470
7435
  return {
7471
7436
  ...newEditor,
7472
7437
  modified: false
@@ -7774,7 +7739,7 @@ const selectInsideString = editor => {
7774
7739
 
7775
7740
  const getNewSelections = async (editor, selections) => {
7776
7741
  // @ts-ignore
7777
- const newSelections = await invoke$c('ExtensionHostSelection.executeGrowSelection', editor, selections);
7742
+ const newSelections = await invoke$b('ExtensionHostSelection.executeGrowSelection', editor, selections);
7778
7743
  if (newSelections.length === 0) {
7779
7744
  return selections;
7780
7745
  }
@@ -7802,7 +7767,7 @@ const selectionGrow = async editor => {
7802
7767
  // ccc
7803
7768
 
7804
7769
  // when clicking first at position 4 and then position 2,
7805
- // - vscode selects next position 3 and refuses to select position 1
7770
+ // - VS Code selects next position 3 and refuses to select position 1
7806
7771
  // - atom also selects next position 3 and refuses to select position 1
7807
7772
  // - WebStorm also selects next position 3 and refuses to select position 1
7808
7773
  // - brackets (codemirror) selects position 3 and then selects position 1
@@ -7863,25 +7828,25 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
7863
7828
  startRowIndex = selections[selectionIndex];
7864
7829
  const startColumnIndex = selections[selectionIndex + 1];
7865
7830
  const endColumnIndex = selections[selectionIndex + 3];
7866
- if (startRowIndex === i && startColumnIndex <= columnIndex && columnIndex <= endColumnIndex) {
7867
- continue;
7868
- }
7869
- if (startRowIndex > i) {
7870
- selectionIndex -= 4;
7831
+ const isSelected = startRowIndex === i && startColumnIndex <= columnIndex && columnIndex <= endColumnIndex;
7832
+ if (!isSelected) {
7833
+ if (startRowIndex > i) {
7834
+ selectionIndex -= 4;
7835
+ }
7836
+ const columnEndIndex = columnIndex + word.length;
7837
+ selectionIndex += 4;
7838
+ const newSelections = new Uint32Array(selections.length + 4);
7839
+ newSelections.set(selections.subarray(0, selectionIndex), 0);
7840
+ newSelections[selectionIndex] = i;
7841
+ newSelections[selectionIndex + 1] = columnIndex;
7842
+ newSelections[selectionIndex + 2] = i;
7843
+ newSelections[selectionIndex + 3] = columnEndIndex;
7844
+ newSelections.set(selections.subarray(selectionIndex), selectionIndex + 4);
7845
+ return {
7846
+ revealRange: newSelections.length - 4,
7847
+ selectionEdits: newSelections
7848
+ };
7871
7849
  }
7872
- const columnEndIndex = columnIndex + word.length;
7873
- selectionIndex += 4;
7874
- const newSelections = new Uint32Array(selections.length + 4);
7875
- newSelections.set(selections.subarray(0, selectionIndex), 0);
7876
- newSelections[selectionIndex] = i;
7877
- newSelections[selectionIndex + 1] = columnIndex;
7878
- newSelections[selectionIndex + 2] = i;
7879
- newSelections[selectionIndex + 3] = columnEndIndex;
7880
- newSelections.set(selections.subarray(selectionIndex), selectionIndex + 4);
7881
- return {
7882
- revealRange: newSelections.length - 4,
7883
- selectionEdits: newSelections
7884
- };
7885
7850
  }
7886
7851
  }
7887
7852
  return undefined;
@@ -7936,13 +7901,13 @@ const getSelectNextOccurrenceResult = editor => {
7936
7901
  // ccc
7937
7902
 
7938
7903
  // when clicking first at position 4 and then position 2,
7939
- // - vscode selects next position 3 and refuses to select position 1
7904
+ // - VS Code selects next position 3 and refuses to select position 1
7940
7905
  // - atom also selects next position 3 and refuses to select position 1
7941
7906
  // - WebStorm also selects next position 3 and refuses to select position 1
7942
7907
  // - brackets (codemirror) selects position 3 and then selects position 1
7943
7908
  // - sublime selects next position 1, then next position 3
7944
7909
 
7945
- const isRangeInViewPort = (minLineY, maxLineY, startRowIndex, endRowIndex) => {
7910
+ const isRangeInViewport = (minLineY, maxLineY, startRowIndex, endRowIndex) => {
7946
7911
  return startRowIndex >= minLineY && endRowIndex <= maxLineY;
7947
7912
  };
7948
7913
 
@@ -7953,14 +7918,12 @@ const selectNextOccurrence = editor => {
7953
7918
  return editor;
7954
7919
  }
7955
7920
  const {
7956
- revealRange
7957
- } = result;
7958
- const {
7921
+ revealRange,
7959
7922
  selectionEdits
7960
7923
  } = result;
7961
7924
  const revealRangeStartRowIndex = selectionEdits[revealRange];
7962
7925
  const revealRangeEndRowIndex = selectionEdits[revealRange + 2];
7963
- if (isRangeInViewPort(editor.minLineY, editor.maxLineY, revealRangeStartRowIndex, revealRangeEndRowIndex)) {
7926
+ if (isRangeInViewport(editor.minLineY, editor.maxLineY, revealRangeStartRowIndex, revealRangeEndRowIndex)) {
7964
7927
  return scheduleSelections(editor, selectionEdits);
7965
7928
  }
7966
7929
  // TODO what is this magic number 5?
@@ -8207,7 +8170,7 @@ const showHover3 = async editor => {
8207
8170
 
8208
8171
  const EditorHover = 'EditorHover';
8209
8172
  const showHover = async state => {
8210
- await invoke$c('Viewlet.openWidget', EditorHover);
8173
+ await invoke$b('Viewlet.openWidget', EditorHover);
8211
8174
  return state;
8212
8175
  };
8213
8176
 
@@ -8470,9 +8433,7 @@ const editorSnippet = (editor, snippet) => {
8470
8433
  return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
8471
8434
  };
8472
8435
 
8473
- const getErrorMessage = error => {
8474
- return `${error}`;
8475
- };
8436
+ const getErrorMessage = String;
8476
8437
  const tabCompletion = async editor => {
8477
8438
  try {
8478
8439
  // TODO race condition
@@ -8498,7 +8459,7 @@ const getBlockComment = async (editor, offset) => {
8498
8459
  } = editor;
8499
8460
  // TODO ask extension host worker,
8500
8461
  // execute block comment provider with
8501
- // uri, language id, offset
8462
+ // URI, language id, offset
8502
8463
  // and the extension returns a matching block comment or undefined
8503
8464
  try {
8504
8465
  await activateByEvent(`onLanguage:${editor.languageId}`, assetDir, platform);
@@ -8760,7 +8721,7 @@ const toggleComment = async editor => {
8760
8721
  } catch (error$1) {
8761
8722
  error(error$1);
8762
8723
  // TODO use correct position
8763
- await editorShowMessage(/* editor */editor, /* rowIndex */0, /* columnIndex */0, /* message */`${error$1}`, /* isError */true);
8724
+ await editorShowMessage(/* editor */editor, /* rowIndex */0, /* columnIndex */0, /* message */String(error$1), /* isError */true);
8764
8725
  return editor;
8765
8726
  }
8766
8727
  };
@@ -8853,7 +8814,7 @@ const typeWithAutoClosingQuote = (editor, text) => {
8853
8814
  const typeWithAutoClosingTag = async (editor, text) => {
8854
8815
  const offset = offsetAt(editor, editor.selections[0], editor.selections[1]);
8855
8816
  // @ts-ignore
8856
- const result = await invoke$c('ExtensionHostClosingTagCompletion.executeClosingTagProvider', editor, offset, text);
8817
+ const result = await invoke$b('ExtensionHostClosingTagCompletion.executeClosingTagProvider', editor, offset, text);
8857
8818
  if (!result) {
8858
8819
  const changes = editorReplaceSelections(editor, [text], EditorType);
8859
8820
  return scheduleDocumentAndCursorsSelections(editor, changes);
@@ -9105,7 +9066,7 @@ const addWidget$1 = (widget, id, render) => {
9105
9066
  // 1. renderDom
9106
9067
  // 2. renderAriaAnnouncement
9107
9068
  // 3. renderFocus
9108
- // to ensure that focus is always after the element is added to the dom
9069
+ // to ensure that focus is always after the element is added to the DOM
9109
9070
  if (focusCommandIndex !== -1) {
9110
9071
  const command = allCommands[focusCommandIndex];
9111
9072
  allCommands.splice(focusCommandIndex, 1);
@@ -9212,6 +9173,7 @@ const renderFull$4 = (oldState, newState) => {
9212
9173
  return commands;
9213
9174
  };
9214
9175
 
9176
+ const commandsToForward$5 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
9215
9177
  const render$b = widget => {
9216
9178
  const commands = renderFull$4(widget.oldState, widget.newState);
9217
9179
  const wrappedCommands = [];
@@ -9219,7 +9181,7 @@ const render$b = widget => {
9219
9181
  uid
9220
9182
  } = widget.newState;
9221
9183
  for (const command of commands) {
9222
- if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
9184
+ if (commandsToForward$5.includes(command[0])) {
9223
9185
  wrappedCommands.push(command);
9224
9186
  } else {
9225
9187
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -9284,6 +9246,7 @@ const renderFull$3 = (oldState, newState) => {
9284
9246
  return commands;
9285
9247
  };
9286
9248
 
9249
+ const commandsToForward$4 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
9287
9250
  const render$a = widget => {
9288
9251
  const commands = renderFull$3(widget.oldState, widget.newState);
9289
9252
  const wrappedCommands = [];
@@ -9291,7 +9254,7 @@ const render$a = widget => {
9291
9254
  uid
9292
9255
  } = widget.newState;
9293
9256
  for (const command of commands) {
9294
- if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
9257
+ if (commandsToForward$4.includes(command[0])) {
9295
9258
  wrappedCommands.push(command);
9296
9259
  } else {
9297
9260
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -9715,9 +9678,7 @@ const renderHoverDom = {
9715
9678
  const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
9716
9679
  return [/* method */SetDom2, dom];
9717
9680
  },
9718
- isEqual(oldState, newState) {
9719
- return oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics;
9720
- }
9681
+ isEqual: (oldState, newState) => oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics
9721
9682
  };
9722
9683
  const renderBounds$2 = {
9723
9684
  apply(oldState, newState) {
@@ -9729,9 +9690,7 @@ const renderBounds$2 = {
9729
9690
  } = newState;
9730
9691
  return [SetBounds, x, y, width, height];
9731
9692
  },
9732
- isEqual(oldState, newState) {
9733
- return oldState.x === newState.x && oldState.y === newState.y;
9734
- }
9693
+ isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y
9735
9694
  };
9736
9695
  const render$9 = [renderHoverDom, renderBounds$2];
9737
9696
  const renderHover = (oldState, newState) => {
@@ -9744,6 +9703,7 @@ const renderHover = (oldState, newState) => {
9744
9703
  return commands;
9745
9704
  };
9746
9705
 
9706
+ const commandsToForward$3 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
9747
9707
  const render$8 = widget => {
9748
9708
  const commands = renderFull$4(widget.oldState, widget.newState);
9749
9709
  const wrappedCommands = [];
@@ -9751,7 +9711,7 @@ const render$8 = widget => {
9751
9711
  uid
9752
9712
  } = widget.newState;
9753
9713
  for (const command of commands) {
9754
- if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
9714
+ if (commandsToForward$3.includes(command[0])) {
9755
9715
  wrappedCommands.push(command);
9756
9716
  } else {
9757
9717
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -9804,6 +9764,7 @@ const removeWidget$1 = widget => {
9804
9764
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
9805
9765
  };
9806
9766
 
9767
+ const commandsToForward$2 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
9807
9768
  const render$7 = widget => {
9808
9769
  const commands = renderFull$4(widget.oldState, widget.newState);
9809
9770
  const wrappedCommands = [];
@@ -9811,7 +9772,7 @@ const render$7 = widget => {
9811
9772
  uid
9812
9773
  } = widget.newState;
9813
9774
  for (const command of commands) {
9814
- if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
9775
+ if (commandsToForward$2.includes(command[0])) {
9815
9776
  wrappedCommands.push(command);
9816
9777
  } else {
9817
9778
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -9908,7 +9869,7 @@ const getEditorSourceActions = async editorId => {
9908
9869
  languageId
9909
9870
  } = newState;
9910
9871
  // @ts-ignore
9911
- const allActions = await invoke$c('GetEditorSourceActions.getEditorSourceActions');
9872
+ const allActions = await invoke$b('GetEditorSourceActions.getEditorSourceActions');
9912
9873
  const filtered = filterActions(allActions, languageId);
9913
9874
  return filtered;
9914
9875
  };
@@ -9931,14 +9892,14 @@ const getWordAtOffset = editor => {
9931
9892
  };
9932
9893
 
9933
9894
  const setFocus = async focusKey => {
9934
- await invoke$c('Focus.setFocus', focusKey);
9895
+ await invoke$b('Focus.setFocus', focusKey);
9935
9896
  };
9936
9897
  const unsetAdditionalFocus = async focusKey => {
9937
9898
  if (!focusKey) {
9938
9899
  return;
9939
9900
  }
9940
9901
  // @ts-ignore
9941
- await invoke$c('Focus.removeAdditionalFocus', focusKey);
9902
+ await invoke$b('Focus.removeAdditionalFocus', focusKey);
9942
9903
  };
9943
9904
 
9944
9905
  const shouldUpdateSelectionData = (oldState, newState) => {
@@ -10094,7 +10055,7 @@ const getDiagnostics$1 = async editorUid => {
10094
10055
  };
10095
10056
 
10096
10057
  const ensure = async (fontName, fontUrl) => {
10097
- await invoke$b('TextMeasurement.ensureFont', fontName, fontUrl);
10058
+ await invoke$c('TextMeasurement.ensureFont', fontName, fontUrl);
10098
10059
  };
10099
10060
 
10100
10061
  const getKeyBindings = () => {
@@ -10652,7 +10613,7 @@ const handleBeforeInput = (editor, inputType, data) => {
10652
10613
  };
10653
10614
 
10654
10615
  const handleMessagePort = async (port, rpcId) => {
10655
- const rpc = await create$c({
10616
+ const rpc = await create$b({
10656
10617
  commandMap: {},
10657
10618
  messagePort: port
10658
10619
  });
@@ -10761,73 +10722,10 @@ const hotReload = async () => {
10761
10722
 
10762
10723
  // TODO ask renderer worker to rerender all editors
10763
10724
  // @ts-ignore
10764
- await invoke$c(`Editor.rerender`);
10725
+ await invoke$b(`Editor.rerender`);
10765
10726
  isReloading = false;
10766
10727
  };
10767
10728
 
10768
- const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
10769
- await sendMessagePortToExtensionHostWorker(port, rpcId);
10770
- };
10771
-
10772
- const createExtensionHostRpc = async () => {
10773
- try {
10774
- const initialCommand = 'HandleMessagePort.handleMessagePort2';
10775
- const rpc = await create$e({
10776
- commandMap: {},
10777
- async send(port) {
10778
- await sendMessagePortToExtensionHostWorker2(port, initialCommand, EditorWorker);
10779
- }
10780
- });
10781
- return rpc;
10782
- } catch (error) {
10783
- throw new VError(error, `Failed to create extension host rpc`);
10784
- }
10785
- };
10786
-
10787
- const initializeExtensionHost = async () => {
10788
- const extensionHostRpc = await createExtensionHostRpc();
10789
- set$1(extensionHostRpc);
10790
- };
10791
-
10792
- const createExtensionManagementWorkerRpc = async () => {
10793
- try {
10794
- const rpc = await create$e({
10795
- commandMap: {},
10796
- async send(port) {
10797
- await sendMessagePortToExtensionManagementWorker$1(port, EditorWorker);
10798
- }
10799
- });
10800
- return rpc;
10801
- } catch (error) {
10802
- throw new VError(error, `Failed to create extension management worker rpc`);
10803
- }
10804
- };
10805
-
10806
- const initializeExtensionManagementWorker = async () => {
10807
- try {
10808
- const rpc = await createExtensionManagementWorkerRpc();
10809
- set$c(rpc);
10810
- } catch {
10811
- // ignore
10812
- }
10813
- };
10814
-
10815
- const send$1 = port => {
10816
- // @ts-ignore
10817
- return sendMessagePortToOpenerWorker(port);
10818
- };
10819
- const initializeOpenerWorker = async () => {
10820
- try {
10821
- const rpc = await create$d({
10822
- commandMap: {},
10823
- send: send$1
10824
- });
10825
- set$b(rpc);
10826
- } catch {
10827
- // ignore
10828
- }
10829
- };
10830
-
10831
10729
  const sendMessagePortToSyntaxHighlightingWorker = async port => {
10832
10730
  try {
10833
10731
  await sendMessagePortToSyntaxHighlightingWorker$1(port);
@@ -10841,7 +10739,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
10841
10739
 
10842
10740
  const createSyntaxHighlightingWorkerRpc = async () => {
10843
10741
  try {
10844
- const rpc = await create$e({
10742
+ const rpc = await create$d({
10845
10743
  commandMap: {},
10846
10744
  send: sendMessagePortToSyntaxHighlightingWorker
10847
10745
  });
@@ -10862,17 +10760,6 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
10862
10760
  }
10863
10761
  };
10864
10762
 
10865
- const send = port => {
10866
- return sendMessagePortToTextMeasurementWorker(port);
10867
- };
10868
- const initializeTextMeasurementWorker = async () => {
10869
- const rpc = await create$d({
10870
- commandMap: {},
10871
- send
10872
- });
10873
- set$9(rpc);
10874
- };
10875
-
10876
10763
  const launchCompletionWorker = async () => {
10877
10764
  const name = 'Completion Worker';
10878
10765
  const url = 'completionWorkerMain.js';
@@ -10883,7 +10770,7 @@ const launchCompletionWorker = async () => {
10883
10770
 
10884
10771
  const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
10885
10772
  setFactory(launchCompletionWorker);
10886
- await Promise.all([initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental), initializeExtensionHost(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
10773
+ await initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental);
10887
10774
  };
10888
10775
 
10889
10776
  const kLineHeight = 'editor.lineHeight';
@@ -11067,8 +10954,8 @@ const loadContent = async (state, savedState) => {
11067
10954
  };
11068
10955
 
11069
10956
  // TODO move cursor
11070
- // TODO multiple cursors -> vscode removes multiple cursors
11071
- // TODO with selection -> vscode moves whole selection
10957
+ // TODO multiple cursors -> VS Code removes multiple cursors
10958
+ // TODO with selection -> VS Code moves whole selection
11072
10959
  const moveLineDown = editor => {
11073
10960
  // const rowIndex = editor.cursor.rowIndex
11074
10961
  // if (rowIndex === editor.lines.length - 1) {
@@ -11243,12 +11130,12 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
11243
11130
  };
11244
11131
 
11245
11132
  const compareNodes = (oldNode, newNode) => {
11246
- const patches = [];
11247
11133
  // Check if node type changed - return null to signal incompatible nodes
11248
11134
  // (caller should handle this with a Replace operation)
11249
11135
  if (oldNode.type !== newNode.type) {
11250
11136
  return null;
11251
11137
  }
11138
+ const patches = [];
11252
11139
  // Handle reference nodes - special handling for uid changes
11253
11140
  if (oldNode.type === Reference) {
11254
11141
  if (oldNode.uid !== newNode.uid) {
@@ -11284,7 +11171,7 @@ const compareNodes = (oldNode, newNode) => {
11284
11171
  }
11285
11172
  // Check for removed attributes
11286
11173
  for (const key of oldKeys) {
11287
- if (!(key in newNode)) {
11174
+ if (!Object.hasOwn(newNode, key)) {
11288
11175
  patches.push({
11289
11176
  type: RemoveAttribute,
11290
11177
  key
@@ -11460,15 +11347,12 @@ const getEditorInputVirtualDom = () => {
11460
11347
  };
11461
11348
 
11462
11349
  const getCursorsVirtualDom = cursors => {
11463
- const dom = [];
11464
- for (const translate of cursors) {
11465
- dom.push({
11466
- childCount: 0,
11467
- className: EditorCursor,
11468
- translate,
11469
- type: Div
11470
- });
11471
- }
11350
+ const dom = Array.from(cursors, translate => ({
11351
+ childCount: 0,
11352
+ className: EditorCursor,
11353
+ translate,
11354
+ type: Div
11355
+ }));
11472
11356
  return dom;
11473
11357
  };
11474
11358
 
@@ -11822,9 +11706,7 @@ const renderLines = {
11822
11706
  const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine);
11823
11707
  return [/* method */'setText', dom];
11824
11708
  },
11825
- isEqual(oldState, newState) {
11826
- return oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled;
11827
- }
11709
+ isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
11828
11710
  };
11829
11711
  const renderSelections = {
11830
11712
  apply: (oldState, newState) => {
@@ -11836,9 +11718,7 @@ const renderSelections = {
11836
11718
  const selectionsDom = getSelectionsVirtualDom(selectionInfos);
11837
11719
  return [/* method */'setSelections', cursorsDom, selectionsDom];
11838
11720
  },
11839
- isEqual(oldState, newState) {
11840
- return oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos;
11841
- }
11721
+ isEqual: (oldState, newState) => oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos
11842
11722
  };
11843
11723
  const renderScrollBarY = {
11844
11724
  apply(oldState, newState) {
@@ -11847,9 +11727,7 @@ const renderScrollBarY = {
11847
11727
  const heightPx = `${newState.scrollBarHeight}px`;
11848
11728
  return [/* method */'setScrollBar', translate, heightPx];
11849
11729
  },
11850
- isEqual(oldState, newState) {
11851
- return oldState.deltaY === newState.deltaY && oldState.scrollBarHeight === newState.scrollBarHeight;
11852
- }
11730
+ isEqual: (oldState, newState) => oldState.deltaY === newState.deltaY && oldState.scrollBarHeight === newState.scrollBarHeight
11853
11731
  };
11854
11732
  const renderScrollBarX = {
11855
11733
  apply(oldState, newState) {
@@ -11857,25 +11735,15 @@ const renderScrollBarX = {
11857
11735
  const scrollBarX = newState.deltaX / newState.longestLineWidth * newState.width;
11858
11736
  return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
11859
11737
  },
11860
- isEqual(oldState, newState) {
11861
- return oldState.longestLineWidth === newState.longestLineWidth && oldState.deltaX === newState.deltaX;
11862
- }
11738
+ isEqual: (oldState, newState) => oldState.longestLineWidth === newState.longestLineWidth && oldState.deltaX === newState.deltaX
11863
11739
  };
11864
11740
  const renderFocus$1 = {
11865
- apply(oldState, newState) {
11866
- return [/* method */'setFocused', newState.focused];
11867
- },
11868
- isEqual(oldState, newState) {
11869
- return oldState.focused === newState.focused;
11870
- }
11741
+ apply: (oldState, newState) => [/* method */'setFocused', newState.focused],
11742
+ isEqual: (oldState, newState) => oldState.focused === newState.focused
11871
11743
  };
11872
11744
  const renderFocusContext = {
11873
- apply(oldState, newState) {
11874
- return [SetFocusContext$1, newState.uid, newState.focus, 0, newState.uid, 'Editor'];
11875
- },
11876
- isEqual(oldState, newState) {
11877
- return oldState.focus === newState.focus;
11878
- }
11745
+ apply: (oldState, newState) => [SetFocusContext$1, newState.uid, newState.focus, 0, newState.uid, 'Editor'],
11746
+ isEqual: (oldState, newState) => oldState.focus === newState.focus
11879
11747
  };
11880
11748
  const renderAdditionalFocusContext = {
11881
11749
  apply(oldState, newState) {
@@ -11884,18 +11752,14 @@ const renderAdditionalFocusContext = {
11884
11752
  }
11885
11753
  return ['viewlet.unsetAdditionalFocus', newState.uid, newState.additionalFocus];
11886
11754
  },
11887
- isEqual(oldState, newState) {
11888
- return oldState.additionalFocus === newState.additionalFocus;
11889
- }
11755
+ isEqual: (oldState, newState) => oldState.additionalFocus === newState.additionalFocus
11890
11756
  };
11891
11757
  const renderDecorations = {
11892
11758
  apply(oldState, newState) {
11893
11759
  const dom = getDiagnosticsVirtualDom(newState.visualDecorations || []);
11894
11760
  return ['setDecorationsDom', dom];
11895
11761
  },
11896
- isEqual(oldState, newState) {
11897
- return oldState.visualDecorations === newState.visualDecorations;
11898
- }
11762
+ isEqual: (oldState, newState) => oldState.visualDecorations === newState.visualDecorations
11899
11763
  };
11900
11764
  const renderGutterInfo = {
11901
11765
  apply(oldState, newState) {
@@ -11913,9 +11777,7 @@ const renderGutterInfo = {
11913
11777
  const dom = getEditorGutterVirtualDom$1(gutterInfos);
11914
11778
  return ['renderGutter', dom];
11915
11779
  },
11916
- isEqual(oldState, newState) {
11917
- return oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY;
11918
- }
11780
+ isEqual: (oldState, newState) => oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY
11919
11781
  };
11920
11782
  const renderWidgets = {
11921
11783
  apply(oldState, newState) {
@@ -11933,14 +11795,14 @@ const renderWidgets = {
11933
11795
  newWidgetMap[newWidget.id] = newWidget;
11934
11796
  }
11935
11797
  for (const oldWidget of oldWidgets) {
11936
- if (oldWidget.id in newWidgetMap) {
11798
+ if (Object.hasOwn(newWidgetMap, oldWidget.id)) {
11937
11799
  changedWidgets.push(newWidgetMap[oldWidget.id]);
11938
11800
  } else {
11939
11801
  removedWidgets.push(oldWidget);
11940
11802
  }
11941
11803
  }
11942
11804
  for (const newWidget of newWidgets) {
11943
- if (newWidget.id in oldWidgetMap) ; else {
11805
+ if (Object.hasOwn(oldWidgetMap, newWidget.id)) ; else {
11944
11806
  addedWidgets.push(newWidget);
11945
11807
  }
11946
11808
  }
@@ -11969,9 +11831,7 @@ const renderWidgets = {
11969
11831
  const filteredCommands = allCommands.filter(item => item[0] !== 'Viewlet.setFocusContext');
11970
11832
  return filteredCommands;
11971
11833
  },
11972
- isEqual(oldState, newState) {
11973
- return oldState.widgets === newState.widgets;
11974
- },
11834
+ isEqual: (oldState, newState) => oldState.widgets === newState.widgets,
11975
11835
  multiple: true
11976
11836
  };
11977
11837
  const render$6 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
@@ -12085,6 +11945,10 @@ const saveState = (state, savedState) => {
12085
11945
  };
12086
11946
  };
12087
11947
 
11948
+ const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
11949
+ await sendMessagePortToExtensionHostWorker(port, rpcId);
11950
+ };
11951
+
12088
11952
  const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
12089
11953
  await sendMessagePortToExtensionManagementWorker$1(port, rpcId);
12090
11954
  };
@@ -12135,7 +11999,7 @@ const updateDebugInfo = async debugId => {
12135
11999
  };
12136
12000
  set$7(key, oldState, newEditor);
12137
12001
  // @ts-ignore
12138
- await invoke$c('Editor.rerender', key);
12002
+ await invoke$b('Editor.rerender', key);
12139
12003
  };
12140
12004
 
12141
12005
  // TODO wrap commands globally, not per editor
@@ -12422,14 +12286,76 @@ for (const [key, value] of Object.entries(commandMap)) {
12422
12286
  }
12423
12287
  }
12424
12288
 
12425
- const listen = async () => {
12426
- registerCommands(commandMap);
12427
- const rpc = await create$b({
12289
+ const createExtensionHostRpc = async () => {
12290
+ const initialCommand = 'HandleMessagePort.handleMessagePort2';
12291
+ const rpc = await create$c({
12292
+ commandMap: {},
12293
+ async send(port) {
12294
+ await sendMessagePortToExtensionHostWorker2(port, initialCommand, EditorWorker);
12295
+ }
12296
+ });
12297
+ return rpc;
12298
+ };
12299
+
12300
+ const initializeExtensionHost = async () => {
12301
+ const extensionHostRpc = await createExtensionHostRpc();
12302
+ set$1(extensionHostRpc);
12303
+ };
12304
+
12305
+ const createExtensionManagementWorkerRpc = async () => {
12306
+ const rpc = await create$c({
12307
+ commandMap: {},
12308
+ async send(port) {
12309
+ await sendMessagePortToExtensionManagementWorker$1(port, EditorWorker);
12310
+ }
12311
+ });
12312
+ return rpc;
12313
+ };
12314
+
12315
+ const initializeExtensionManagementWorker = async () => {
12316
+ try {
12317
+ const rpc = await createExtensionManagementWorkerRpc();
12318
+ set$c(rpc);
12319
+ } catch {
12320
+ // ignore
12321
+ }
12322
+ };
12323
+
12324
+ const send$1 = port => {
12325
+ // @ts-ignore
12326
+ return sendMessagePortToOpenerWorker(port);
12327
+ };
12328
+ const initializeOpenerWorker = async () => {
12329
+ const rpc = await create$c({
12330
+ commandMap: {},
12331
+ send: send$1
12332
+ });
12333
+ set$b(rpc);
12334
+ };
12335
+
12336
+ const initializeRendererWorker = async () => {
12337
+ const rpc = await create$a({
12428
12338
  commandMap: commandMap
12429
12339
  });
12340
+ set$9(rpc);
12341
+ };
12342
+
12343
+ const send = port => {
12344
+ return sendMessagePortToTextMeasurementWorker(port);
12345
+ };
12346
+ const initializeTextMeasurementWorker = async () => {
12347
+ const rpc = await create$c({
12348
+ commandMap: {},
12349
+ send
12350
+ });
12430
12351
  set$a(rpc);
12431
12352
  };
12432
12353
 
12354
+ const listen = async () => {
12355
+ registerCommands(commandMap);
12356
+ await Promise.all([initializeRendererWorker(), initializeExtensionHost(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
12357
+ };
12358
+
12433
12359
  const CodeGeneratorInput = 'CodeGeneratorInput';
12434
12360
 
12435
12361
  const getCodeGeneratorVirtualDom = state => {
@@ -12457,9 +12383,7 @@ const renderContent$1 = {
12457
12383
  const dom = getCodeGeneratorVirtualDom();
12458
12384
  return [SetDom2, newState.uid, dom];
12459
12385
  },
12460
- isEqual(oldState, newState) {
12461
- return oldState.questions === newState.questions;
12462
- }
12386
+ isEqual: (oldState, newState) => oldState.questions === newState.questions
12463
12387
  };
12464
12388
  const renderBounds$1 = {
12465
12389
  apply(oldState, newState) {
@@ -12471,17 +12395,11 @@ const renderBounds$1 = {
12471
12395
  } = newState;
12472
12396
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
12473
12397
  },
12474
- isEqual(oldState, newState) {
12475
- return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
12476
- }
12398
+ isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height
12477
12399
  };
12478
12400
  const renderFocus = {
12479
- apply(oldState, newState) {
12480
- return [Focus, '.CodeGeneratorInput', newState.focusSource];
12481
- },
12482
- isEqual(oldState, newState) {
12483
- return oldState.focused === newState.focused && oldState.focusSource === newState.focusSource;
12484
- }
12401
+ apply: (oldState, newState) => [Focus, '.CodeGeneratorInput', newState.focusSource],
12402
+ isEqual: (oldState, newState) => oldState.focused === newState.focused && oldState.focusSource === newState.focusSource
12485
12403
  };
12486
12404
  const render$5 = [renderContent$1, renderBounds$1, renderFocus];
12487
12405
  const renderFull$2 = (oldState, newState) => {
@@ -12529,6 +12447,7 @@ const renderFull$1 = (oldState, newState) => {
12529
12447
  return commands;
12530
12448
  };
12531
12449
 
12450
+ const commandsToForward$1 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetUid];
12532
12451
  const render$3 = widget => {
12533
12452
  const commands = renderFull$1(widget.oldState, widget.newState);
12534
12453
  const wrappedCommands = [];
@@ -12536,7 +12455,7 @@ const render$3 = widget => {
12536
12455
  uid
12537
12456
  } = widget.newState;
12538
12457
  for (const command of commands) {
12539
- if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetUid) {
12458
+ if (commandsToForward$1.includes(command[0])) {
12540
12459
  wrappedCommands.push(command);
12541
12460
  } else {
12542
12461
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -12595,9 +12514,7 @@ const renderContent = {
12595
12514
  const dom = getCompletionDetailVirtualDom(newState.content);
12596
12515
  return [SetDom2, newState.uid, dom];
12597
12516
  },
12598
- isEqual(oldState, newState) {
12599
- return oldState.content === newState.content;
12600
- }
12517
+ isEqual: (oldState, newState) => oldState.content === newState.content
12601
12518
  };
12602
12519
  const renderBounds = {
12603
12520
  apply(oldState, newState) {
@@ -12609,9 +12526,7 @@ const renderBounds = {
12609
12526
  } = newState;
12610
12527
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
12611
12528
  },
12612
- isEqual(oldState, newState) {
12613
- return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
12614
- }
12529
+ isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height
12615
12530
  };
12616
12531
  const render$2 = [renderContent, renderBounds];
12617
12532
  const renderFull = (oldState, newState) => {
@@ -12683,6 +12598,7 @@ const EditorCompletionDetailWidget = {
12683
12598
  render: render$1
12684
12599
  };
12685
12600
 
12601
+ const commandsToForward = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
12686
12602
  const render = widget => {
12687
12603
  const commands = renderFull$4(widget.oldState, widget.newState);
12688
12604
  const wrappedCommands = [];
@@ -12690,7 +12606,7 @@ const render = widget => {
12690
12606
  uid
12691
12607
  } = widget.newState;
12692
12608
  for (const command of commands) {
12693
- if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
12609
+ if (commandsToForward.includes(command[0])) {
12694
12610
  wrappedCommands.push(command);
12695
12611
  } else {
12696
12612
  wrappedCommands.push(['Viewlet.send', uid, ...command]);