@lvce-editor/main-area-worker 9.32.7 → 9.33.1

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,7 +1311,7 @@ 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
  };
@@ -1739,6 +1493,7 @@ const VirtualDomElements = {
1739
1493
  const Button$1 = 'event.button';
1740
1494
  const ClientX = 'event.clientX';
1741
1495
  const ClientY = 'event.clientY';
1496
+ const DataTransferFiles2 = 'event.dataTransfer.files2';
1742
1497
  const EventTargetClassName = 'event.target.className';
1743
1498
  const TargetName = 'event.target.name';
1744
1499
 
@@ -1751,6 +1506,7 @@ const None$1 = 0;
1751
1506
  const Electron = 2;
1752
1507
 
1753
1508
  const ClipBoardWorker = 3400;
1509
+ const DialogWorker = 7014;
1754
1510
  const ExtensionHostWorker = 44;
1755
1511
  const IconThemeWorker = 7009;
1756
1512
  const RendererWorker = 1;
@@ -1762,17 +1518,22 @@ const SetPatches = 'Viewlet.setPatches';
1762
1518
  const FocusEditorText = 12;
1763
1519
 
1764
1520
  const {
1521
+ set: set$5
1522
+ } = create$4(ClipBoardWorker);
1523
+
1524
+ const {
1525
+ invoke: invoke$2,
1765
1526
  set: set$4
1766
- } = create$3(ClipBoardWorker);
1527
+ } = create$4(DialogWorker);
1767
1528
 
1768
1529
  const {
1769
1530
  set: set$3
1770
- } = create$3(ExtensionHostWorker);
1531
+ } = create$4(ExtensionHostWorker);
1771
1532
 
1772
1533
  const {
1773
1534
  invoke: invoke$1,
1774
1535
  set: set$2
1775
- } = create$3(IconThemeWorker);
1536
+ } = create$4(IconThemeWorker);
1776
1537
  const getIcons = async iconRequests => {
1777
1538
  // @ts-ignore
1778
1539
  return invoke$1('IconTheme.getIcons', iconRequests);
@@ -1782,7 +1543,7 @@ const {
1782
1543
  invoke,
1783
1544
  invokeAndTransfer,
1784
1545
  set: set$1
1785
- } = create$3(RendererWorker);
1546
+ } = create$4(RendererWorker);
1786
1547
  const handleModifiedStatusChange$1 = async (uri, modified) => {
1787
1548
  return invoke('Main.handleModifiedStatusChange', uri, modified);
1788
1549
  };
@@ -1793,10 +1554,18 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1793
1554
  number(y);
1794
1555
  await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1795
1556
  };
1557
+ const getFileHandles = async fileIds => {
1558
+ const files = await invoke('FileSystemHandle.getFileHandles', fileIds);
1559
+ return files;
1560
+ };
1796
1561
  const sendMessagePortToClipBoardWorker$1 = async (port, rpcId) => {
1797
1562
  const command = 'ClipBoard.handleMessagePort';
1798
1563
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
1799
1564
  };
1565
+ const sendMessagePortToDialogWorker = async port => {
1566
+ const command = 'HandleMessagePort.handleMessagePort';
1567
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1568
+ };
1800
1569
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1801
1570
  const command = 'IconTheme.handleMessagePort';
1802
1571
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
@@ -1808,12 +1577,258 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1808
1577
  const command = 'HandleMessagePort.handleMessagePort2';
1809
1578
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1810
1579
  };
