@lvce-editor/main-area-worker 9.32.5 → 9.33.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,249 +1,3 @@
1
- const toCommandId = key => {
2
- const dotIndex = key.indexOf('.');
3
- return key.slice(dotIndex + 1);
4
- };
5
- const create$f = () => {
6
- const commandQueues = new Map();
7
- const generations = Object.create(null);
8
- const states = Object.create(null);
9
- const commandMapRef = {};
10
- const getGeneration = uid => generations[uid] || 0;
11
- const isCurrentGeneration = (uid, generation) => {
12
- return states[uid] !== undefined && getGeneration(uid) === generation;
13
- };
14
- const updateState = (uid, generation, fallbackState, updater) => {
15
- if (!isCurrentGeneration(uid, generation)) {
16
- return Promise.resolve(fallbackState);
17
- }
18
- const current = states[uid];
19
- const updatedState = updater(current.newState);
20
- if (updatedState !== current.newState) {
21
- states[uid] = {
22
- newState: updatedState,
23
- oldState: current.oldState,
24
- scheduledState: updatedState
25
- };
26
- }
27
- return Promise.resolve(updatedState);
28
- };
29
- const createAsyncCommandContext = (uid, generation) => {
30
- let latestState = states[uid].newState;
31
- return {
32
- getState: () => {
33
- if (isCurrentGeneration(uid, generation)) {
34
- latestState = states[uid].newState;
35
- }
36
- return latestState;
37
- },
38
- updateState: async updater => {
39
- latestState = await updateState(uid, generation, latestState, updater);
40
- return latestState;
41
- }
42
- };
43
- };
44
- const enqueueCommand = async (uid, command) => {
45
- const previous = commandQueues.get(uid) || Promise.resolve();
46
- const run = async () => {
47
- try {
48
- await previous;
49
- } catch {
50
- // The previous caller receives its error; later commands must still run.
51
- }
52
- await command();
53
- };
54
- const current = run();
55
- commandQueues.set(uid, current);
56
- try {
57
- await current;
58
- } finally {
59
- if (commandQueues.get(uid) === current) {
60
- commandQueues.delete(uid);
61
- }
62
- }
63
- };
64
- return {
65
- clear() {
66
- commandQueues.clear();
67
- for (const key of Object.keys(states)) {
68
- delete states[key];
69
- }
70
- },
71
- diff(uid, modules, numbers) {
72
- const {
73
- oldState,
74
- scheduledState
75
- } = states[uid];
76
- const diffResult = [];
77
- for (let i = 0; i < modules.length; i++) {
78
- const fn = modules[i];
79
- if (!fn(oldState, scheduledState)) {
80
- diffResult.push(numbers[i]);
81
- }
82
- }
83
- return diffResult;
84
- },
85
- dispose(uid) {
86
- commandQueues.delete(uid);
87
- delete states[uid];
88
- },
89
- get(uid) {
90
- return states[uid];
91
- },
92
- getCommandIds() {
93
- const keys = Object.keys(commandMapRef);
94
- const ids = keys.map(toCommandId);
95
- return ids;
96
- },
97
- getKeys() {
98
- return Object.keys(states).map(Number);
99
- },
100
- registerCommands(commandMap) {
101
- Object.assign(commandMapRef, commandMap);
102
- },
103
- set(uid, oldState, newState, scheduledState) {
104
- const current = states[uid];
105
- if (!current || oldState === newState && newState !== current.newState) {
106
- generations[uid] = getGeneration(uid) + 1;
107
- }
108
- states[uid] = {
109
- newState,
110
- oldState,
111
- scheduledState: scheduledState ?? newState
112
- };
113
- },
114
- wrapAsyncCommand(fn) {
115
- const wrapped = async (uid, ...args) => {
116
- const generation = getGeneration(uid);
117
- const context = createAsyncCommandContext(uid, generation);
118
- await fn(context, ...args);
119
- };
120
- return wrapped;
121
- },
122
- wrapCommand(fn) {
123
- const wrapped = async (uid, ...args) => {
124
- const generation = getGeneration(uid);
125
- const {
126
- newState,
127
- oldState
128
- } = states[uid];
129
- const newerState = await fn(newState, ...args);
130
- if (oldState === newerState || newState === newerState) {
131
- return;
132
- }
133
- if (!isCurrentGeneration(uid, generation)) {
134
- return;
135
- }
136
- const latestOld = states[uid];
137
- const latestNew = {
138
- ...latestOld.newState,
139
- ...newerState
140
- };
141
- states[uid] = {
142
- newState: latestNew,
143
- oldState: latestOld.oldState,
144
- scheduledState: latestNew
145
- };
146
- };
147
- return wrapped;
148
- },
149
- wrapGetter(fn) {
150
- const wrapped = (uid, ...args) => {
151
- const {
152
- newState
153
- } = states[uid];
154
- return fn(newState, ...args);
155
- };
156
- return wrapped;
157
- },
158
- wrapLoadContent(fn) {
159
- const wrapped = async (uid, ...args) => {
160
- const generation = getGeneration(uid);
161
- const {
162
- newState,
163
- oldState
164
- } = states[uid];
165
- const result = await fn(newState, ...args);
166
- const {
167
- error,
168
- state
169
- } = result;
170
- if (oldState === state || newState === state) {
171
- return {
172
- error
173
- };
174
- }
175
- if (!isCurrentGeneration(uid, generation)) {
176
- return {
177
- error
178
- };
179
- }
180
- const latestOld = states[uid];
181
- const latestNew = {
182
- ...latestOld.newState,
183
- ...state
184
- };
185
- states[uid] = {
186
- newState: latestNew,
187
- oldState: latestOld.oldState,
188
- scheduledState: latestNew
189
- };
190
- return {
191
- error
192
- };
193
- };
194
- return wrapped;
195
- },
196
- wrapSerialAsyncCommand(fn) {
197
- const wrapped = async (uid, ...args) => {
198
- await enqueueCommand(uid, async () => {
199
- if (!states[uid]) {
200
- return;
201
- }
202
- const generation = getGeneration(uid);
203
- const context = createAsyncCommandContext(uid, generation);
204
- await fn(context, ...args);
205
- });
206
- };
207
- return wrapped;
208
- },
209
- wrapSerialCommand(fn) {
210
- const wrapped = async (uid, ...args) => {
211
- await enqueueCommand(uid, async () => {
212
- if (!states[uid]) {
213
- return;
214
- }
215
- const generation = getGeneration(uid);
216
- const {
217
- newState,
218
- oldState
219
- } = states[uid];
220
- const newerState = await fn(newState, ...args);
221
- if (oldState === newerState || newState === newerState) {
222
- return;
223
- }
224
- if (!isCurrentGeneration(uid, generation)) {
225
- return;
226
- }
227
- const latestOld = states[uid];
228
- const latestNew = {
229
- ...latestOld.newState,
230
- ...newerState
231
- };
232
- states[uid] = {
233
- newState: latestNew,
234
- oldState: latestOld.oldState,
235
- scheduledState: latestNew
236
- };
237
- });
238
- };
239
- return wrapped;
240
- }
241
- };
242
- };
243
- const terminate = () => {
244
- globalThis.close();
245
- };
246
-
247
1
  const normalizeLine = line => {
248
2
  if (line.startsWith('Error: ')) {
249
3
  return line.slice('Error: '.length);
@@ -1137,7 +891,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
1137
891
  const errorProperty = getErrorProperty(error, prettyError);
1138
892
  return create$1$1(id, errorProperty);
1139
893
  };
1140
- const create$e = (message, result) => {
894
+ const create$f = (message, result) => {
1141
895
  return {
1142
896
  id: message.id,
1143
897
  jsonrpc: Two$1,
@@ -1146,7 +900,7 @@ const create$e = (message, result) => {
1146
900
  };
1147
901
  const getSuccessResponse = (message, result) => {
1148
902
  const resultProperty = result ?? null;
1149
- return create$e(message, resultProperty);
903
+ return create$f(message, resultProperty);
1150
904
  };
1151
905
  const getErrorResponseSimple = (id, error) => {
1152
906
  return {
@@ -1240,7 +994,7 @@ const handleJsonRpcMessage = async (...args) => {
1240
994
 
1241
995
  const Two = '2.0';
1242
996
 
1243
- const create$d = (method, params) => {
997
+ const create$e = (method, params) => {
1244
998
  return {
1245
999
  jsonrpc: Two,
1246
1000
  method,
@@ -1248,7 +1002,7 @@ const create$d = (method, params) => {
1248
1002
  };
1249
1003
  };
1250
1004
 
1251
- const create$c = (id, method, params) => {
1005
+ const create$d = (id, method, params) => {
1252
1006
  const message = {
1253
1007
  id,
1254
1008
  jsonrpc: Two,
@@ -1259,12 +1013,12 @@ const create$c = (id, method, params) => {
1259
1013
  };
1260
1014
 
1261
1015
  let id$1 = 0;
1262
- const create$b = () => {
1016
+ const create$c = () => {
1263
1017
  return ++id$1;
1264
1018
  };
1265
1019
 
1266
1020
  const registerPromise = map => {
1267
- const id = create$b();
1021
+ const id = create$c();
1268
1022
  const {
1269
1023
  promise,
1270
1024
  resolve
@@ -1281,7 +1035,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
1281
1035
  id,
1282
1036
  promise
1283
1037
  } = registerPromise(callbacks);
1284
- const message = create$c(id, method, params);
1038
+ const message = create$d(id, method, params);
1285
1039
  if (useSendAndTransfer && ipc.sendAndTransfer) {
1286
1040
  ipc.sendAndTransfer(message);
1287
1041
  } else {
@@ -1317,7 +1071,7 @@ const createRpc = ipc => {
1317
1071
  * @deprecated
1318
1072
  */
1319
1073
  send(method, ...params) {
1320
- const message = create$d(method, params);
1074
+ const message = create$e(method, params);
1321
1075
  ipc.send(message);
1322
1076
  }
1323
1077
  };
@@ -1357,7 +1111,7 @@ const listen$1 = async (module, options) => {
1357
1111
  return ipc;
1358
1112
  };
1359
1113
 
1360
- const create$a = async ({
1114
+ const create$b = async ({
1361
1115
  commandMap,
1362
1116
  messagePort,
1363
1117
  requiresSocket
@@ -1375,7 +1129,7 @@ const create$a = async ({
1375
1129
  return rpc;
1376
1130
  };
1377
1131
 
1378
- const create$9 = async ({
1132
+ const create$a = async ({
1379
1133
  commandMap,
1380
1134
  isMessagePortOpen = true,
1381
1135
  messagePort
@@ -1393,7 +1147,7 @@ const create$9 = async ({
1393
1147
  return rpc;
1394
1148
  };
1395
1149
 
1396
- const create$8 = async ({
1150
+ const create$9 = async ({
1397
1151
  commandMap,
1398
1152
  isMessagePortOpen,
1399
1153
  send
@@ -1403,7 +1157,7 @@ const create$8 = async ({
1403
1157
  port2
1404
1158
  } = new MessageChannel();
1405
1159
  await send(port1);
1406
- return create$9({
1160
+ return create$a({
1407
1161
  commandMap,
1408
1162
  isMessagePortOpen,
1409
1163
  messagePort: port2
@@ -1438,7 +1192,7 @@ const createSharedLazyRpc = factory => {
1438
1192
  };
1439
1193
  };
1440
1194
 
1441
- const create$7 = async ({
1195
+ const create$8 = async ({
1442
1196
  commandMap,
1443
1197
  getPortTuple,
1444
1198
  send
@@ -1448,20 +1202,20 @@ const create$7 = async ({
1448
1202
  port2
1449
1203
  } = await getPortTuple();
1450
1204
  await send(port1);
1451
- const rpc = create$a({
1205
+ const rpc = create$b({
1452
1206
  commandMap,
1453
1207
  messagePort: port2
1454
1208
  });
1455
1209
  return rpc;
1456
1210
  };
1457
1211
 
1458
- const create$6 = async ({
1212
+ const create$7 = async ({
1459
1213
  commandMap,
1460
1214
  getPortTuple,
1461
1215
  send
1462
1216
  }) => {
1463
1217
  return createSharedLazyRpc(() => {
1464
- return create$7({
1218
+ return create$8({
1465
1219
  commandMap,
1466
1220
  getPortTuple,
1467
1221
  send
@@ -1469,13 +1223,13 @@ const create$6 = async ({
1469
1223
  });
1470
1224
  };
1471
1225
 
1472
- const create$5 = async ({
1226
+ const create$6 = async ({
1473
1227
  commandMap,
1474
1228
  isMessagePortOpen,
1475
1229
  send
1476
1230
  }) => {
1477
1231
  return createSharedLazyRpc(() => {
1478
- return create$8({
1232
+ return create$9({
1479
1233
  commandMap,
1480
1234
  isMessagePortOpen,
1481
1235
  send
@@ -1483,7 +1237,7 @@ const create$5 = async ({
1483
1237
  });
1484
1238
  };
1485
1239
 
1486
- const create$4 = async ({
1240
+ const create$5 = async ({
1487
1241
  commandMap
1488
1242
  }) => {
1489
1243
  // TODO create a commandMap per rpc instance
@@ -1515,7 +1269,7 @@ const createMockRpc = ({
1515
1269
  };
1516
1270
 
1517
1271
  const rpcs = Object.create(null);
1518
- const set$5 = (id, rpc) => {
1272
+ const set$6 = (id, rpc) => {
1519
1273
  rpcs[id] = rpc;
1520
1274
  };
1521
1275
  const get$1 = id => {
@@ -1526,7 +1280,7 @@ const remove = id => {
1526
1280
  };
1527
1281
 
1528
1282
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
1529
- const create$3 = rpcId => {
1283
+ const create$4 = rpcId => {
1530
1284
  return {
1531
1285
  async dispose() {
1532
1286
  const rpc = get$1(rpcId);
@@ -1548,7 +1302,7 @@ const create$3 = rpcId => {
1548
1302
  const mockRpc = createMockRpc({
1549
1303
  commandMap
1550
1304
  });
1551
- set$5(rpcId, mockRpc);
1305
+ set$6(rpcId, mockRpc);
1552
1306
  // @ts-ignore
1553
1307
  mockRpc[Symbol.dispose] = () => {
1554
1308
  remove(rpcId);
@@ -1557,12 +1311,12 @@ const create$3 = rpcId => {
1557
1311
  return mockRpc;
1558
1312
  },
1559
1313
  set(rpc) {
1560
- set$5(rpcId, rpc);
1314
+ set$6(rpcId, rpc);
1561
1315
  }
1562
1316
  };
1563
1317
  };
1564
1318
 
1565
- const None$1 = 'none';
1319
+ const None$2 = 'none';
1566
1320
  const Tab$1 = 'tab';
1567
1321
  const TabList = 'tablist';
1568
1322
  const ToolBar = 'toolbar';
@@ -1746,11 +1500,12 @@ const Tab = 13;
1746
1500
  const Main$1 = 24;
1747
1501
 
1748
1502
  const Separator = 1;
1749
- const None = 0;
1503
+ const None$1 = 0;
1750
1504
 
1751
1505
  const Electron = 2;
1752
1506
 
1753
1507
  const ClipBoardWorker = 3400;
1508
+ const DialogWorker = 7014;
1754
1509
  const ExtensionHostWorker = 44;
1755
1510
  const IconThemeWorker = 7009;
1756
1511
  const RendererWorker = 1;
@@ -1762,17 +1517,22 @@ const SetPatches = 'Viewlet.setPatches';
1762
1517
  const FocusEditorText = 12;
1763
1518
 
1764
1519
  const {
1520
+ set: set$5
1521
+ } = create$4(ClipBoardWorker);
1522
+
1523
+ const {
1524
+ invoke: invoke$2,
1765
1525
  set: set$4
1766
- } = create$3(ClipBoardWorker);
1526
+ } = create$4(DialogWorker);
1767
1527
 
1768
1528
  const {
1769
1529
  set: set$3
1770
- } = create$3(ExtensionHostWorker);
1530
+ } = create$4(ExtensionHostWorker);
1771
1531
 
1772
1532
  const {
1773
1533
  invoke: invoke$1,
1774
1534
  set: set$2
1775
- } = create$3(IconThemeWorker);
1535
+ } = create$4(IconThemeWorker);
1776
1536
  const getIcons = async iconRequests => {
1777
1537
  // @ts-ignore
1778
1538
  return invoke$1('IconTheme.getIcons', iconRequests);
@@ -1782,7 +1542,7 @@ const {
1782
1542
  invoke,
1783
1543
  invokeAndTransfer,
1784
1544
  set: set$1
1785
- } = create$3(RendererWorker);
1545
+ } = create$4(RendererWorker);
1786
1546
  const handleModifiedStatusChange$1 = async (uri, modified) => {
1787
1547
  return invoke('Main.handleModifiedStatusChange', uri, modified);
1788
1548
  };
@@ -1797,6 +1557,10 @@ const sendMessagePortToClipBoardWorker$1 = async (port, rpcId) => {
1797
1557
  const command = 'ClipBoard.handleMessagePort';
1798
1558
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
1799
1559
  };
1560
+ const sendMessagePortToDialogWorker = async port => {
1561
+ const command = 'HandleMessagePort.handleMessagePort';
1562
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1563
+ };
1800
1564
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1801
1565
  const command = 'IconTheme.handleMessagePort';
1802
1566
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
@@ -1808,21 +1572,270 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1808
1572
  const command = 'HandleMessagePort.handleMessagePort2';
1809
1573
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1810
1574
  };
1811
- const confirm = async (message, options) => {
1575
+ const confirm$1 = async (message, options) => {
1812
1576
  const result = await invoke('ConfirmPrompt.prompt', message, options);
1813
1577
  return result;
1814
1578
  };
1815
- const writeClipBoardText = async text => {
1816
- await invoke('ClipBoard.writeText', /* text */text);
1579
+ const writeClipBoardText = async text => {
1580
+ await invoke('ClipBoard.writeText', /* text */text);
1581
+ };
1582
+
1583
+ const toCommandId = key => {
1584
+ const dotIndex = key.indexOf('.');
1585
+ return key.slice(dotIndex + 1);
1586
+ };
1587
+ const create$3 = () => {
1588
+ const commandQueues = new Map();
1589
+ const generations = Object.create(null);
1590
+ const states = Object.create(null);
1591
+ const commandMapRef = {};
1592
+ const getGeneration = uid => generations[uid] || 0;
1593
+ const isCurrentGeneration = (uid, generation) => {
1594
+ return states[uid] !== undefined && getGeneration(uid) === generation;
1595
+ };
1596
+ const updateState = (uid, generation, fallbackState, updater) => {
1597
+ if (!isCurrentGeneration(uid, generation)) {
1598
+ return Promise.resolve(fallbackState);
1599
+ }
1600
+ const current = states[uid];
1601
+ const updatedState = updater(current.newState);
1602
+ if (updatedState !== current.newState) {
1603
+ states[uid] = {
1604
+ newState: updatedState,
1605
+ oldState: current.oldState,
1606
+ scheduledState: updatedState
1607
+ };
1608
+ }
1609
+ return Promise.resolve(updatedState);
1610
+ };
1611
+ const createAsyncCommandContext = (uid, generation) => {
1612
+ let latestState = states[uid].newState;
1613
+ return {
1614
+ getState: () => {
1615
+ if (isCurrentGeneration(uid, generation)) {
1616
+ latestState = states[uid].newState;
1617
+ }
1618
+ return latestState;
1619
+ },
1620
+ updateState: async updater => {
1621
+ latestState = await updateState(uid, generation, latestState, updater);
1622
+ return latestState;
1623
+ }
1624
+ };
1625
+ };
1626
+ const enqueueCommand = async (uid, command) => {
1627
+ const previous = commandQueues.get(uid) || Promise.resolve();
1628
+ const run = async () => {
1629
+ try {
1630
+ await previous;
1631
+ } catch {
1632
+ // The previous caller receives its error; later commands must still run.
1633
+ }
1634
+ await command();
1635
+ };
1636
+ const current = run();
1637
+ commandQueues.set(uid, current);
1638
+ try {
1639
+ await current;
1640
+ } finally {
1641
+ if (commandQueues.get(uid) === current) {
1642
+ commandQueues.delete(uid);
1643
+ }
1644
+ }
1645
+ };
1646
+ return {
1647
+ clear() {
1648
+ commandQueues.clear();
1649
+ for (const key of Object.keys(states)) {
1650
+ delete states[key];
1651
+ }
1652
+ },
1653
+ diff(uid, modules, numbers) {
1654
+ const {
1655
+ oldState,
1656
+ scheduledState
1657
+ } = states[uid];
1658
+ const diffResult = [];
1659
+ for (let i = 0; i < modules.length; i++) {
1660
+ const fn = modules[i];
1661
+ if (!fn(oldState, scheduledState)) {
1662
+ diffResult.push(numbers[i]);
1663
+ }
1664
+ }
1665
+ return diffResult;
1666
+ },
1667
+ dispose(uid) {
1668
+ commandQueues.delete(uid);
1669
+ delete states[uid];
1670
+ },
1671
+ get(uid) {
1672
+ return states[uid];
1673
+ },
1674
+ getCommandIds() {
1675
+ const keys = Object.keys(commandMapRef);
1676
+ const ids = keys.map(toCommandId);
1677
+ return ids;
1678
+ },
1679
+ getKeys() {
1680
+ return Object.keys(states).map(Number);
1681
+ },
1682
+ registerCommands(commandMap) {
1683
+ Object.assign(commandMapRef, commandMap);
1684
+ },
1685
+ set(uid, oldState, newState, scheduledState) {
1686
+ const current = states[uid];
1687
+ if (!current || oldState === newState && newState !== current.newState) {
1688
+ generations[uid] = getGeneration(uid) + 1;
1689
+ }
1690
+ states[uid] = {
1691
+ newState,
1692
+ oldState,
1693
+ scheduledState: scheduledState ?? newState
1694
+ };
1695
+ },
1696
+ wrapAsyncCommand(fn) {
1697
+ const wrapped = async (uid, ...args) => {
1698
+ const generation = getGeneration(uid);
1699
+ const context = createAsyncCommandContext(uid, generation);
1700
+ await fn(context, ...args);
1701
+ };
1702
+ return wrapped;
1703
+ },
1704
+ wrapCommand(fn) {
1705
+ const wrapped = async (uid, ...args) => {
1706
+ const generation = getGeneration(uid);
1707
+ const {
1708
+ newState,
1709
+ oldState
1710
+ } = states[uid];
1711
+ const newerState = await fn(newState, ...args);
1712
+ if (oldState === newerState || newState === newerState) {
1713
+ return;
1714
+ }
1715
+ if (!isCurrentGeneration(uid, generation)) {
1716
+ return;
1717
+ }
1718
+ const latestOld = states[uid];
1719
+ const latestNew = {
1720
+ ...latestOld.newState,
1721
+ ...newerState
1722
+ };
1723
+ states[uid] = {
1724
+ newState: latestNew,
1725
+ oldState: latestOld.oldState,
1726
+ scheduledState: latestNew
1727
+ };
1728
+ };
1729
+ return wrapped;
1730
+ },
1731
+ wrapGetter(fn) {
1732
+ const wrapped = (uid, ...args) => {
1733
+ const {
1734
+ newState
1735
+ } = states[uid];
1736
+ return fn(newState, ...args);
1737
+ };
1738
+ return wrapped;
1739
+ },
1740
+ wrapLoadContent(fn) {
1741
+ const wrapped = async (uid, ...args) => {
1742
+ const generation = getGeneration(uid);
1743
+ const {
1744
+ newState,
1745
+ oldState
1746
+ } = states[uid];
1747
+ const result = await fn(newState, ...args);
1748
+ const {
1749
+ error,
1750
+ state
1751
+ } = result;
1752
+ if (oldState === state || newState === state) {
1753
+ return {
1754
+ error
1755
+ };
1756
+ }
1757
+ if (!isCurrentGeneration(uid, generation)) {
1758
+ return {
1759
+ error
1760
+ };
1761
+ }
1762
+ const latestOld = states[uid];
1763
+ const latestNew = {
1764
+ ...latestOld.newState,
1765
+ ...state
1766
+ };
1767
+ states[uid] = {
1768
+ newState: latestNew,
1769
+ oldState: latestOld.oldState,
1770
+ scheduledState: latestNew
1771
+ };
1772
+ return {
1773
+ error
1774
+ };
1775
+ };
1776
+ return wrapped;
1777
+ },
1778
+ wrapSerialAsyncCommand(fn) {
1779
+ const wrapped = async (uid, ...args) => {
1780
+ await enqueueCommand(uid, async () => {
1781
+ if (!states[uid]) {
1782
+ return;
1783
+ }
1784
+ const generation = getGeneration(uid);
1785
+ const context = createAsyncCommandContext(uid, generation);
1786
+ await fn(context, ...args);
1787
+ });
1788
+ };
1789
+ return wrapped;
1790
+ },
1791
+ wrapSerialCommand(fn) {
1792
+ const wrapped = async (uid, ...args) => {
1793
+ await enqueueCommand(uid, async () => {
1794
+ if (!states[uid]) {
1795
+ return;
1796
+ }
1797
+ const generation = getGeneration(uid);
1798
+ const {
1799
+ newState,
1800
+ oldState
1801
+ } = states[uid];
1802
+ const newerState = await fn(newState, ...args);
1803
+ if (oldState === newerState || newState === newerState) {
1804
+ return;
1805
+ }
1806
+ if (!isCurrentGeneration(uid, generation)) {
1807
+ return;
1808
+ }
1809
+ const latestOld = states[uid];
1810
+ const latestNew = {
1811
+ ...latestOld.newState,
1812
+ ...newerState
1813
+ };
1814
+ states[uid] = {
1815
+ newState: latestNew,
1816
+ oldState: latestOld.oldState,
1817
+ scheduledState: latestNew
1818
+ };
1819
+ });
1820
+ };
1821
+ return wrapped;
1822
+ }
1823
+ };
1824
+ };
1825
+ const terminate = () => {
1826
+ globalThis.close();
1817
1827
  };
1818
1828
 
1819
1829
  const addClosedTabs = (state, entries) => {
1830
+ const {
1831
+ closedTabs
1832
+ } = state;
1820
1833
  if (entries.length === 0) {
1821
1834
  return state;
1822
1835
  }
1823
1836
  return {
1824
1837
  ...state,
1825
- closedTabs: [...state.closedTabs, ...entries].slice(-20)
1838
+ closedTabs: [...closedTabs, ...entries].slice(-20)
1826
1839
  };
1827
1840
  };
1828
1841
 
@@ -1844,10 +1857,13 @@ const redistributeSizesWithRounding = groups => {
1844
1857
  };
1845
1858
 
1846
1859
  const withGroupsAndActiveGroup = (state, groups, activeGroupId) => {
1860
+ const {
1861
+ layout
1862
+ } = state;
1847
1863
  return {
1848
1864
  ...state,
1849
1865
  layout: {
1850
- ...state.layout,
1866
+ ...layout,
1851
1867
  activeGroupId,
1852
1868
  groups
1853
1869
  }
@@ -1859,20 +1875,26 @@ const withEmptyGroups = state => {
1859
1875
  };
1860
1876
 
1861
1877
  const withGroups = (state, groups) => {
1878
+ const {
1879
+ layout
1880
+ } = state;
1862
1881
  return {
1863
1882
  ...state,
1864
1883
  layout: {
1865
- ...state.layout,
1884
+ ...layout,
1866
1885
  groups
1867
1886
  }
1868
1887
  };
1869
1888
  };
1870
1889
 
1871
1890
  const closeTab = (state, groupId, tabId) => {
1891
+ const {
1892
+ layout
1893
+ } = state;
1872
1894
  const {
1873
1895
  activeGroupId,
1874
1896
  groups
1875
- } = state.layout;
1897
+ } = layout;
1876
1898
 
1877
1899
  // Find the group to close the tab from
1878
1900
  const groupIndex = getGroupIndexById(state, groupId);
@@ -1951,10 +1973,13 @@ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) =>
1951
1973
  };
1952
1974
 
1953
1975
  const getActiveFileUri = state => {
1976
+ const {
1977
+ layout
1978
+ } = state;
1954
1979
  const {
1955
1980
  activeGroupId,
1956
1981
  groups
1957
- } = state.layout;
1982
+ } = layout;
1958
1983
  const activeGroup = groups.find(group => group.id === activeGroupId);
1959
1984
  const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
1960
1985
  if (!activeTab) {
@@ -1998,7 +2023,7 @@ const withActiveEditorChangeAsync = fn => {
1998
2023
  };
1999
2024
  };
2000
2025
 
2001
- const registry = create$f();
2026
+ const registry = create$3();
2002
2027
  const {
2003
2028
  get,
2004
2029
  getCommandIds,
@@ -2301,6 +2326,9 @@ const findTabInState = (state, groupId, tabId) => {
2301
2326
  };
2302
2327
 
2303
2328
  const closeTabWithViewlet = async (state, groupId, tabId) => {
2329
+ const {
2330
+ layout
2331
+ } = state;
2304
2332
  const tab = findTabInState(state, groupId, tabId);
2305
2333
  const commands = [];
2306
2334
  if (tab && tab.editorUid !== -1) {
@@ -2310,7 +2338,7 @@ const closeTabWithViewlet = async (state, groupId, tabId) => {
2310
2338
  commands.push(...disposeCommands);
2311
2339
  }
2312
2340
  const newState = closeTab(state, groupId, tabId);
2313
- const group = state.layout.groups.find(g => g.id === groupId);
2341
+ const group = layout.groups.find(g => g.id === groupId);
2314
2342
  const wasActiveTab = group?.activeTabId === tabId;
2315
2343
  const newGroup = wasActiveTab ? newState.layout.groups.find(candidate => candidate.id === groupId) : undefined;
2316
2344
  const newActiveTabId = newGroup?.activeTabId;
@@ -2342,6 +2370,17 @@ const saveEditor = async editorUid => {
2342
2370
  return invoke('Editor.save', editorUid);
2343
2371
  };
2344
2372
 
2373
+ const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
2374
+ const confirm = async (message, options) => {
2375
+ try {
2376
+ return await invoke$2('ConfirmPrompt.prompt', message, options);
2377
+ } catch (error) {
2378
+ if (!String(error).includes(missingDialogWorkerRelay)) {
2379
+ throw error;
2380
+ }
2381
+ return confirm$1(message, options);
2382
+ }
2383
+ };
2345
2384
  const promptSave = async title => {
2346
2385
  const shouldSave = await confirm(`Do you want to save the changes you made to ${title}?`, {
2347
2386
  cancelMessage: 'More Options',
@@ -2420,9 +2459,12 @@ const disposeEditors = async editorUids => {
2420
2459
  };
2421
2460
 
2422
2461
  const closeAll$1 = async state => {
2423
- const editorUids = state.layout.groups.flatMap(group => group.tabs.map(tab => tab.editorUid)).filter(editorUid => editorUid !== -1);
2462
+ const {
2463
+ layout
2464
+ } = state;
2465
+ const editorUids = layout.groups.flatMap(group => group.tabs.map(tab => tab.editorUid)).filter(editorUid => editorUid !== -1);
2424
2466
  await disposeEditors(editorUids);
2425
- const entries = state.layout.groups.flatMap((group, groupIndex) => {
2467
+ const entries = layout.groups.flatMap((group, groupIndex) => {
2426
2468
  return group.tabs.map((tab, tabIndex) => ({
2427
2469
  group,
2428
2470
  groupIndex,
@@ -2566,9 +2608,12 @@ const closeSavedInGroup = group => {
2566
2608
  };
2567
2609
  };
2568
2610
  const closeSaved$1 = state => {
2611
+ const {
2612
+ layout
2613
+ } = state;
2569
2614
  const {
2570
2615
  groups
2571
- } = state.layout;
2616
+ } = layout;
2572
2617
  const closedTabs = groups.flatMap((group, groupIndex) => {
2573
2618
  return group.tabs.map((tab, tabIndex) => ({
2574
2619
  group,
@@ -2582,7 +2627,10 @@ const closeSaved$1 = state => {
2582
2627
  };
2583
2628
 
2584
2629
  const closeFirstTabByUri = (state, uri) => {
2585
- const matchingGroup = state.layout.groups.find(group => {
2630
+ const {
2631
+ layout
2632
+ } = state;
2633
+ const matchingGroup = layout.groups.find(group => {
2586
2634
  return group.tabs.some(tab => tab.uri === uri);
2587
2635
  });
2588
2636
  const matchingTab = matchingGroup?.tabs.find(tab => tab.uri === uri);
@@ -2604,7 +2652,10 @@ const closeTabsByUris = (state, uris) => {
2604
2652
  };
2605
2653
 
2606
2654
  const getGroupById = (state, groupId) => {
2607
- return state.layout.groups.find(group => group.id === groupId);
2655
+ const {
2656
+ layout
2657
+ } = state;
2658
+ return layout.groups.find(group => group.id === groupId);
2608
2659
  };
2609
2660
 
2610
2661
  const closeTabsRight = (state, groupId) => {
@@ -2664,9 +2715,12 @@ const findGroupById = (state, groupId) => {
2664
2715
  };
2665
2716
 
2666
2717
  const copyIntoNewWindow$1 = async state => {
2718
+ const {
2719
+ layout
2720
+ } = state;
2667
2721
  const {
2668
2722
  activeGroupId
2669
- } = state.layout;
2723
+ } = layout;
2670
2724
  const group = findGroupById(state, activeGroupId ?? 0);
2671
2725
  if (!group) {
2672
2726
  return state;
@@ -2747,12 +2801,12 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
2747
2801
  set(uid, state, state);
2748
2802
  };
2749
2803
 
2750
- const isEqual$1 = (oldState, newState) => {
2804
+ const isEqual$2 = (oldState, newState) => {
2751
2805
  return false;
2752
2806
  };
2753
2807
 
2754
- const isEqual = (oldState, newState) => {
2755
- return oldState.layout === newState.layout;
2808
+ const isEqual$1 = (oldState, newState) => {
2809
+ return oldState.dragOverlay === newState.dragOverlay && oldState.layout === newState.layout;
2756
2810
  };
2757
2811
 
2758
2812
  const RenderItems = 4;
@@ -2763,7 +2817,7 @@ const RenderPendingViewletUpdate = 12;
2763
2817
  const isPendingViewletUpdateEqual = (oldState, newState) => {
2764
2818
  return newState.pendingViewletUpdate === undefined;
2765
2819
  };
2766
- const modules = [isEqual, isEqual$1, isPendingViewletUpdateEqual];
2820
+ const modules = [isEqual$1, isEqual$2, isPendingViewletUpdateEqual];
2767
2821
  const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate];
2768
2822
 
2769
2823
  const diff = (oldState, newState) => {
@@ -2983,7 +3037,10 @@ const getActiveTabId$1 = state => {
2983
3037
  };
2984
3038
 
2985
3039
  const getSelectedTabData = (state, groupIndex, index) => {
2986
- const group = state.layout.groups[groupIndex];
3040
+ const {
3041
+ layout
3042
+ } = state;
3043
+ const group = layout.groups[groupIndex];
2987
3044
  if (!group || index < 0 || index >= group.tabs.length) {
2988
3045
  return undefined;
2989
3046
  }
@@ -3043,11 +3100,18 @@ const findTabById = (state, tabId) => {
3043
3100
  };
3044
3101
 
3045
3102
  const getSelectedTabBounds = state => {
3103
+ const {
3104
+ height,
3105
+ tabHeight,
3106
+ width,
3107
+ x,
3108
+ y
3109
+ } = state;
3046
3110
  return {
3047
- height: state.height - state.tabHeight,
3048
- width: state.width,
3049
- x: state.x,
3050
- y: state.y + state.tabHeight
3111
+ height: height - tabHeight,
3112
+ width,
3113
+ x,
3114
+ y: y + tabHeight
3051
3115
  };
3052
3116
  };
3053
3117
 
@@ -3095,11 +3159,14 @@ const getViewletModuleId = async tab => {
3095
3159
  };
3096
3160
 
3097
3161
  const startContentLoading = async (oldState, state, tabId, path, requestId) => {
3162
+ const {
3163
+ uid
3164
+ } = state;
3098
3165
  try {
3099
3166
  const getLatestState = () => {
3100
- return get(state.uid).newState;
3167
+ return get(uid).newState;
3101
3168
  };
3102
- set(state.uid, oldState, state);
3169
+ set(uid, oldState, state);
3103
3170
  const newState = await loadTabContentAsync(tabId, path, requestId, getLatestState);
3104
3171
  return newState;
3105
3172
  } catch {
@@ -3281,8 +3348,8 @@ const getActiveGroup = (groups, activeGroupId) => {
3281
3348
  return groups.find(g => g.id === activeGroupId);
3282
3349
  };
3283
3350
 
3284
- const Left = 'left';
3285
- const Right = 'right';
3351
+ const Left$1 = 'left';
3352
+ const Right$1 = 'right';
3286
3353
 
3287
3354
  const getActiveTab = state => {
3288
3355
  const {
@@ -3374,12 +3441,18 @@ const getRestoredTab = tab => {
3374
3441
  };
3375
3442
  };
3376
3443
  const getStateWithoutLastClosedTab = state => {
3444
+ const {
3445
+ closedTabs
3446
+ } = state;
3377
3447
  return {
3378
3448
  ...state,
3379
- closedTabs: state.closedTabs.slice(0, -1)
3449
+ closedTabs: closedTabs.slice(0, -1)
3380
3450
  };
3381
3451
  };
3382
3452
  const restoreExistingUri = (state, entry) => {
3453
+ const {
3454
+ layout
3455
+ } = state;
3383
3456
  if (!entry.tab.uri) {
3384
3457
  return undefined;
3385
3458
  }
@@ -3387,11 +3460,11 @@ const restoreExistingUri = (state, entry) => {
3387
3460
  if (!existing) {
3388
3461
  return undefined;
3389
3462
  }
3390
- const groupIndex = state.layout.groups.findIndex(group => group.id === existing.groupId);
3463
+ const groupIndex = layout.groups.findIndex(group => group.id === existing.groupId);
3391
3464
  if (groupIndex === -1) {
3392
3465
  return undefined;
3393
3466
  }
3394
- const tabIndex = state.layout.groups[groupIndex].tabs.findIndex(tab => tab.id === existing.tab.id);
3467
+ const tabIndex = layout.groups[groupIndex].tabs.findIndex(tab => tab.id === existing.tab.id);
3395
3468
  if (tabIndex === -1) {
3396
3469
  return undefined;
3397
3470
  }
@@ -3411,9 +3484,12 @@ const restoreExistingUri = (state, entry) => {
3411
3484
  };
3412
3485
  };
3413
3486
  const restoreIntoExistingGroup = (state, entry) => {
3487
+ const {
3488
+ layout
3489
+ } = state;
3414
3490
  const {
3415
3491
  groups
3416
- } = state.layout;
3492
+ } = layout;
3417
3493
  const groupIndex = groups.findIndex(group => group.id === entry.group.id);
3418
3494
  if (groupIndex === -1) {
3419
3495
  return undefined;
@@ -3501,7 +3577,10 @@ const restoreIntoRecreatedGroup = (state, entry) => {
3501
3577
  };
3502
3578
  };
3503
3579
  const restoreClosedTabState = state => {
3504
- const entry = state.closedTabs.at(-1);
3580
+ const {
3581
+ closedTabs
3582
+ } = state;
3583
+ const entry = closedTabs.at(-1);
3505
3584
  if (!entry) {
3506
3585
  return undefined;
3507
3586
  }
@@ -3550,7 +3629,10 @@ const getActiveTabId = state => {
3550
3629
  };
3551
3630
 
3552
3631
  const getTabCount = state => {
3553
- return state.layout.groups.reduce((sum, group) => sum + group.tabs.length, 0);
3632
+ const {
3633
+ layout
3634
+ } = state;
3635
+ return layout.groups.reduce((sum, group) => sum + group.tabs.length, 0);
3554
3636
  };
3555
3637
 
3556
3638
  const getCurrentState = state => {
@@ -3664,9 +3746,10 @@ const updateTabUriTitle = (tab, homeDirUri) => {
3664
3746
  };
3665
3747
  const updateTabUriTitles = state => {
3666
3748
  const {
3749
+ homeDirUri: rawHomeDirUri,
3667
3750
  layout
3668
3751
  } = state;
3669
- const homeDirUri = state.homeDirUri || '';
3752
+ const homeDirUri = rawHomeDirUri || '';
3670
3753
  return {
3671
3754
  ...state,
3672
3755
  layout: {
@@ -3681,6 +3764,7 @@ const updateTabUriTitles = state => {
3681
3764
 
3682
3765
  const createEmptyGroup$1 = (state, uri, requestId, preview = false, title = getLabel(uri), editorType = 'text', editorInput) => {
3683
3766
  const {
3767
+ homeDirUri,
3684
3768
  layout
3685
3769
  } = state;
3686
3770
  const {
@@ -3702,7 +3786,7 @@ const createEmptyGroup$1 = (state, uri, requestId, preview = false, title = getL
3702
3786
  loadingState: 'loading',
3703
3787
  title,
3704
3788
  uri,
3705
- uriTitle: getUriTitle(uri, state.homeDirUri || '')
3789
+ uriTitle: getUriTitle(uri, homeDirUri || '')
3706
3790
  };
3707
3791
  const newGroup = {
3708
3792
  activeTabId: newTab.id,
@@ -3761,6 +3845,7 @@ const openTab = (state, groupId, tab) => {
3761
3845
  const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), editorType = 'text', editorInput) => {
3762
3846
  // Find the active group (by activeGroupId or focused flag)
3763
3847
  const {
3848
+ homeDirUri,
3764
3849
  layout
3765
3850
  } = state;
3766
3851
  const {
@@ -3798,7 +3883,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
3798
3883
  loadingState: 'loading',
3799
3884
  title,
3800
3885
  uri,
3801
- uriTitle: getUriTitle(uri, state.homeDirUri || '')
3886
+ uriTitle: getUriTitle(uri, homeDirUri || '')
3802
3887
  };
3803
3888
  });
3804
3889
  return {
@@ -3832,7 +3917,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
3832
3917
  loadingState: 'loading',
3833
3918
  title,
3834
3919
  uri: uri,
3835
- uriTitle: getUriTitle(uri, state.homeDirUri || '')
3920
+ uriTitle: getUriTitle(uri, homeDirUri || '')
3836
3921
  };
3837
3922
  newState = openTab(state, activeGroup.id, newTab);
3838
3923
  } else {
@@ -4047,7 +4132,10 @@ const getExistingTabState = (state, existingTab, preview) => {
4047
4132
  return switchTab(pinnedState, existingTab.groupId, existingTab.tab.id);
4048
4133
  };
4049
4134
  const getActivePreviewEditorUid = state => {
4050
- const activeGroup = state.layout.activeGroupId === undefined ? state.layout.groups.find(group => group.focused) : state.layout.groups.find(group => group.id === state.layout.activeGroupId);
4135
+ const {
4136
+ layout
4137
+ } = state;
4138
+ const activeGroup = layout.activeGroupId === undefined ? layout.groups.find(group => group.focused) : layout.groups.find(group => group.id === layout.activeGroupId);
4051
4139
  const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
4052
4140
  return activeTab?.isPreview ? activeTab.editorUid : -1;
4053
4141
  };
@@ -4254,17 +4342,20 @@ const rebalanceGroupSizes = groups => {
4254
4342
  }));
4255
4343
  };
4256
4344
  const isTrailingSplit = direction => {
4257
- return direction === Right || direction === 'down';
4345
+ return direction === Right$1 || direction === 'down';
4258
4346
  };
4259
4347
  const getSplitLayoutDirection = direction => {
4260
- return direction === Left || direction === Right ? Horizontal : Vertical;
4348
+ return direction === Left$1 || direction === Right$1 ? Horizontal : Vertical;
4261
4349
  };
4262
4350
  const createNextState = (state, activeGroupId, groups) => {
4351
+ const {
4352
+ layout
4353
+ } = state;
4263
4354
  return {
4264
4355
  ...state,
4265
4356
  layout: {
4266
4357
  activeGroupId,
4267
- direction: state.layout.direction,
4358
+ direction: layout.direction,
4268
4359
  groups
4269
4360
  }
4270
4361
  };
@@ -4433,7 +4524,7 @@ const handleClickAction = async (state, action, rawGroupId) => {
4433
4524
  case RetryOpen:
4434
4525
  return retryOpen(state);
4435
4526
  case SplitRight$1:
4436
- return splitEditorGroup$1(state, activeGroup.id, Right);
4527
+ return splitEditorGroup$1(state, activeGroup.id, Right$1);
4437
4528
  case TogglePreview$1:
4438
4529
  return handleClickTogglePreview(state);
4439
4530
  default:
@@ -4486,6 +4577,9 @@ const show2 = async (uid, menuId, x, y, args) => {
4486
4577
 
4487
4578
  const NoGroupId = -1;
4488
4579
  const handleContextMenu = async (state, rawGroupId, x, y) => {
4580
+ const {
4581
+ uid
4582
+ } = state;
4489
4583
  number(x);
4490
4584
  number(y);
4491
4585
  if (rawGroupId === undefined) {
@@ -4495,7 +4589,7 @@ const handleContextMenu = async (state, rawGroupId, x, y) => {
4495
4589
  if (Number.isNaN(groupId)) {
4496
4590
  return state;
4497
4591
  }
4498
- await show2(state.uid, Main$1, x, y, {
4592
+ await show2(uid, Main$1, x, y, {
4499
4593
  groupId,
4500
4594
  menuId: Main$1
4501
4595
  });
@@ -4503,12 +4597,15 @@ const handleContextMenu = async (state, rawGroupId, x, y) => {
4503
4597
  };
4504
4598
 
4505
4599
  const handleDoubleClick = (state, groupIndexRaw, indexRaw) => {
4600
+ const {
4601
+ layout
4602
+ } = state;
4506
4603
  if (!groupIndexRaw || !indexRaw) {
4507
4604
  return state;
4508
4605
  }
4509
4606
  const groupIndex = Number.parseInt(groupIndexRaw);
4510
4607
  const tabIndex = Number.parseInt(indexRaw);
4511
- const tab = state.layout.groups[groupIndex]?.tabs[tabIndex];
4608
+ const tab = layout.groups[groupIndex]?.tabs[tabIndex];
4512
4609
  if (!tab?.isPreview) {
4513
4610
  return state;
4514
4611
  }
@@ -4517,6 +4614,118 @@ const handleDoubleClick = (state, groupIndexRaw, indexRaw) => {
4517
4614
  });
4518
4615
  };
4519
4616
 
4617
+ const handleDragLeave = state => {
4618
+ const {
4619
+ dragOverlay
4620
+ } = state;
4621
+ if (!dragOverlay) {
4622
+ return state;
4623
+ }
4624
+ return {
4625
+ ...state,
4626
+ dragOverlay: undefined
4627
+ };
4628
+ };
4629
+
4630
+ const None = 0;
4631
+ const Up = 1;
4632
+ const Down = 2;
4633
+ const Left = 3;
4634
+ const Right = 4;
4635
+
4636
+ const getSplitDirection = (x, y, width, height) => {
4637
+ const percentX = x / width;
4638
+ if (percentX < 0.25) {
4639
+ return Left;
4640
+ }
4641
+ if (percentX > 0.75) {
4642
+ return Right;
4643
+ }
4644
+ const percentY = y / height;
4645
+ if (percentY < 0.25) {
4646
+ return Up;
4647
+ }
4648
+ if (percentY > 0.75) {
4649
+ return Down;
4650
+ }
4651
+ return None;
4652
+ };
4653
+ const getOverlay = (x, y, width, height, splitDirection) => {
4654
+ const halfHeight = height / 2;
4655
+ const halfWidth = width / 2;
4656
+ switch (splitDirection) {
4657
+ case Down:
4658
+ return {
4659
+ height: halfHeight,
4660
+ width,
4661
+ x,
4662
+ y: y + halfHeight
4663
+ };
4664
+ case Left:
4665
+ return {
4666
+ height,
4667
+ width: halfWidth,
4668
+ x,
4669
+ y
4670
+ };
4671
+ case Right:
4672
+ return {
4673
+ height,
4674
+ width: halfWidth,
4675
+ x: x + halfWidth,
4676
+ y
4677
+ };
4678
+ case Up:
4679
+ return {
4680
+ height: halfHeight,
4681
+ width,
4682
+ x,
4683
+ y
4684
+ };
4685
+ default:
4686
+ return {
4687
+ height,
4688
+ width,
4689
+ x,
4690
+ y
4691
+ };
4692
+ }
4693
+ };
4694
+ const getDragOverlay = (state, eventX, eventY) => {
4695
+ const {
4696
+ height,
4697
+ layout,
4698
+ tabHeight,
4699
+ width,
4700
+ x,
4701
+ y
4702
+ } = state;
4703
+ const hasOpenEditor = layout.groups.some(group => !group.isEmpty);
4704
+ const contentY = hasOpenEditor ? tabHeight : 0;
4705
+ const contentHeight = Math.max(0, height - contentY);
4706
+ const relativeX = eventX - x;
4707
+ const relativeY = eventY - y - contentY;
4708
+ const splitDirection = getSplitDirection(relativeX, relativeY, width, contentHeight);
4709
+ return getOverlay(0, contentY, width, contentHeight, splitDirection);
4710
+ };
4711
+
4712
+ const isEqual = (oldOverlay, newOverlay) => {
4713
+ return oldOverlay?.x === newOverlay?.x && oldOverlay?.y === newOverlay?.y && oldOverlay?.width === newOverlay?.width && oldOverlay?.height === newOverlay?.height;
4714
+ };
4715
+ const handleDragOver = (state, eventX, eventY) => {
4716
+ const {
4717
+ dragOverlay: oldDragOverlay
4718
+ } = state;
4719
+ const dragOverlay = getDragOverlay(state, eventX, eventY);
4720
+ if (isEqual(oldDragOverlay, dragOverlay)) {
4721
+ return state;
4722
+ }
4723
+ return {
4724
+ ...state,
4725
+ dragOverlay
4726
+ };
4727
+ };
4728
+
4520
4729
  const EditorGroupHeader = 'EditorGroupHeader';
4521
4730
  const EmptyGroupHeader = 'EmptyGroupHeader';
4522
4731
  const EmptyGroupCloseButton = 'EmptyGroupCloseButton';
@@ -4539,6 +4748,7 @@ const TextEditorLoading = 'TextEditor TextEditor--loading';
4539
4748
  const EditorContentLoading = 'EditorContent EditorContent--loading';
4540
4749
  const TextEditorError = 'TextEditor TextEditorError';
4541
4750
  const EditorContentError = 'EditorContent EditorContentError';
4751
+ const DragOverlay = 'DragOverlay';
4542
4752
  const Main = 'Main';
4543
4753
  const EDITOR_GROUPS_CONTAINER = 'editor-groups-container';
4544
4754
  const TabIcon = 'TabIcon';
@@ -4677,16 +4887,20 @@ const getAllTabs = layout => {
4677
4887
  };
4678
4888
 
4679
4889
  const loadFileIcons = async state => {
4890
+ const {
4891
+ fileIconCache,
4892
+ layout
4893
+ } = state;
4680
4894
  try {
4681
- const allTabs = getAllTabs(state.layout);
4895
+ const allTabs = getAllTabs(layout);
4682
4896
  const {
4683
4897
  newFileIconCache
4684
- } = await getFileIconsForTabs(allTabs, state.fileIconCache);
4898
+ } = await getFileIconsForTabs(allTabs, fileIconCache);
4685
4899
 
4686
4900
  // Update tabs with their icons
4687
4901
  const updatedLayout = {
4688
- ...state.layout,
4689
- groups: state.layout.groups.map(group => ({
4902
+ ...layout,
4903
+ groups: layout.groups.map(group => ({
4690
4904
  ...group,
4691
4905
  tabs: group.tabs.map(tab => ({
4692
4906
  ...tab,
@@ -4701,8 +4915,8 @@ const loadFileIcons = async state => {
4701
4915
  } catch {
4702
4916
  // If icon request fails, continue without icons
4703
4917
  return {
4704
- fileIconCache: state.fileIconCache,
4705
- updatedLayout: state.layout
4918
+ fileIconCache,
4919
+ updatedLayout: layout
4706
4920
  };
4707
4921
  }
4708
4922
  };
@@ -4840,17 +5054,20 @@ const getSashCorner = layout => {
4840
5054
  };
4841
5055
 
4842
5056
  const handleSashCornerPointerDown = async (state, clientX, clientY) => {
5057
+ const {
5058
+ layout
5059
+ } = state;
4843
5060
  if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
4844
5061
  return state;
4845
5062
  }
4846
- const sashCorner = getSashCorner(state.layout);
5063
+ const sashCorner = getSashCorner(layout);
4847
5064
  if (!sashCorner) {
4848
5065
  return state;
4849
5066
  }
4850
5067
  return {
4851
5068
  ...state,
4852
5069
  sashCornerDrag: {
4853
- groupSizes: state.layout.groups.map(group => ({
5070
+ groupSizes: layout.groups.map(group => ({
4854
5071
  id: group.id,
4855
5072
  size: group.size
4856
5073
  })),
@@ -4893,6 +5110,9 @@ const getBeforeSize = (startSize, deltaPx, axisSize, minSizePx, totalSize) => {
4893
5110
  const handleSashCornerPointerMove = async (state, clientX, clientY) => {
4894
5111
  const {
4895
5112
  height,
5113
+ layout,
5114
+ minGroupHeightPx,
5115
+ minGroupWidthPx,
4896
5116
  sashCornerDrag,
4897
5117
  width
4898
5118
  } = state;
@@ -4912,8 +5132,8 @@ const handleSashCornerPointerMove = async (state, clientX, clientY) => {
4912
5132
  }
4913
5133
  const xBeforeStartSize = sumGroupSizes(groupSizes, xBeforeGroupIds);
4914
5134
  const yBeforeStartSize = sumGroupSizes(groupSizes, yBeforeGroupIds);
4915
- const xBeforeSize = getBeforeSize(xBeforeStartSize, clientX - startClientX, width, state.minGroupWidthPx, totalSize);
4916
- const yBeforeSize = getBeforeSize(yBeforeStartSize, clientY - startClientY, height, state.minGroupHeightPx, totalSize);
5135
+ const xBeforeSize = getBeforeSize(xBeforeStartSize, clientX - startClientX, width, minGroupWidthPx, totalSize);
5136
+ const yBeforeSize = getBeforeSize(yBeforeStartSize, clientY - startClientY, height, minGroupHeightPx, totalSize);
4917
5137
  const xAfterSize = totalSize - xBeforeSize;
4918
5138
  const yAfterSize = totalSize - yBeforeSize;
4919
5139
  const xBeforeGroupIdSet = new Set(xBeforeGroupIds);
@@ -4921,8 +5141,8 @@ const handleSashCornerPointerMove = async (state, clientX, clientY) => {
4921
5141
  return {
4922
5142
  ...state,
4923
5143
  layout: {
4924
- ...state.layout,
4925
- groups: state.layout.groups.map(group => {
5144
+ ...layout,
5145
+ groups: layout.groups.map(group => {
4926
5146
  const xSize = xBeforeGroupIdSet.has(group.id) ? xBeforeSize : xAfterSize;
4927
5147
  const ySize = yBeforeGroupIdSet.has(group.id) ? yBeforeSize : yAfterSize;
4928
5148
  return {
@@ -4935,7 +5155,10 @@ const handleSashCornerPointerMove = async (state, clientX, clientY) => {
4935
5155
  };
4936
5156
 
4937
5157
  const handleSashCornerPointerUp = async state => {
4938
- if (!state.sashCornerDrag) {
5158
+ const {
5159
+ sashCornerDrag
5160
+ } = state;
5161
+ if (!sashCornerDrag) {
4939
5162
  return state;
4940
5163
  }
4941
5164
  return {
@@ -5003,6 +5226,8 @@ const handleSashPointerMove = async (state, clientX, clientY) => {
5003
5226
  const {
5004
5227
  height,
5005
5228
  layout,
5229
+ minGroupHeightPx,
5230
+ minGroupWidthPx,
5006
5231
  sashDrag,
5007
5232
  width
5008
5233
  } = state;
@@ -5023,7 +5248,7 @@ const handleSashPointerMove = async (state, clientX, clientY) => {
5023
5248
  const deltaPx = direction === Horizontal ? clientX - sashDrag.startClientX : clientY - sashDrag.startClientY;
5024
5249
  const deltaPercent = deltaPx / axisSize * 100;
5025
5250
  const totalResizableSize = sashDrag.beforeSize + sashDrag.afterSize;
5026
- const minGroupSizePx = direction === Horizontal ? state.minGroupWidthPx : state.minGroupHeightPx;
5251
+ const minGroupSizePx = direction === Horizontal ? minGroupWidthPx : minGroupHeightPx;
5027
5252
  let minGroupSize = getMinGroupSizePercent(axisSize, minGroupSizePx);
5028
5253
 
5029
5254
  // If the minimum size makes it impossible to fit two groups, relax the constraint
@@ -5083,6 +5308,7 @@ const handleTabContextMenu = async (state, button, x, y) => {
5083
5308
 
5084
5309
  const handleUriChange = async (state, oldUri, newUri) => {
5085
5310
  const {
5311
+ homeDirUri,
5086
5312
  layout
5087
5313
  } = state;
5088
5314
  const {
@@ -5113,7 +5339,7 @@ const handleUriChange = async (state, oldUri, newUri) => {
5113
5339
  editorInput,
5114
5340
  title: getLabel(renamedUri),
5115
5341
  uri: renamedUri,
5116
- uriTitle: getUriTitle(renamedUri, state.homeDirUri || '')
5342
+ uriTitle: getUriTitle(renamedUri, homeDirUri || '')
5117
5343
  };
5118
5344
  }
5119
5345
  return tab;
@@ -5324,15 +5550,18 @@ const updateTabs = (state, editorUids) => {
5324
5550
  };
5325
5551
 
5326
5552
  const restoreAndCreateEditors = async (state, restoredLayout) => {
5553
+ const {
5554
+ tabHeight
5555
+ } = state;
5327
5556
  let newState = {
5328
5557
  ...state,
5329
5558
  layout: restoredLayout
5330
5559
  };
5331
5560
  const bounds = {
5332
- height: newState.height - state.tabHeight,
5561
+ height: newState.height - tabHeight,
5333
5562
  width: newState.width,
5334
5563
  x: newState.x,
5335
- y: newState.y + state.tabHeight
5564
+ y: newState.y + tabHeight
5336
5565
  };
5337
5566
 
5338
5567
  // Get viewlet module IDs for all active tabs
@@ -5440,7 +5669,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
5440
5669
 
5441
5670
  const createExtensionHostRpc = async () => {
5442
5671
  try {
5443
- const rpc = await create$8({
5672
+ const rpc = await create$9({
5444
5673
  commandMap: {},
5445
5674
  send: sendMessagePortToExtensionHostWorker
5446
5675
  });
@@ -5604,12 +5833,15 @@ const menuEntrySeparator = {
5604
5833
  };
5605
5834
 
5606
5835
  const getNewWindowMenuEntries = state => {
5607
- if (state.platform !== Electron) {
5836
+ const {
5837
+ platform
5838
+ } = state;
5839
+ if (platform !== Electron) {
5608
5840
  return [];
5609
5841
  }
5610
5842
  return [menuEntrySeparator, {
5611
5843
  command: 'MainArea.newWindow',
5612
- flags: None,
5844
+ flags: None$1,
5613
5845
  id: 'newWindow',
5614
5846
  label: newWindow$1()
5615
5847
  }];
@@ -5619,37 +5851,37 @@ const getMenuEntries$2 = (state, groupId) => {
5619
5851
  const groupArgs = getMenuEntryArgs(groupId);
5620
5852
  const entries = [{
5621
5853
  command: 'MainArea.newFile',
5622
- flags: None,
5854
+ flags: None$1,
5623
5855
  id: 'newTextFile',
5624
5856
  label: newTextFile()
5625
5857
  }, {
5626
5858
  args: [QuickPick, 'file'],
5627
5859
  command: 'Viewlet.openWidget',
5628
- flags: None,
5860
+ flags: None$1,
5629
5861
  id: 'openFile',
5630
5862
  label: openFile()
5631
5863
  }, menuEntrySeparator, {
5632
5864
  args: groupArgs,
5633
5865
  command: 'MainArea.splitUp',
5634
- flags: None,
5866
+ flags: None$1,
5635
5867
  id: 'splitUp',
5636
5868
  label: splitUp$1()
5637
5869
  }, {
5638
5870
  args: groupArgs,
5639
5871
  command: 'MainArea.splitDown',
5640
- flags: None,
5872
+ flags: None$1,
5641
5873
  id: 'splitDown',
5642
5874
  label: splitDown$1()
5643
5875
  }, {
5644
5876
  args: groupArgs,
5645
5877
  command: 'MainArea.splitLeft',
5646
- flags: None,
5878
+ flags: None$1,
5647
5879
  id: 'splitLeft',
5648
5880
  label: splitLeft$1()
5649
5881
  }, {
5650
5882
  args: groupArgs,
5651
5883
  command: 'MainArea.splitRight',
5652
- flags: None,
5884
+ flags: None$1,
5653
5885
  id: 'splitRight',
5654
5886
  label: splitRight$1()
5655
5887
  }, ...getNewWindowMenuEntries(state)];
@@ -5659,7 +5891,7 @@ const getMenuEntries$2 = (state, groupId) => {
5659
5891
  return [...entries, menuEntrySeparator, {
5660
5892
  args: [groupId],
5661
5893
  command: 'MainArea.closeEditorGroup',
5662
- flags: None,
5894
+ flags: None$1,
5663
5895
  id: 'closeGroup',
5664
5896
  label: closeEditorGroup()
5665
5897
  }];
@@ -5690,101 +5922,101 @@ const getMenuEntries$1 = state => {
5690
5922
  } = tab;
5691
5923
  return [{
5692
5924
  command: 'Main.closeFocusedTab',
5693
- flags: None,
5925
+ flags: None$1,
5694
5926
  id: 'tabClose',
5695
5927
  label: close()
5696
5928
  }, {
5697
5929
  command: 'Main.closeOthers',
5698
- flags: None,
5930
+ flags: None$1,
5699
5931
  id: 'tabCloseOthers',
5700
5932
  label: closeOthers()
5701
5933
  }, {
5702
5934
  command: 'Main.closeTabsRight',
5703
- flags: None,
5935
+ flags: None$1,
5704
5936
  id: 'tabCloseToTheRight',
5705
5937
  label: closeToTheRight()
5706
5938
  }, {
5707
5939
  command: 'Main.closeSaved',
5708
- flags: None,
5940
+ flags: None$1,
5709
5941
  id: 'tabCloseSaved',
5710
5942
  label: closeSaved()
5711
5943
  }, {
5712
5944
  command: 'Main.closeAll',
5713
- flags: None,
5945
+ flags: None$1,
5714
5946
  id: 'tabCloseAll',
5715
5947
  label: closeAll()
5716
5948
  }, menuEntrySeparator, {
5717
5949
  args: [path],
5718
5950
  command: 'Main.copyPath',
5719
- flags: None,
5951
+ flags: None$1,
5720
5952
  id: 'copyPath',
5721
5953
  label: copyPath()
5722
5954
  }, {
5723
5955
  args: [path],
5724
5956
  command: 'Main.copyRelativePath',
5725
- flags: None,
5957
+ flags: None$1,
5726
5958
  id: 'copyRelativePath',
5727
5959
  label: copyRelativePath()
5728
5960
  }, menuEntrySeparator, {
5729
5961
  command: 'Main.reopenEditorWith',
5730
- flags: None,
5962
+ flags: None$1,
5731
5963
  id: 'reopenEditorWith',
5732
5964
  label: reopenEditorWith$1()
5733
5965
  }, menuEntrySeparator, {
5734
5966
  command: '',
5735
- flags: None,
5967
+ flags: None$1,
5736
5968
  id: 'share',
5737
5969
  label: share()
5738
5970
  }, menuEntrySeparator, {
5739
5971
  command: '',
5740
- flags: None,
5972
+ flags: None$1,
5741
5973
  id: 'addFileToChat',
5742
5974
  label: addFileToChat()
5743
5975
  }, menuEntrySeparator, {
5744
5976
  command: '',
5745
- flags: None,
5977
+ flags: None$1,
5746
5978
  id: 'openContainingFolder',
5747
5979
  label: openContainingFolder()
5748
5980
  }, {
5749
5981
  args: [path],
5750
5982
  command: 'Explorer.revealItem',
5751
- flags: None,
5983
+ flags: None$1,
5752
5984
  id: 'revealInExplorerView',
5753
5985
  label: revealInExplorerView()
5754
5986
  }, menuEntrySeparator, {
5755
5987
  command: '',
5756
- flags: None,
5988
+ flags: None$1,
5757
5989
  id: 'keepOpen',
5758
5990
  label: keepOpen()
5759
5991
  }, {
5760
5992
  command: '',
5761
- flags: None,
5993
+ flags: None$1,
5762
5994
  id: 'pin',
5763
5995
  label: pin()
5764
5996
  }, menuEntrySeparator, {
5765
5997
  command: 'Main.splitRight',
5766
- flags: None,
5998
+ flags: None$1,
5767
5999
  id: 'splitRight',
5768
6000
  label: splitRight$1()
5769
6001
  }, {
5770
6002
  command: '',
5771
- flags: None,
6003
+ flags: None$1,
5772
6004
  id: 'splitAndMove',
5773
6005
  label: splitAndMove()
5774
6006
  }, {
5775
6007
  command: 'MainArea.moveIntoNewWindow',
5776
- flags: None,
6008
+ flags: None$1,
5777
6009
  id: 'moveIntoNewWindow',
5778
6010
  label: moveIntoNewWindow$1()
5779
6011
  }, {
5780
6012
  command: 'MainArea.copyIntoNewWindow',
5781
- flags: None,
6013
+ flags: None$1,
5782
6014
  id: 'copyIntoNewWindow',
5783
6015
  label: copyIntoNewWindow()
5784
6016
  }, menuEntrySeparator, {
5785
6017
  args: [/* id */'References', /* focus */true, path],
5786
6018
  command: 'SideBar.show',
5787
- flags: None,
6019
+ flags: None$1,
5788
6020
  id: 'findFileReferences',
5789
6021
  label: findFileReferences()
5790
6022
  }];
@@ -5802,9 +6034,12 @@ const getMenuEntries = async (state, props) => {
5802
6034
  };
5803
6035
 
5804
6036
  const moveIntoNewWindow = async state => {
6037
+ const {
6038
+ layout
6039
+ } = state;
5805
6040
  const {
5806
6041
  activeGroupId
5807
- } = state.layout;
6042
+ } = layout;
5808
6043
  const group = findGroupById(state, activeGroupId ?? 0);
5809
6044
  if (!group) {
5810
6045
  return state;
@@ -5829,25 +6064,9 @@ const newWindow = async state => {
5829
6064
  };
5830
6065
 
5831
6066
  const openUrisWithContext = async (context, uris) => {
5832
- if (uris.length === 0) {
5833
- return;
5834
- }
5835
- await openUriWithContext(context, uris[0]);
5836
- if (uris.length === 1) {
5837
- return;
5838
- }
5839
- let currentState = context.getState();
5840
- const firstTab = findTabByUri(currentState, uris[0]);
5841
- for (const uri of uris.slice(1)) {
5842
- const existingTab = findTabByUri(currentState, uri);
5843
- if (!existingTab) {
5844
- currentState = ensureActiveGroup(currentState, uri);
5845
- }
5846
- }
5847
- if (firstTab) {
5848
- currentState = switchTab(currentState, firstTab.groupId, firstTab.tab.id);
6067
+ for (const uri of uris) {
6068
+ await openUriWithContext(context, uri);
5849
6069
  }
5850
- await context.updateState(() => currentState);
5851
6070
  };
5852
6071
 
5853
6072
  const refresh = state => {
@@ -5856,6 +6075,24 @@ const refresh = state => {
5856
6075
  };
5857
6076
  };
5858
6077
 
6078
+ const getDragOverlayCss = dragOverlay => {
6079
+ if (!dragOverlay) {
6080
+ return [];
6081
+ }
6082
+ const {
6083
+ height,
6084
+ width,
6085
+ x,
6086
+ y
6087
+ } = dragOverlay;
6088
+ return [`.DragOverlay {
6089
+ left: ${x}px;
6090
+ top: ${y}px;
6091
+ width: ${width}px;
6092
+ height: ${height}px;
6093
+ }`];
6094
+ };
6095
+
5859
6096
  const getEditorGroupCss = layout => {
5860
6097
  const groupSizeVariable = layout.direction === Vertical ? '--EditorGroupHeight' : '--EditorGroupWidth';
5861
6098
  return layout.groups.map(group => {
@@ -5945,10 +6182,18 @@ const getSashCss = (layout, width = 0) => {
5945
6182
  return getProtoSashCss(layout, width).map(renderSashCss);
5946
6183
  };
5947
6184
 
5948
- const getCss = (layout, width = 0) => {
5949
- const rules = [`.MainArea {
6185
+ const getCss = (layout, width = 0, dragOverlay) => {
6186
+ const rules = [`.Main {
6187
+ position: relative;
5950
6188
  }`, `.editor-groups-container {
5951
6189
  overflow: auto;
6190
+ }`, `.DragOverlay {
6191
+ position: absolute;
6192
+ z-index: 1;
6193
+ contain: strict;
6194
+ pointer-events: none;
6195
+ background: rgba(83, 89, 93, 0.5);
6196
+ transition: all 100ms;
5952
6197
  }`, `.SashBorder {
5953
6198
  background: var(--SashBorder, gray);
5954
6199
  }`, `.SashBorderHorizontal {
@@ -5984,7 +6229,7 @@ const getCss = (layout, width = 0) => {
5984
6229
  /*height: var(--EditorGroupHeight, auto);*/
5985
6230
  }`];
5986
6231
  if (layout) {
5987
- rules.push(...getEditorGroupCss(layout), ...getSashCss(layout, width));
6232
+ rules.push(...getEditorGroupCss(layout), ...getDragOverlayCss(dragOverlay), ...getSashCss(layout, width));
5988
6233
  const sashCorner = getSashCorner(layout);
5989
6234
  if (sashCorner) {
5990
6235
  rules.push(`.SashCorner {
@@ -5998,7 +6243,7 @@ const getCss = (layout, width = 0) => {
5998
6243
  };
5999
6244
 
6000
6245
  const renderCss = (oldState, newState) => {
6001
- const css = getCss(newState.layout, newState.width);
6246
+ const css = getCss(newState.layout, newState.width, newState.dragOverlay);
6002
6247
  return [SetCss, newState.uid, css];
6003
6248
  };
6004
6249
 
@@ -6094,14 +6339,11 @@ const compareNodes = (oldNode, newNode) => {
6094
6339
  }
6095
6340
  const patches = [];
6096
6341
  // Handle reference nodes - special handling for uid changes
6097
- if (oldNode.type === Reference) {
6098
- if (oldNode.uid !== newNode.uid) {
6099
- patches.push({
6100
- type: SetReferenceNodeUid,
6101
- uid: newNode.uid
6102
- });
6103
- }
6104
- return patches;
6342
+ if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
6343
+ patches.push({
6344
+ type: SetReferenceNodeUid,
6345
+ uid: newNode.uid
6346
+ });
6105
6347
  }
6106
6348
  // Handle text nodes
6107
6349
  if (oldNode.type === Text && newNode.type === Text) {
@@ -6114,8 +6356,8 @@ const compareNodes = (oldNode, newNode) => {
6114
6356
  return patches;
6115
6357
  }
6116
6358
  // Compare attributes
6117
- const oldKeys = getKeys(oldNode);
6118
- const newKeys = getKeys(newNode);
6359
+ const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
6360
+ const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
6119
6361
  // Check for attribute changes
6120
6362
  for (const key of newKeys) {
6121
6363
  if (oldNode[key] !== newNode[key]) {
@@ -6139,9 +6381,14 @@ const compareNodes = (oldNode, newNode) => {
6139
6381
  };
6140
6382
 
6141
6383
  const treeToArray = node => {
6142
- const result = [node.node];
6143
- for (const child of node.children) {
6144
- result.push(...treeToArray(child));
6384
+ const result = [];
6385
+ const stack = [node];
6386
+ while (stack.length > 0) {
6387
+ const current = stack.pop();
6388
+ result.push(current.node);
6389
+ for (let i = current.children.length - 1; i >= 0; i--) {
6390
+ stack.push(current.children[i]);
6391
+ }
6145
6392
  }
6146
6393
  return result;
6147
6394
  };
@@ -6253,17 +6500,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
6253
6500
  };
6254
6501
 
6255
6502
  const removeTrailingNavigationPatches = patches => {
6256
- // Find the last non-navigation patch
6257
- let lastNonNavigationIndex = -1;
6258
- for (let i = patches.length - 1; i >= 0; i--) {
6259
- const patch = patches[i];
6503
+ while (patches.length > 0) {
6504
+ const patch = patches.at(-1);
6260
6505
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
6261
- lastNonNavigationIndex = i;
6262
6506
  break;
6263
6507
  }
6508
+ patches.pop();
6264
6509
  }
6265
- // Return patches up to and including the last non-navigation patch
6266
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
6510
+ return patches;
6267
6511
  };
6268
6512
 
6269
6513
  const diffTree = (oldNodes, newNodes) => {
@@ -6291,6 +6535,18 @@ const HandleDoubleClick = 19;
6291
6535
  const HandleSashCornerPointerDown = 20;
6292
6536
  const HandleSashCornerPointerMove = 21;
6293
6537
  const HandleSashCornerPointerUp = 22;
6538
+ const HandleDragOver = 23;
6539
+ const HandleDragLeave = 24;
6540
+ const HandleDrop = 25;
6541
+
6542
+ const dragOverlayVirtualDom = {
6543
+ childCount: 0,
6544
+ className: DragOverlay,
6545
+ type: Div
6546
+ };
6547
+ const getDragOverlayVirtualDom = () => {
6548
+ return dragOverlayVirtualDom;
6549
+ };
6294
6550
 
6295
6551
  const textEditorNode = {
6296
6552
  childCount: 1,
@@ -6320,15 +6576,16 @@ const paragraphNode = {
6320
6576
  childCount: 1,
6321
6577
  type: P
6322
6578
  };
6579
+ const retryButtonNode = {
6580
+ childCount: 1,
6581
+ className: mergeClassNames(Button, ButtonSecondary),
6582
+ 'data-action': RetryOpen,
6583
+ name: RetryOpen,
6584
+ onClick: HandleClickAction,
6585
+ type: Button$2
6586
+ };
6323
6587
  const renderError = errorMessage => {
6324
- return [textEditorErrorNode, editorContentErrorNode, paragraphNode, text(`Error: ${errorMessage}`), {
6325
- childCount: 1,
6326
- className: mergeClassNames(Button, ButtonSecondary),
6327
- 'data-action': RetryOpen,
6328
- name: RetryOpen,
6329
- onClick: HandleClickAction,
6330
- type: Button$2
6331
- }, text(retry())];
6588
+ return [textEditorErrorNode, editorContentErrorNode, paragraphNode, text(`Error: ${errorMessage}`), retryButtonNode, text(retry())];
6332
6589
  };
6333
6590
 
6334
6591
  const textEditorLoadingNode = {
@@ -6421,7 +6678,7 @@ const SearchEditorScheme = 'search-editor://';
6421
6678
  const tabIconNode = {
6422
6679
  childCount: 1,
6423
6680
  className: TabIcon,
6424
- role: None$1,
6681
+ role: None$2,
6425
6682
  type: Div
6426
6683
  };
6427
6684
  const tabTitleNode = {
@@ -6452,7 +6709,7 @@ const renderTabIcon = tab => {
6452
6709
  return [{
6453
6710
  childCount: 0,
6454
6711
  className: TabIcon,
6455
- role: None$1,
6712
+ role: None$2,
6456
6713
  src: tab.icon,
6457
6714
  type: Img
6458
6715
  }];
@@ -6554,7 +6811,7 @@ const renderEditorGroupHeader = (group, groupIndex, splitButtonEnabled) => {
6554
6811
  childCount: hasActions ? 2 : 1,
6555
6812
  className: EditorGroupHeader,
6556
6813
  onDblClick: HandleHeaderDoubleClick,
6557
- role: None$1,
6814
+ role: None$2,
6558
6815
  type: Div
6559
6816
  }, ...getTabsVirtualDom(group, groupIndex, tabsChildCount), ...actions];
6560
6817
  };
@@ -6645,7 +6902,7 @@ const renderSash = (direction, sashId) => {
6645
6902
  className: getSashClassName(direction),
6646
6903
  'data-sashId': sashId,
6647
6904
  onPointerDown: HandleSashPointerDown,
6648
- role: None$1,
6905
+ role: None$2,
6649
6906
  type: Button$2
6650
6907
  }, {
6651
6908
  childCount: 0,
@@ -6658,7 +6915,7 @@ const sashCornerNode = {
6658
6915
  childCount: 0,
6659
6916
  className: 'SashCorner',
6660
6917
  onPointerDown: HandleSashCornerPointerDown,
6661
- role: None$1,
6918
+ role: None$2,
6662
6919
  type: Button$2
6663
6920
  };
6664
6921
  const renderSashCorner = () => {
@@ -6668,6 +6925,9 @@ const renderSashCorner = () => {
6668
6925
  const mainNode$1 = {
6669
6926
  childCount: 1,
6670
6927
  className: Main,
6928
+ onDragLeave: HandleDragLeave,
6929
+ onDragOver: HandleDragOver,
6930
+ onDrop: HandleDrop,
6671
6931
  type: Div
6672
6932
  };
6673
6933
  const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
@@ -6687,8 +6947,20 @@ const getContainerClassName = (direction, childCount) => {
6687
6947
  const mainNode = {
6688
6948
  childCount: 1,
6689
6949
  className: Main,
6950
+ onDragLeave: HandleDragLeave,
6951
+ onDragOver: HandleDragOver,
6952
+ onDrop: HandleDrop,
6690
6953
  type: Div
6691
6954
  };
6955
+ const addDragOverlay = (dom, dragOverlay) => {
6956
+ if (!dragOverlay) {
6957
+ return dom;
6958
+ }
6959
+ return [dom[0], {
6960
+ ...dom[1],
6961
+ childCount: dom[1].childCount + 1
6962
+ }, ...dom.slice(2), getDragOverlayVirtualDom()];
6963
+ };
6692
6964
  const getSizeProperty = direction => {
6693
6965
  return direction === Vertical ? 'height' : 'width';
6694
6966
  };
@@ -6737,7 +7009,7 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
6737
7009
  children.push({
6738
7010
  childCount: nestedChildCount,
6739
7011
  className: getContainerClassName(nestedDirection, segment.groups.length),
6740
- role: None$1,
7012
+ role: None$2,
6741
7013
  style: `${sizeProperty}:${segmentSize}%;`,
6742
7014
  type: Div
6743
7015
  });
@@ -6750,25 +7022,25 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled) => {
6750
7022
  children
6751
7023
  };
6752
7024
  };
6753
- const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
7025
+ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay) => {
6754
7026
  const {
6755
7027
  direction,
6756
7028
  groups
6757
7029
  } = layout;
6758
7030
  const sizeProperty = getSizeProperty(direction);
6759
7031
  if (groups.length === 1) {
6760
- return renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty);
7032
+ return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty), dragOverlay);
6761
7033
  }
6762
7034
  const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
6763
7035
  if (groups.length === 0) {
6764
- return [mainNode, {
7036
+ return addDragOverlay([mainNode, {
6765
7037
  childCount: 0,
6766
7038
  className: editorGroupsContainerClassName,
6767
7039
  'data-groupId': '',
6768
7040
  onContextMenu: HandleContextMenu,
6769
- role: None$1,
7041
+ role: None$2,
6770
7042
  type: Div
6771
- }];
7043
+ }], dragOverlay);
6772
7044
  }
6773
7045
  const {
6774
7046
  childCount,
@@ -6776,16 +7048,17 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false) => {
6776
7048
  } = renderSegmentChildren(direction, groups, splitButtonEnabled);
6777
7049
  const sashCorner = getSashCorner(layout);
6778
7050
  const sashCornerChildren = sashCorner ? [renderSashCorner()] : [];
6779
- return [mainNode, {
7051
+ return addDragOverlay([mainNode, {
6780
7052
  childCount: childCount + sashCornerChildren.length,
6781
7053
  className: editorGroupsContainerClassName,
6782
- role: None$1,
7054
+ role: None$2,
6783
7055
  type: Div
6784
- }, ...children, ...sashCornerChildren];
7056
+ }, ...children, ...sashCornerChildren], dragOverlay);
6785
7057
  };
6786
7058
 
6787
7059
  const renderItems = (oldState, newState) => {
6788
7060
  const {
7061
+ dragOverlay,
6789
7062
  initial,
6790
7063
  layout,
6791
7064
  splitButtonEnabled,
@@ -6794,7 +7067,7 @@ const renderItems = (oldState, newState) => {
6794
7067
  if (initial) {
6795
7068
  return [SetDom2, uid, []];
6796
7069
  }
6797
- const dom = getMainAreaVirtualDom(layout, splitButtonEnabled);
7070
+ const dom = getMainAreaVirtualDom(layout, splitButtonEnabled, dragOverlay);
6798
7071
  return [SetDom2, uid, dom];
6799
7072
  };
6800
7073
 
@@ -6900,6 +7173,17 @@ const renderEventListeners = () => {
6900
7173
  }, {
6901
7174
  name: HandleSashCornerPointerUp,
6902
7175
  params: ['handleSashCornerPointerUp', ClientX, ClientY]
7176
+ }, {
7177
+ name: HandleDragOver,
7178
+ params: ['handleDragOver', ClientX, ClientY],
7179
+ preventDefault: true
7180
+ }, {
7181
+ name: HandleDragLeave,
7182
+ params: ['handleDragLeave']
7183
+ }, {
7184
+ name: HandleDrop,
7185
+ params: ['handleDragLeave'],
7186
+ preventDefault: true
6903
7187
  }];
6904
7188
  };
6905
7189
 
@@ -7035,8 +7319,11 @@ const getLatestStoredState = (uid, fallbackState, referenceTabId, referenceTabUr
7035
7319
  return fallbackState;
7036
7320
  };
7037
7321
  const save = async state => {
7322
+ const {
7323
+ uid
7324
+ } = state;
7038
7325
  const requestedActiveTabData = getActiveTab(state);
7039
- const currentState = getLatestStoredState(state.uid, state, requestedActiveTabData?.tab.id, requestedActiveTabData?.tab.uri, !requestedActiveTabData);
7326
+ const currentState = getLatestStoredState(uid, state, requestedActiveTabData?.tab.id, requestedActiveTabData?.tab.uri, !requestedActiveTabData);
7040
7327
  const activeTabData = getActiveTab(currentState);
7041
7328
  if (!activeTabData) {
7042
7329
  return currentState;
@@ -7049,17 +7336,17 @@ const save = async state => {
7049
7336
  }
7050
7337
  if (!tab.isDirty) {
7051
7338
  await saveEditorAndHandleSettingsChange(tab);
7052
- return getLatestStoredState(state.uid, currentState, tab.id, tab.uri);
7339
+ return getLatestStoredState(uid, currentState, tab.id, tab.uri);
7053
7340
  }
7054
7341
  const editorState = await saveEditorAndHandleSettingsChange(tab);
7055
- const latestState = getLatestStoredState(state.uid, currentState, tab.id, tab.uri);
7342
+ const latestState = getLatestStoredState(uid, currentState, tab.id, tab.uri);
7056
7343
  if (editorState?.modified) {
7057
7344
  return latestState;
7058
7345
  }
7059
7346
  if (tab.uri) {
7060
7347
  await handleModifiedStatusChange$1(tab.uri, false);
7061
7348
  }
7062
- const stateAfterModifiedStatusChange = getLatestStoredState(state.uid, latestState, tab.id, tab.uri);
7349
+ const stateAfterModifiedStatusChange = getLatestStoredState(uid, latestState, tab.id, tab.uri);
7063
7350
  return updateTab(stateAfterModifiedStatusChange, tab.id, {
7064
7351
  isDirty: false
7065
7352
  });
@@ -7196,12 +7483,15 @@ const setEditorLayout = (state, direction, slots) => {
7196
7483
  };
7197
7484
  };
7198
7485
  const flipLayout = state => {
7486
+ const {
7487
+ layout
7488
+ } = state;
7199
7489
  return {
7200
7490
  ...state,
7201
7491
  layout: {
7202
- ...state.layout,
7203
- direction: flipDirection(state.layout.direction),
7204
- groups: state.layout.groups.map(group => ({
7492
+ ...layout,
7493
+ direction: flipDirection(layout.direction),
7494
+ groups: layout.groups.map(group => ({
7205
7495
  ...group,
7206
7496
  direction: group.direction === undefined ? undefined : flipDirection(group.direction)
7207
7497
  }))
@@ -7324,7 +7614,7 @@ const splitDown = (state, groupId) => {
7324
7614
  };
7325
7615
  return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, 'down');
7326
7616
  }
7327
- const resolvedGroupId = groupId ?? state.layout.activeGroupId;
7617
+ const resolvedGroupId = groupId ?? layout.activeGroupId;
7328
7618
  if (!resolvedGroupId) {
7329
7619
  return state;
7330
7620
  }
@@ -7357,10 +7647,10 @@ const splitLeft = (state, groupId) => {
7357
7647
  groups: [initialGroup]
7358
7648
  }
7359
7649
  };
7360
- return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Left);
7650
+ return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Left$1);
7361
7651
  }
7362
7652
  const targetGroupId = groupId ?? activeGroupId ?? groups[0]?.id ?? 0;
7363
- return splitEditorGroup$1(state, targetGroupId, Left);
7653
+ return splitEditorGroup$1(state, targetGroupId, Left$1);
7364
7654
  };
7365
7655
 
7366
7656
  const splitRight = (state, groupId) => {
@@ -7391,10 +7681,10 @@ const splitRight = (state, groupId) => {
7391
7681
  groups: [initialGroup]
7392
7682
  }
7393
7683
  };
7394
- return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Right);
7684
+ return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Right$1);
7395
7685
  }
7396
7686
  const targetGroupId = groupId ?? activeGroupId ?? groups[0]?.id ?? 0;
7397
- return splitEditorGroup$1(state, targetGroupId, Right);
7687
+ return splitEditorGroup$1(state, targetGroupId, Right$1);
7398
7688
  };
7399
7689
 
7400
7690
  const splitUp = (state, groupId) => {
@@ -7424,7 +7714,7 @@ const splitUp = (state, groupId) => {
7424
7714
  };
7425
7715
  return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, 'up');
7426
7716
  }
7427
- const resolvedGroupId = groupId ?? state.layout.activeGroupId;
7717
+ const resolvedGroupId = groupId ?? layout.activeGroupId;
7428
7718
  if (!resolvedGroupId) {
7429
7719
  return state;
7430
7720
  }
@@ -7511,6 +7801,8 @@ const commandMap = {
7511
7801
  'MainArea.handleClickTogglePreview': wrapSerialCommand(handleClickTogglePreview),
7512
7802
  'MainArea.handleContextMenu': wrapSerialCommand(handleContextMenu),
7513
7803
  'MainArea.handleDoubleClick': wrapSerialCommand(handleDoubleClick),
7804
+ 'MainArea.handleDragLeave': wrapSerialCommand(handleDragLeave),
7805
+ 'MainArea.handleDragOver': wrapSerialCommand(handleDragOver),
7514
7806
  'MainArea.handleHeaderDoubleClick': wrapSerialCommand(handleHeaderDoubleClick),
7515
7807
  'MainArea.handleIconThemeChange': wrapSerialCommand(handleIconThemeChange),
7516
7808
  'MainArea.handleModifiedStatusChange': wrapAsyncCommand(handleModifiedStatusChangeWithContext),
@@ -7564,11 +7856,11 @@ const sendMessagePortToClipBoardWorker = async port => {
7564
7856
  };
7565
7857
 
7566
7858
  const initializeClipBoardWorker = async () => {
7567
- const rpc = await create$6({
7859
+ const rpc = await create$7({
7568
7860
  commandMap: {},
7569
7861
  send: sendMessagePortToClipBoardWorker
7570
7862
  });
7571
- set$4(rpc);
7863
+ set$5(rpc);
7572
7864
  };
7573
7865
 
7574
7866
  const send = port => {
@@ -7576,7 +7868,7 @@ const send = port => {
7576
7868
  };
7577
7869
  const createIconThemeWorkerRpc = async () => {
7578
7870
  try {
7579
- const rpc = await create$5({
7871
+ const rpc = await create$6({
7580
7872
  commandMap: {},
7581
7873
  send
7582
7874
  });
@@ -7605,7 +7897,7 @@ const initializeIconThemeWorker = async () => {
7605
7897
  };
7606
7898
 
7607
7899
  const initializeRendererWorker = async () => {
7608
- const rpc = await create$4({
7900
+ const rpc = await create$5({
7609
7901
  commandMap: commandMap
7610
7902
  });
7611
7903
  set$1(rpc);
@@ -7614,6 +7906,11 @@ const initializeRendererWorker = async () => {
7614
7906
  const listen = async () => {
7615
7907
  registerCommands(commandMap);
7616
7908
  await Promise.all([initializeRendererWorker(), initializeIconThemeWorker(), initializeClipBoardWorker()]);
7909
+ const dialogRpc = await create$6({
7910
+ commandMap: {},
7911
+ send: sendMessagePortToDialogWorker
7912
+ });
7913
+ set$4(dialogRpc);
7617
7914
  };
7618
7915
 
7619
7916
  const main$1 = async () => {
@@ -7622,7 +7919,7 @@ const main$1 = async () => {
7622
7919
 
7623
7920
  const main = async () => {
7624
7921
  registerCommands(commandMap);
7625
- const rpc = await create$4({
7922
+ const rpc = await create$5({
7626
7923
  commandMap: commandMap
7627
7924
  });
7628
7925
  set$1(rpc);