@lvce-editor/main-area-worker 9.32.7 → 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,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
  };
@@ -1751,6 +1505,7 @@ const None$1 = 0;
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,12 +1572,258 @@ 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) => {
@@ -2013,7 +2023,7 @@ const withActiveEditorChangeAsync = fn => {
2013
2023
  };
2014
2024
  };
2015
2025
 
2016
- const registry = create$f();
2026
+ const registry = create$3();
2017
2027
  const {
2018
2028
  get,
2019
2029
  getCommandIds,
@@ -2360,6 +2370,17 @@ const saveEditor = async editorUid => {
2360
2370
  return invoke('Editor.save', editorUid);
2361
2371
  };
2362
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
+ };
2363
2384
  const promptSave = async title => {
2364
2385
  const shouldSave = await confirm(`Do you want to save the changes you made to ${title}?`, {
2365
2386
  cancelMessage: 'More Options',
@@ -5648,7 +5669,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
5648
5669
 
5649
5670
  const createExtensionHostRpc = async () => {
5650
5671
  try {
5651
- const rpc = await create$8({
5672
+ const rpc = await create$9({
5652
5673
  commandMap: {},
5653
5674
  send: sendMessagePortToExtensionHostWorker
5654
5675
  });
@@ -6043,25 +6064,9 @@ const newWindow = async state => {
6043
6064
  };
6044
6065
 
6045
6066
  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);
6067
+ for (const uri of uris) {
6068
+ await openUriWithContext(context, uri);
6063
6069
  }
6064
- await context.updateState(() => currentState);
6065
6070
  };
6066
6071
 
6067
6072
  const refresh = state => {
@@ -6334,14 +6339,11 @@ const compareNodes = (oldNode, newNode) => {
6334
6339
  }
6335
6340
  const patches = [];
6336
6341
  // 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;
6342
+ if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
6343
+ patches.push({
6344
+ type: SetReferenceNodeUid,
6345
+ uid: newNode.uid
6346
+ });
6345
6347
  }
6346
6348
  // Handle text nodes
6347
6349
  if (oldNode.type === Text && newNode.type === Text) {
@@ -6354,8 +6356,8 @@ const compareNodes = (oldNode, newNode) => {
6354
6356
  return patches;
6355
6357
  }
6356
6358
  // Compare attributes
6357
- const oldKeys = getKeys(oldNode);
6358
- 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');
6359
6361
  // Check for attribute changes
6360
6362
  for (const key of newKeys) {
6361
6363
  if (oldNode[key] !== newNode[key]) {
@@ -6379,9 +6381,14 @@ const compareNodes = (oldNode, newNode) => {
6379
6381
  };
6380
6382
 
6381
6383
  const treeToArray = node => {
6382
- const result = [node.node];
6383
- for (const child of node.children) {
6384
- 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
+ }
6385
6392
  }
6386
6393
  return result;
6387
6394
  };
@@ -6493,17 +6500,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
6493
6500
  };
6494
6501
 
6495
6502
  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];
6503
+ while (patches.length > 0) {
6504
+ const patch = patches.at(-1);
6500
6505
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
6501
- lastNonNavigationIndex = i;
6502
6506
  break;
6503
6507
  }
6508
+ patches.pop();
6504
6509
  }
6505
- // Return patches up to and including the last non-navigation patch
6506
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
6510
+ return patches;
6507
6511
  };
6508
6512
 
6509
6513
  const diffTree = (oldNodes, newNodes) => {
@@ -6572,15 +6576,16 @@ const paragraphNode = {
6572
6576
  childCount: 1,
6573
6577
  type: P
6574
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
+ };
6575
6587
  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())];
6588
+ return [textEditorErrorNode, editorContentErrorNode, paragraphNode, text(`Error: ${errorMessage}`), retryButtonNode, text(retry())];
6584
6589
  };
6585
6590
 
6586
6591
  const textEditorLoadingNode = {
@@ -7851,11 +7856,11 @@ const sendMessagePortToClipBoardWorker = async port => {
7851
7856
  };
7852
7857
 
7853
7858
  const initializeClipBoardWorker = async () => {
7854
- const rpc = await create$6({
7859
+ const rpc = await create$7({
7855
7860
  commandMap: {},
7856
7861
  send: sendMessagePortToClipBoardWorker
7857
7862
  });
7858
- set$4(rpc);
7863
+ set$5(rpc);
7859
7864
  };
7860
7865
 
7861
7866
  const send = port => {
@@ -7863,7 +7868,7 @@ const send = port => {
7863
7868
  };
7864
7869
  const createIconThemeWorkerRpc = async () => {
7865
7870
  try {
7866
- const rpc = await create$5({
7871
+ const rpc = await create$6({
7867
7872
  commandMap: {},
7868
7873
  send
7869
7874
  });
@@ -7892,7 +7897,7 @@ const initializeIconThemeWorker = async () => {
7892
7897
  };
7893
7898
 
7894
7899
  const initializeRendererWorker = async () => {
7895
- const rpc = await create$4({
7900
+ const rpc = await create$5({
7896
7901
  commandMap: commandMap
7897
7902
  });
7898
7903
  set$1(rpc);
@@ -7901,6 +7906,11 @@ const initializeRendererWorker = async () => {
7901
7906
  const listen = async () => {
7902
7907
  registerCommands(commandMap);
7903
7908
  await Promise.all([initializeRendererWorker(), initializeIconThemeWorker(), initializeClipBoardWorker()]);
7909
+ const dialogRpc = await create$6({
7910
+ commandMap: {},
7911
+ send: sendMessagePortToDialogWorker
7912
+ });
7913
+ set$4(dialogRpc);
7904
7914
  };
7905
7915
 
7906
7916
  const main$1 = async () => {
@@ -7909,7 +7919,7 @@ const main$1 = async () => {
7909
7919
 
7910
7920
  const main = async () => {
7911
7921
  registerCommands(commandMap);
7912
- const rpc = await create$4({
7922
+ const rpc = await create$5({
7913
7923
  commandMap: commandMap
7914
7924
  });
7915
7925
  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.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",