1811
- const confirm = async (message, options) => {
1580
+ const confirm$1 = async (message, options) => {
1812
1581
  const result = await invoke('ConfirmPrompt.prompt', message, options);
1813
1582
  return result;
1814
1583
  };
1815
- const writeClipBoardText = async text => {
1816
- await invoke('ClipBoard.writeText', /* text */text);
1584
+ const writeClipBoardText = async text => {
1585
+ await invoke('ClipBoard.writeText', /* text */text);
1586
+ };
1587
+
1588
+ const toCommandId = key => {
1589
+ const dotIndex = key.indexOf('.');
1590
+ return key.slice(dotIndex + 1);
1591
+ };
1592
+ const create$3 = () => {
1593
+ const commandQueues = new Map();
1594
+ const generations = Object.create(null);
1595
+ const states = Object.create(null);
1596
+ const commandMapRef = {};
1597
+ const getGeneration = uid => generations[uid] || 0;
1598
+ const isCurrentGeneration = (uid, generation) => {
1599
+ return states[uid] !== undefined && getGeneration(uid) === generation;
1600
+ };
1601
+ const updateState = (uid, generation, fallbackState, updater) => {
1602
+ if (!isCurrentGeneration(uid, generation)) {
1603
+ return Promise.resolve(fallbackState);
1604
+ }
1605
+ const current = states[uid];
1606
+ const updatedState = updater(current.newState);
1607
+ if (updatedState !== current.newState) {
1608
+ states[uid] = {
1609
+ newState: updatedState,
1610
+ oldState: current.oldState,
1611
+ scheduledState: updatedState
1612
+ };
1613
+ }
1614
+ return Promise.resolve(updatedState);
1615
+ };
1616
+ const createAsyncCommandContext = (uid, generation) => {
1617
+ let latestState = states[uid].newState;
1618
+ return {
1619
+ getState: () => {
1620
+ if (isCurrentGeneration(uid, generation)) {
1621
+ latestState = states[uid].newState;
1622
+ }
1623
+ return latestState;
1624
+ },
1625
+ updateState: async updater => {
1626
+ latestState = await updateState(uid, generation, latestState, updater);
1627
+ return latestState;
1628
+ }
1629
+ };
1630
+ };
1631
+ const enqueueCommand = async (uid, command) => {
1632
+ const previous = commandQueues.get(uid) || Promise.resolve();
1633
+ const run = async () => {
1634
+ try {
1635
+ await previous;
1636
+ } catch {
1637
+ // The previous caller receives its error; later commands must still run.
1638
+ }
1639
+ await command();
1640
+ };
1641
+ const current = run();
1642
+ commandQueues.set(uid, current);
1643
+ try {
1644
+ await current;
1645
+ } finally {
1646
+ if (commandQueues.get(uid) === current) {
1647
+ commandQueues.delete(uid);
1648
+ }
1649
+ }
1650
+ };
1651
+ return {
1652
+ clear() {
1653
+ commandQueues.clear();
1654
+ for (const key of Object.keys(states)) {
1655
+ delete states[key];
1656
+ }
1657
+ },
1658
+ diff(uid, modules, numbers) {
1659
+ const {
1660
+ oldState,
1661
+ scheduledState
1662
+ } = states[uid];
1663
+ const diffResult = [];
1664
+ for (let i = 0; i < modules.length; i++) {
1665
+ const fn = modules[i];
1666
+ if (!fn(oldState, scheduledState)) {
1667
+ diffResult.push(numbers[i]);
1668
+ }
1669
+ }
1670
+ return diffResult;
1671
+ },
1672
+ dispose(uid) {
1673
+ commandQueues.delete(uid);
1674
+ delete states[uid];
1675
+ },
1676
+ get(uid) {
1677
+ return states[uid];
1678
+ },
1679
+ getCommandIds() {
1680
+ const keys = Object.keys(commandMapRef);
1681
+ const ids = keys.map(toCommandId);
1682
+ return ids;
1683
+ },
1684
+ getKeys() {
1685
+ return Object.keys(states).map(Number);
1686
+ },
1687
+ registerCommands(commandMap) {
1688
+ Object.assign(commandMapRef, commandMap);
1689
+ },
1690
+ set(uid, oldState, newState, scheduledState) {
1691
+ const current = states[uid];
1692
+ if (!current || oldState === newState && newState !== current.newState) {
1693
+ generations[uid] = getGeneration(uid) + 1;
1694
+ }
1695
+ states[uid] = {
1696
+ newState,
1697
+ oldState,
1698
+ scheduledState: scheduledState ?? newState
1699
+ };
1700
+ },
1701
+ wrapAsyncCommand(fn) {
1702
+ const wrapped = async (uid, ...args) => {
1703
+ const generation = getGeneration(uid);
1704
+ const context = createAsyncCommandContext(uid, generation);
1705
+ await fn(context, ...args);
1706
+ };
1707
+ return wrapped;
1708
+ },
1709
+ wrapCommand(fn) {
1710
+ const wrapped = async (uid, ...args) => {
1711
+ const generation = getGeneration(uid);
1712
+ const {
1713
+ newState,
1714
+ oldState
1715
+ } = states[uid];
1716
+ const newerState = await fn(newState, ...args);
1717
+ if (oldState === newerState || newState === newerState) {
1718
+ return;
1719
+ }
1720
+ if (!isCurrentGeneration(uid, generation)) {
1721
+ return;
1722
+ }
1723
+ const latestOld = states[uid];
1724
+ const latestNew = {
1725
+ ...latestOld.newState,
1726
+ ...newerState
1727
+ };
1728
+ states[uid] = {
1729
+ newState: latestNew,
1730
+ oldState: latestOld.oldState,
1731
+ scheduledState: latestNew
1732
+ };
1733
+ };
1734
+ return wrapped;
1735
+ },
1736
+ wrapGetter(fn) {
1737
+ const wrapped = (uid, ...args) => {
1738
+ const {
1739
+ newState
1740
+ } = states[uid];
1741
+ return fn(newState, ...args);
1742
+ };
1743
+ return wrapped;
1744
+ },
1745
+ wrapLoadContent(fn) {
1746
+ const wrapped = async (uid, ...args) => {
1747
+ const generation = getGeneration(uid);
1748
+ const {
1749
+ newState,
1750
+ oldState
1751
+ } = states[uid];
1752
+ const result = await fn(newState, ...args);
1753
+ const {
1754
+ error,
1755
+ state
1756
+ } = result;
1757
+ if (oldState === state || newState === state) {
1758
+ return {
1759
+ error
1760
+ };
1761
+ }
1762
+ if (!isCurrentGeneration(uid, generation)) {
1763
+ return {
1764
+ error
1765
+ };
1766
+ }
1767
+ const latestOld = states[uid];
1768
+ const latestNew = {
1769
+ ...latestOld.newState,
1770
+ ...state
1771
+ };
1772
+ states[uid] = {
1773
+ newState: latestNew,
1774
+ oldState: latestOld.oldState,
1775
+ scheduledState: latestNew
1776
+ };
1777
+ return {
1778
+ error
1779
+ };
1780
+ };
1781
+ return wrapped;
1782
+ },
1783
+ wrapSerialAsyncCommand(fn) {
1784
+ const wrapped = async (uid, ...args) => {
1785
+ await enqueueCommand(uid, async () => {
1786
+ if (!states[uid]) {
1787
+ return;
1788
+ }
1789
+ const generation = getGeneration(uid);
1790
+ const context = createAsyncCommandContext(uid, generation);
1791
+ await fn(context, ...args);
1792
+ });
1793
+ };
1794
+ return wrapped;
1795
+ },
1796
+ wrapSerialCommand(fn) {
1797
+ const wrapped = async (uid, ...args) => {
1798
+ await enqueueCommand(uid, async () => {
1799
+ if (!states[uid]) {
1800
+ return;
1801
+ }
1802
+ const generation = getGeneration(uid);
1803
+ const {
1804
+ newState,
1805
+ oldState
1806
+ } = states[uid];
1807
+ const newerState = await fn(newState, ...args);
1808
+ if (oldState === newerState || newState === newerState) {
1809
+ return;
1810
+ }
1811
+ if (!isCurrentGeneration(uid, generation)) {
1812
+ return;
1813
+ }
1814
+ const latestOld = states[uid];
1815
+ const latestNew = {
1816
+ ...latestOld.newState,
1817
+ ...newerState
1818
+ };
1819
+ states[uid] = {
1820
+ newState: latestNew,
1821
+ oldState: latestOld.oldState,
1822
+ scheduledState: latestNew
1823
+ };
1824
+ });
1825
+ };
1826
+ return wrapped;
1827
+ }
1828
+ };
1829
+ };
1830
+ const terminate = () => {
1831
+ globalThis.close();
1817
1832
  };
1818
1833
 
1819
1834
  const addClosedTabs = (state, entries) => {
@@ -2013,7 +2028,7 @@ const withActiveEditorChangeAsync = fn => {
2013
2028
  };
2014
2029
  };
2015
2030
 
2016
- const registry = create$f();
2031
+ const registry = create$3();
2017
2032
  const {
2018
2033
  get,
2019
2034
  getCommandIds,
@@ -2360,6 +2375,17 @@ const saveEditor = async editorUid => {
2360
2375
  return invoke('Editor.save', editorUid);
2361
2376
  };
2362
2377
 
2378
+ const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
2379
+ const confirm = async (message, options) => {
2380
+ try {
2381
+ return await invoke$2('ConfirmPrompt.prompt', message, options);
2382
+ } catch (error) {
2383
+ if (!String(error).includes(missingDialogWorkerRelay)) {
2384
+ throw error;
2385
+ }
2386
+ return confirm$1(message, options);
2387
+ }
2388
+ };
2363
2389
  const promptSave = async title => {
2364
2390
  const shouldSave = await confirm(`Do you want to save the changes you made to ${title}?`, {
2365
2391
  cancelMessage: 'More Options',
@@ -4060,11 +4086,14 @@ const updateIconCache = (iconCache, missingRequests, newIcons) => {
4060
4086
  return newFileIconCache;
4061
4087
  };
4062
4088
 
4089
+ const getUri = tab => {
4090
+ return tab.uri || '';
4091
+ };
4063
4092
  const getFileIconsForTabs = async (tabs, fileIconCache) => {
4064
4093
  const missingRequests = getMissingIconRequestsForTabs(tabs, fileIconCache);
4065
4094
  const newIcons = await requestFileIcons(missingRequests);
4066
4095
  const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
4067
- const tabUris = tabs.map(tab => tab.uri || '');
4096
+ const tabUris = tabs.map(getUri);
4068
4097
  const icons = getIconsCached(tabUris, newFileIconCache);
4069
4098
  return {
4070
4099
  icons,
@@ -4612,23 +4641,6 @@ const Down = 2;
4612
4641
  const Left = 3;
4613
4642
  const Right = 4;
4614
4643
 
4615
- const getSplitDirection = (x, y, width, height) => {
4616
- const percentX = x / width;
4617
- if (percentX < 0.25) {
4618
- return Left;
4619
- }
4620
- if (percentX > 0.75) {
4621
- return Right;
4622
- }
4623
- const percentY = y / height;
4624
- if (percentY < 0.25) {
4625
- return Up;
4626
- }
4627
- if (percentY > 0.75) {
4628
- return Down;
4629
- }
4630
- return None;
4631
- };
4632
4644
  const getOverlay = (x, y, width, height, splitDirection) => {
4633
4645
  const halfHeight = height / 2;
4634
4646
  const halfWidth = width / 2;
@@ -4670,6 +4682,25 @@ const getOverlay = (x, y, width, height, splitDirection) => {
4670
4682
  };
4671
4683
  }
4672
4684
  };
4685
+
4686
+ const getSplitDirection = (x, y, width, height) => {
4687
+ const percentX = x / width;
4688
+ if (percentX < 0.25) {
4689
+ return Left;
4690
+ }
4691
+ if (percentX > 0.75) {
4692
+ return Right;
4693
+ }
4694
+ const percentY = y / height;
4695
+ if (percentY < 0.25) {
4696
+ return Up;
4697
+ }
4698
+ if (percentY > 0.75) {
4699
+ return Down;
4700
+ }
4701
+ return None;
4702
+ };
4703
+
4673
4704
  const getDragOverlay = (state, eventX, eventY) => {
4674
4705
  const {
4675
4706
  height,
@@ -4705,6 +4736,37 @@ const handleDragOver = (state, eventX, eventY) => {
4705
4736
  };
4706
4737
  };
4707
4738
 
4739
+ const lineSeparatorRegex = /\r?\n/;
4740
+ const isUriList = item => {
4741
+ if (!item || typeof item !== 'object') {
4742
+ return false;
4743
+ }
4744
+ const candidate = item;
4745
+ return candidate.kind === 'string' && candidate.type === 'text/uri-list' && typeof candidate.value === 'string';
4746
+ };
4747
+ const parseUriList = value => {
4748
+ return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
4749
+ };
4750
+ const getDroppedUris = async itemIds => {
4751
+ if (itemIds.length === 0) {
4752
+ return [];
4753
+ }
4754
+ const items = await getFileHandles(itemIds);
4755
+ return items.filter(isUriList).flatMap(item => parseUriList(item.value));
4756
+ };
4757
+
4758
+ const openUrisWithContext = async (context, uris) => {
4759
+ for (const uri of uris) {
4760
+ await openUriWithContext(context, uri);
4761
+ }
4762
+ };
4763
+
4764
+ const handleDrop = async (context, itemIds) => {
4765
+ await context.updateState(handleDragLeave);
4766
+ const uris = await getDroppedUris(itemIds);
4767
+ await openUrisWithContext(context, uris);
4768
+ };
4769
+
4708
4770
  const EditorGroupHeader = 'EditorGroupHeader';
4709
4771
  const EmptyGroupHeader = 'EmptyGroupHeader';
4710
4772
  const EmptyGroupCloseButton = 'EmptyGroupCloseButton';
@@ -5648,7 +5710,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
5648
5710
 
5649
5711
  const createExtensionHostRpc = async () => {
5650
5712
  try {
5651
- const rpc = await create$8({
5713
+ const rpc = await create$9({
5652
5714
  commandMap: {},
5653
5715
  send: sendMessagePortToExtensionHostWorker
5654
5716
  });
@@ -6042,28 +6104,6 @@ const newWindow = async state => {
6042
6104
  return state;
6043
6105
  };
6044
6106
 
6045
- const openUrisWithContext = async (context, uris) => {
6046
- if (uris.length === 0) {
6047
- return;
6048
- }
6049
- await openUriWithContext(context, uris[0]);
6050
- if (uris.length === 1) {
6051
- return;
6052
- }
6053
- let currentState = context.getState();
6054
- const firstTab = findTabByUri(currentState, uris[0]);
6055
- for (const uri of uris.slice(1)) {
6056
- const existingTab = findTabByUri(currentState, uri);
6057
- if (!existingTab) {
6058
- currentState = ensureActiveGroup(currentState, uri);
6059
- }
6060
- }
6061
- if (firstTab) {
6062
- currentState = switchTab(currentState, firstTab.groupId, firstTab.tab.id);
6063
- }
6064
- await context.updateState(() => currentState);
6065
- };
6066
-
6067
6107
  const refresh = state => {
6068
6108
  return {
6069
6109
  ...state
@@ -6334,14 +6374,11 @@ const compareNodes = (oldNode, newNode) => {
6334
6374
  }
6335
6375
  const patches = [];
6336
6376
  // Handle reference nodes - special handling for uid changes
6337
- if (oldNode.type === Reference) {
6338
- if (oldNode.uid !== newNode.uid) {
6339
- patches.push({
6340
- type: SetReferenceNodeUid,
6341
- uid: newNode.uid
6342
- });
6343
- }
6344
- return patches;
6377
+ if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
6378
+ patches.push({
6379
+ type: SetReferenceNodeUid,
6380
+ uid: newNode.uid
6381
+ });
6345
6382
  }
6346
6383
  // Handle text nodes
6347
6384
  if (oldNode.type === Text && newNode.type === Text) {
@@ -6354,8 +6391,8 @@ const compareNodes = (oldNode, newNode) => {
6354
6391
  return patches;
6355
6392
  }
6356
6393
  // Compare attributes
6357
- const oldKeys = getKeys(oldNode);
6358
- const newKeys = getKeys(newNode);
6394
+ const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
6395
+ const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
6359
6396
  // Check for attribute changes
6360
6397
  for (const key of newKeys) {
6361
6398
  if (oldNode[key] !== newNode[key]) {
@@ -6379,9 +6416,14 @@ const compareNodes = (oldNode, newNode) => {
6379
6416
  };
6380
6417
 
6381
6418
  const treeToArray = node => {
6382
- const result = [node.node];
6383
- for (const child of node.children) {
6384
- result.push(...treeToArray(child));
6419
+ const result = [];
6420
+ const stack = [node];
6421
+ while (stack.length > 0) {
6422
+ const current = stack.pop();
6423
+ result.push(current.node);
6424
+ for (let i = current.children.length - 1; i >= 0; i--) {
6425
+ stack.push(current.children[i]);
6426
+ }
6385
6427
  }
6386
6428
  return result;
6387
6429
  };
@@ -6493,17 +6535,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
6493
6535
  };
6494
6536
 
6495
6537
  const removeTrailingNavigationPatches = patches => {
6496
- // Find the last non-navigation patch
6497
- let lastNonNavigationIndex = -1;
6498
- for (let i = patches.length - 1; i >= 0; i--) {
6499
- const patch = patches[i];
6538
+ while (patches.length > 0) {
6539
+ const patch = patches.at(-1);
6500
6540
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
6501
- lastNonNavigationIndex = i;
6502
6541
  break;
6503
6542
  }
6543
+ patches.pop();
6504
6544
  }
6505
- // Return patches up to and including the last non-navigation patch
6506
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
6545
+ return patches;
6507
6546
  };
6508
6547
 
6509
6548
  const diffTree = (oldNodes, newNodes) => {
@@ -6572,15 +6611,16 @@ const paragraphNode = {
6572
6611
  childCount: 1,
6573
6612
  type: P
6574
6613
  };
6614
+ const retryButtonNode = {
6615
+ childCount: 1,
6616
+ className: mergeClassNames(Button, ButtonSecondary),
6617
+ 'data-action': RetryOpen,
6618
+ name: RetryOpen,
6619
+ onClick: HandleClickAction,
6620
+ type: Button$2
6621
+ };
6575
6622
  const renderError = errorMessage => {
6576
- return [textEditorErrorNode, editorContentErrorNode, paragraphNode, text(`Error: ${errorMessage}`), {
6577
- childCount: 1,
6578
- className: mergeClassNames(Button, ButtonSecondary),
6579
- 'data-action': RetryOpen,
6580
- name: RetryOpen,
6581
- onClick: HandleClickAction,
6582
- type: Button$2
6583
- }, text(retry())];
6623
+ return [textEditorErrorNode, editorContentErrorNode, paragraphNode, text(`Error: ${errorMessage}`), retryButtonNode, text(retry())];
6584
6624
  };
6585
6625
 
6586
6626
  const textEditorLoadingNode = {
@@ -7177,7 +7217,7 @@ const renderEventListeners = () => {
7177
7217
  params: ['handleDragLeave']
7178
7218
  }, {
7179
7219
  name: HandleDrop,
7180
- params: ['handleDragLeave'],
7220
+ params: ['handleDrop', DataTransferFiles2],
7181
7221
  preventDefault: true
7182
7222
  }];
7183
7223
  };
@@ -7798,6 +7838,7 @@ const commandMap = {
7798
7838
  'MainArea.handleDoubleClick': wrapSerialCommand(handleDoubleClick),
7799
7839
  'MainArea.handleDragLeave': wrapSerialCommand(handleDragLeave),
7800
7840
  'MainArea.handleDragOver': wrapSerialCommand(handleDragOver),
7841
+ 'MainArea.handleDrop': wrapSerialAsyncCommand(handleDrop),
7801
7842
  'MainArea.handleHeaderDoubleClick': wrapSerialCommand(handleHeaderDoubleClick),
7802
7843
  'MainArea.handleIconThemeChange': wrapSerialCommand(handleIconThemeChange),
7803
7844
  'MainArea.handleModifiedStatusChange': wrapAsyncCommand(handleModifiedStatusChangeWithContext),
@@ -7851,11 +7892,11 @@ const sendMessagePortToClipBoardWorker = async port => {
7851
7892
  };
7852
7893
 
7853
7894
  const initializeClipBoardWorker = async () => {
7854
- const rpc = await create$6({
7895
+ const rpc = await create$7({
7855
7896
  commandMap: {},
7856
7897
  send: sendMessagePortToClipBoardWorker
7857
7898
  });
7858
- set$4(rpc);
7899
+ set$5(rpc);
7859
7900
  };
7860
7901
 
7861
7902
  const send = port => {
@@ -7863,7 +7904,7 @@ const send = port => {
7863
7904
  };
7864
7905
  const createIconThemeWorkerRpc = async () => {
7865
7906
  try {
7866
- const rpc = await create$5({
7907
+ const rpc = await create$6({
7867
7908
  commandMap: {},
7868
7909
  send
7869
7910
  });
@@ -7892,7 +7933,7 @@ const initializeIconThemeWorker = async () => {
7892
7933
  };
7893
7934
 
7894
7935
  const initializeRendererWorker = async () => {
7895
- const rpc = await create$4({
7936
+ const rpc = await create$5({
7896
7937
  commandMap: commandMap
7897
7938
  });
7898
7939
  set$1(rpc);
@@ -7901,6 +7942,11 @@ const initializeRendererWorker = async () => {
7901
7942
  const listen = async () => {
7902
7943
  registerCommands(commandMap);
7903
7944
  await Promise.all([initializeRendererWorker(), initializeIconThemeWorker(), initializeClipBoardWorker()]);
7945
+ const dialogRpc = await create$6({
7946
+ commandMap: {},
7947
+ send: sendMessagePortToDialogWorker
7948
+ });
7949
+ set$4(dialogRpc);
7904
7950
  };
7905
7951
 
7906
7952
  const main$1 = async () => {
@@ -7909,7 +7955,7 @@ const main$1 = async () => {
7909
7955
 
7910
7956
  const main = async () => {
7911
7957
  registerCommands(commandMap);
7912
- const rpc = await create$4({
7958
+ const rpc = await create$5({
7913
7959
  commandMap: commandMap
7914
7960
  });
7915
7961
  set$1(rpc);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.32.7",
3
+ "version": "9.33.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",