@lvce-editor/main-area-worker 9.49.0 → 9.50.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.
@@ -455,70 +455,11 @@ class IpcChildWithModuleWorker extends Ipc {
455
455
  const wrap$f = global => {
456
456
  return new IpcChildWithModuleWorker(global);
457
457
  };
458
- const waitForFirstMessage = async port => {
459
- const {
460
- promise,
461
- resolve
462
- } = Promise.withResolvers();
463
- port.addEventListener('message', resolve, {
464
- once: true
465
- });
466
- const event = await promise;
467
- // @ts-ignore
468
- return event.data;
469
- };
470
- const listen$6 = async () => {
471
- const parentIpcRaw = listen$7();
472
- signal$8(parentIpcRaw);
473
- const parentIpc = wrap$f(parentIpcRaw);
474
- const firstMessage = await waitForFirstMessage(parentIpc);
475
- if (firstMessage.method !== 'initialize') {
476
- throw new IpcError('unexpected first message');
477
- }
478
- const type = firstMessage.params[0];
479
- if (type === 'message-port') {
480
- parentIpc.send({
481
- id: firstMessage.id,
482
- jsonrpc: '2.0',
483
- result: null
484
- });
485
- parentIpc.dispose();
486
- const port = firstMessage.params[1];
487
- return port;
488
- }
489
- return globalThis;
490
- };
491
- class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
492
- getData(event) {
493
- return getData$2(event);
494
- }
495
- send(message) {
496
- this._rawIpc.postMessage(message);
497
- }
498
- sendAndTransfer(message) {
499
- const transfer = getTransferrables(message);
500
- this._rawIpc.postMessage(message, transfer);
501
- }
502
- dispose() {
503
- if (this._rawIpc.close) {
504
- this._rawIpc.close();
505
- }
506
- }
507
- onClose(callback) {
508
- // ignore
509
- }
510
- onMessage(callback) {
511
- this._rawIpc.addEventListener('message', callback);
512
- this._rawIpc.start();
513
- }
514
- }
515
- const wrap$e = port => {
516
- return new IpcChildWithModuleWorkerAndMessagePort(port);
517
- };
518
- const IpcChildWithModuleWorkerAndMessagePort$1 = {
458
+ const IpcChildWithModuleWorker$1 = {
519
459
  __proto__: null,
520
- listen: listen$6,
521
- wrap: wrap$e
460
+ listen: listen$7,
461
+ signal: signal$8,
462
+ wrap: wrap$f
522
463
  };
523
464
  const addListener = (emitter, type, callback) => {
524
465
  if ('addEventListener' in emitter) {
@@ -1242,7 +1183,7 @@ const create$5 = async ({
1242
1183
  }) => {
1243
1184
  // TODO create a commandMap per rpc instance
1244
1185
  register(commandMap);
1245
- const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
1186
+ const ipc = await listen$1(IpcChildWithModuleWorker$1);
1246
1187
  handleIpc(ipc);
1247
1188
  const rpc = createRpc(ipc);
1248
1189
  return rpc;
@@ -1268,339 +1209,11 @@ const createMockRpc = ({
1268
1209
  return mockRpc;
1269
1210
  };
1270
1211
 
1271
- const rpcs = Object.create(null);
1272
- const set$8 = (id, rpc) => {
1273
- rpcs[id] = rpc;
1274
- };
1275
- const get$1 = id => {
1276
- return rpcs[id];
1277
- };
1278
- const remove = id => {
1279
- delete rpcs[id];
1280
- };
1281
-
1282
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
1283
- const create$4 = rpcId => {
1284
- return {
1285
- async dispose() {
1286
- const rpc = get$1(rpcId);
1287
- await rpc.dispose();
1288
- },
1289
- // @ts-ignore
1290
- invoke(method, ...params) {
1291
- const rpc = get$1(rpcId);
1292
- // @ts-ignore
1293
- return rpc.invoke(method, ...params);
1294
- },
1295
- // @ts-ignore
1296
- invokeAndTransfer(method, ...params) {
1297
- const rpc = get$1(rpcId);
1298
- // @ts-ignore
1299
- return rpc.invokeAndTransfer(method, ...params);
1300
- },
1301
- registerMockRpc(commandMap) {
1302
- const mockRpc = createMockRpc({
1303
- commandMap
1304
- });
1305
- set$8(rpcId, mockRpc);
1306
- // @ts-ignore
1307
- mockRpc[Symbol.dispose] = () => {
1308
- remove(rpcId);
1309
- };
1310
- // @ts-ignore
1311
- return mockRpc;
1312
- },
1313
- set(rpc) {
1314
- set$8(rpcId, rpc);
1315
- }
1316
- };
1317
- };
1318
-
1319
- const None$2 = 'none';
1320
- const Tab$1 = 'tab';
1321
- const TabList = 'tablist';
1322
- const ToolBar = 'toolbar';
1323
-
1324
- const Audio = 0;
1325
- const Button$2 = 1;
1326
- const Col = 2;
1327
- const ColGroup = 3;
1328
- const Div = 4;
1329
- const H1 = 5;
1330
- const Input = 6;
1331
- const Kbd = 7;
1332
- const Span = 8;
1333
- const Table = 9;
1334
- const TBody = 10;
1335
- const Td = 11;
1336
- const Text = 12;
1337
- const Th = 13;
1338
- const THead = 14;
1339
- const Tr = 15;
1340
- const I = 16;
1341
- const Img = 17;
1342
- const Root = 0;
1343
- const Ins = 20;
1344
- const Del = 21;
1345
- const H2 = 22;
1346
- const H3 = 23;
1347
- const H4 = 24;
1348
- const H5 = 25;
1349
- const H6 = 26;
1350
- const Article = 27;
1351
- const Aside = 28;
1352
- const Footer = 29;
1353
- const Header = 30;
1354
- const Nav = 40;
1355
- const Section = 41;
1356
- const Search = 42;
1357
- const Dd = 43;
1358
- const Dl = 44;
1359
- const Figcaption = 45;
1360
- const Figure = 46;
1361
- const Hr = 47;
1362
- const Li = 48;
1363
- const Ol = 49;
1364
- const P = 50;
1365
- const Pre = 51;
1366
- const A = 53;
1367
- const Abbr = 54;
1368
- const Br = 55;
1369
- const Cite = 56;
1370
- const Data = 57;
1371
- const Time = 58;
1372
- const Tfoot = 59;
1373
- const Ul = 60;
1374
- const Video = 61;
1375
- const TextArea = 62;
1376
- const Select = 63;
1377
- const Option = 64;
1378
- const Code = 65;
1379
- const Label = 66;
1380
- const Dt = 67;
1381
- const Iframe = 68;
1382
- const Main$2 = 69;
1383
- const Strong = 70;
1384
- const Em = 71;
1385
- const Style = 72;
1386
- const Html = 73;
1387
- const Head = 74;
1388
- const Title = 75;
1389
- const Meta = 76;
1390
- const Canvas = 77;
1391
- const Form = 78;
1392
- const BlockQuote = 79;
1393
- const Quote = 80;
1394
- const Circle = 81;
1395
- const Defs = 82;
1396
- const Ellipse = 83;
1397
- const G = 84;
1398
- const Line = 85;
1399
- const Path = 86;
1400
- const Polygon = 87;
1401
- const Polyline = 88;
1402
- const Rect = 89;
1403
- const Svg = 90;
1404
- const Use = 91;
1405
- const Reference = 100;
1406
-
1407
- const VirtualDomElements = {
1408
- __proto__: null,
1409
- A,
1410
- Abbr,
1411
- Article,
1412
- Aside,
1413
- Audio,
1414
- BlockQuote,
1415
- Br,
1416
- Button: Button$2,
1417
- Canvas,
1418
- Circle,
1419
- Cite,
1420
- Code,
1421
- Col,
1422
- ColGroup,
1423
- Data,
1424
- Dd,
1425
- Defs,
1426
- Del,
1427
- Div,
1428
- Dl,
1429
- Dt,
1430
- Ellipse,
1431
- Em,
1432
- Figcaption,
1433
- Figure,
1434
- Footer,
1435
- Form,
1436
- G,
1437
- H1,
1438
- H2,
1439
- H3,
1440
- H4,
1441
- H5,
1442
- H6,
1443
- Head,
1444
- Header,
1445
- Hr,
1446
- Html,
1447
- I,
1448
- Iframe,
1449
- Img,
1450
- Input,
1451
- Ins,
1452
- Kbd,
1453
- Label,
1454
- Li,
1455
- Line,
1456
- Main: Main$2,
1457
- Meta,
1458
- Nav,
1459
- Ol,
1460
- Option,
1461
- P,
1462
- Path,
1463
- Polygon,
1464
- Polyline,
1465
- Pre,
1466
- Quote,
1467
- Rect,
1468
- Reference,
1469
- Root,
1470
- Search,
1471
- Section,
1472
- Select,
1473
- Span,
1474
- Strong,
1475
- Style,
1476
- Svg,
1477
- TBody,
1478
- THead,
1479
- Table,
1480
- Td,
1481
- Text,
1482
- TextArea,
1483
- Tfoot,
1484
- Th,
1485
- Time,
1486
- Title,
1487
- Tr,
1488
- Ul,
1489
- Use,
1490
- Video
1491
- };
1492
-
1493
- const Button$1 = 'event.button';
1494
- const ClientX = 'event.clientX';
1495
- const ClientY = 'event.clientY';
1496
- const DataTransferFiles2 = 'event.dataTransfer.files2';
1497
- const EventTargetClassName = 'event.target.className';
1498
- const TargetName = 'event.target.name';
1499
-
1500
- const Tab = 13;
1501
- const Main$1 = 24;
1502
-
1503
- const Separator = 1;
1504
- const None$1 = 0;
1505
-
1506
- const Add$1 = 6;
1507
- const NavigateChild$1 = 7;
1508
- const NavigateParent$1 = 8;
1509
-
1510
- const Electron = 2;
1511
-
1512
- const ClipBoardWorker = 3400;
1513
- const DialogWorker = 7014;
1514
- const DragAndDropWorker = 3404;
1515
- const IconThemeWorker = 7009;
1516
- const RendererProcess = 1670;
1517
- const RendererWorker = 1;
1518
-
1519
- const SetCss = 'Viewlet.setCss';
1520
- const SetDom2 = 'Viewlet.setDom2';
1521
- const SetPatches = 'Viewlet.setPatches';
1522
-
1523
- const FocusEditorText = 12;
1524
-
1525
- const {
1526
- invoke: invoke$6,
1527
- set: set$7
1528
- } = create$4(ClipBoardWorker);
1529
- const writeText = async text => {
1530
- return invoke$6('ClipBoard.writeText', text);
1531
- };
1532
-
1533
- const {
1534
- invoke: invoke$5,
1535
- set: set$6
1536
- } = create$4(DialogWorker);
1537
-
1538
- const {
1539
- invoke: invoke$4,
1540
- set: set$5
1541
- } = create$4(DragAndDropWorker);
1542
- const getDroppedItems = async (itemIds, isElectron) => {
1543
- return invoke$4('DragAndDrop.getDroppedItems', itemIds, isElectron);
1544
- };
1545
-
1546
- const {
1547
- invoke: invoke$3,
1548
- set: set$4
1549
- } = create$4(IconThemeWorker);
1550
- const getIcons = async iconRequests => {
1551
- // @ts-ignore
1552
- return invoke$3('IconTheme.getIcons', iconRequests);
1553
- };
1554
-
1555
- const {
1556
- invoke: invoke$2,
1557
- set: set$3
1558
- } = create$4(RendererProcess);
1559
-
1560
- const {
1561
- invoke: invoke$1,
1562
- invokeAndTransfer,
1563
- set: set$2
1564
- } = create$4(RendererWorker);
1565
- const handleModifiedStatusChange$1 = async (uri, modified) => {
1566
- return invoke$1('Main.handleModifiedStatusChange', uri, modified);
1567
- };
1568
- const showContextMenu2 = async (uid, menuId, x, y, args) => {
1569
- number(uid);
1570
- number(menuId);
1571
- number(x);
1572
- number(y);
1573
- await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1574
- };
1575
- const sendMessagePortToClipBoardWorker$1 = async (port, rpcId) => {
1576
- const command = 'ClipBoard.handleMessagePort';
1577
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
1578
- };
1579
- const sendMessagePortToDragAndDropWorker = async port => {
1580
- const command = 'DragAndDrop.handleMessagePort';
1581
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDragAndDropWorker', port, command);
1582
- };
1583
- const sendMessagePortToDialogWorker = async port => {
1584
- const command = 'HandleMessagePort.handleMessagePort';
1585
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1586
- };
1587
- const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1588
- const command = 'IconTheme.handleMessagePort';
1589
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1590
- };
1591
- const readFile = async uri => {
1592
- return invoke$1('FileSystem.readFile', uri);
1593
- };
1594
- const confirm$1 = async (message, options) => {
1595
- const result = await invoke$1('ConfirmPrompt.prompt', message, options);
1596
- return result;
1597
- };
1598
-
1599
1212
  const toCommandId = key => {
1600
1213
  const dotIndex = key.indexOf('.');
1601
1214
  return key.slice(dotIndex + 1);
1602
1215
  };
1603
- const create$3 = () => {
1216
+ const create$4 = () => {
1604
1217
  const commandQueues = new Map();
1605
1218
  const generations = Object.create(null);
1606
1219
  const states = Object.create(null);
@@ -1838,8 +1451,340 @@ const create$3 = () => {
1838
1451
  }
1839
1452
  };
1840
1453
  };
1841
- const terminate = () => {
1842
- globalThis.close();
1454
+ const terminate = () => {
1455
+ globalThis.close();
1456
+ };
1457
+
1458
+ const rpcs = Object.create(null);
1459
+ const set$8 = (id, rpc) => {
1460
+ rpcs[id] = rpc;
1461
+ };
1462
+ const get$1 = id => {
1463
+ return rpcs[id];
1464
+ };
1465
+ const remove = id => {
1466
+ delete rpcs[id];
1467
+ };
1468
+
1469
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1470
+ const create$3 = rpcId => {
1471
+ return {
1472
+ async dispose() {
1473
+ const rpc = get$1(rpcId);
1474
+ await rpc.dispose();
1475
+ },
1476
+ // @ts-ignore
1477
+ invoke(method, ...params) {
1478
+ const rpc = get$1(rpcId);
1479
+ // @ts-ignore
1480
+ return rpc.invoke(method, ...params);
1481
+ },
1482
+ // @ts-ignore
1483
+ invokeAndTransfer(method, ...params) {
1484
+ const rpc = get$1(rpcId);
1485
+ // @ts-ignore
1486
+ return rpc.invokeAndTransfer(method, ...params);
1487
+ },
1488
+ registerMockRpc(commandMap) {
1489
+ const mockRpc = createMockRpc({
1490
+ commandMap
1491
+ });
1492
+ set$8(rpcId, mockRpc);
1493
+ // @ts-ignore
1494
+ mockRpc[Symbol.dispose] = () => {
1495
+ remove(rpcId);
1496
+ };
1497
+ // @ts-ignore
1498
+ return mockRpc;
1499
+ },
1500
+ set(rpc) {
1501
+ set$8(rpcId, rpc);
1502
+ }
1503
+ };
1504
+ };
1505
+
1506
+ const None$2 = 'none';
1507
+ const Tab$1 = 'tab';
1508
+ const TabList = 'tablist';
1509
+ const ToolBar = 'toolbar';
1510
+
1511
+ const Audio = 0;
1512
+ const Button$2 = 1;
1513
+ const Col = 2;
1514
+ const ColGroup = 3;
1515
+ const Div = 4;
1516
+ const H1 = 5;
1517
+ const Input = 6;
1518
+ const Kbd = 7;
1519
+ const Span = 8;
1520
+ const Table = 9;
1521
+ const TBody = 10;
1522
+ const Td = 11;
1523
+ const Text = 12;
1524
+ const Th = 13;
1525
+ const THead = 14;
1526
+ const Tr = 15;
1527
+ const I = 16;
1528
+ const Img = 17;
1529
+ const Root = 0;
1530
+ const Ins = 20;
1531
+ const Del = 21;
1532
+ const H2 = 22;
1533
+ const H3 = 23;
1534
+ const H4 = 24;
1535
+ const H5 = 25;
1536
+ const H6 = 26;
1537
+ const Article = 27;
1538
+ const Aside = 28;
1539
+ const Footer = 29;
1540
+ const Header = 30;
1541
+ const Nav = 40;
1542
+ const Section = 41;
1543
+ const Search = 42;
1544
+ const Dd = 43;
1545
+ const Dl = 44;
1546
+ const Figcaption = 45;
1547
+ const Figure = 46;
1548
+ const Hr = 47;
1549
+ const Li = 48;
1550
+ const Ol = 49;
1551
+ const P = 50;
1552
+ const Pre = 51;
1553
+ const A = 53;
1554
+ const Abbr = 54;
1555
+ const Br = 55;
1556
+ const Cite = 56;
1557
+ const Data = 57;
1558
+ const Time = 58;
1559
+ const Tfoot = 59;
1560
+ const Ul = 60;
1561
+ const Video = 61;
1562
+ const TextArea = 62;
1563
+ const Select = 63;
1564
+ const Option = 64;
1565
+ const Code = 65;
1566
+ const Label = 66;
1567
+ const Dt = 67;
1568
+ const Iframe = 68;
1569
+ const Main$2 = 69;
1570
+ const Strong = 70;
1571
+ const Em = 71;
1572
+ const Style = 72;
1573
+ const Html = 73;
1574
+ const Head = 74;
1575
+ const Title = 75;
1576
+ const Meta = 76;
1577
+ const Canvas = 77;
1578
+ const Form = 78;
1579
+ const BlockQuote = 79;
1580
+ const Quote = 80;
1581
+ const Circle = 81;
1582
+ const Defs = 82;
1583
+ const Ellipse = 83;
1584
+ const G = 84;
1585
+ const Line = 85;
1586
+ const Path = 86;
1587
+ const Polygon = 87;
1588
+ const Polyline = 88;
1589
+ const Rect = 89;
1590
+ const Svg = 90;
1591
+ const Use = 91;
1592
+ const Reference = 100;
1593
+
1594
+ const VirtualDomElements = {
1595
+ __proto__: null,
1596
+ A,
1597
+ Abbr,
1598
+ Article,
1599
+ Aside,
1600
+ Audio,
1601
+ BlockQuote,
1602
+ Br,
1603
+ Button: Button$2,
1604
+ Canvas,
1605
+ Circle,
1606
+ Cite,
1607
+ Code,
1608
+ Col,
1609
+ ColGroup,
1610
+ Data,
1611
+ Dd,
1612
+ Defs,
1613
+ Del,
1614
+ Div,
1615
+ Dl,
1616
+ Dt,
1617
+ Ellipse,
1618
+ Em,
1619
+ Figcaption,
1620
+ Figure,
1621
+ Footer,
1622
+ Form,
1623
+ G,
1624
+ H1,
1625
+ H2,
1626
+ H3,
1627
+ H4,
1628
+ H5,
1629
+ H6,
1630
+ Head,
1631
+ Header,
1632
+ Hr,
1633
+ Html,
1634
+ I,
1635
+ Iframe,
1636
+ Img,
1637
+ Input,
1638
+ Ins,
1639
+ Kbd,
1640
+ Label,
1641
+ Li,
1642
+ Line,
1643
+ Main: Main$2,
1644
+ Meta,
1645
+ Nav,
1646
+ Ol,
1647
+ Option,
1648
+ P,
1649
+ Path,
1650
+ Polygon,
1651
+ Polyline,
1652
+ Pre,
1653
+ Quote,
1654
+ Rect,
1655
+ Reference,
1656
+ Root,
1657
+ Search,
1658
+ Section,
1659
+ Select,
1660
+ Span,
1661
+ Strong,
1662
+ Style,
1663
+ Svg,
1664
+ TBody,
1665
+ THead,
1666
+ Table,
1667
+ Td,
1668
+ Text,
1669
+ TextArea,
1670
+ Tfoot,
1671
+ Th,
1672
+ Time,
1673
+ Title,
1674
+ Tr,
1675
+ Ul,
1676
+ Use,
1677
+ Video
1678
+ };
1679
+
1680
+ const Button$1 = 'event.button';
1681
+ const ClientX = 'event.clientX';
1682
+ const ClientY = 'event.clientY';
1683
+ const DropId = 'event.dropId';
1684
+ const EventTargetClassName = 'event.target.className';
1685
+ const TargetName = 'event.target.name';
1686
+
1687
+ const Tab = 13;
1688
+ const Main$1 = 24;
1689
+
1690
+ const Separator = 1;
1691
+ const None$1 = 0;
1692
+
1693
+ const Add$1 = 6;
1694
+ const NavigateChild$1 = 7;
1695
+ const NavigateParent$1 = 8;
1696
+
1697
+ const Electron = 2;
1698
+
1699
+ const ClipBoardWorker = 3400;
1700
+ const DialogWorker = 7014;
1701
+ const DragAndDropWorker = 3404;
1702
+ const IconThemeWorker = 7009;
1703
+ const RendererProcess = 1670;
1704
+ const RendererWorker = 1;
1705
+
1706
+ const SetCss = 'Viewlet.setCss';
1707
+ const SetDom2 = 'Viewlet.setDom2';
1708
+ const SetFocusContext = 'Viewlet.setFocusContext';
1709
+ const SetPatches = 'Viewlet.setPatches';
1710
+
1711
+ const FocusEditorText = 12;
1712
+
1713
+ const {
1714
+ invoke: invoke$6,
1715
+ set: set$7
1716
+ } = create$3(ClipBoardWorker);
1717
+ const writeText = async text => {
1718
+ return invoke$6('ClipBoard.writeText', text);
1719
+ };
1720
+
1721
+ const {
1722
+ invoke: invoke$5,
1723
+ set: set$6
1724
+ } = create$3(DialogWorker);
1725
+
1726
+ const {
1727
+ invoke: invoke$4,
1728
+ set: set$5
1729
+ } = create$3(DragAndDropWorker);
1730
+ const getDroppedItems = async (itemIds, isElectron) => {
1731
+ return invoke$4('DragAndDrop.getDroppedItems', itemIds, isElectron);
1732
+ };
1733
+ const getDroppedUrisByDropId = async (dropId, isElectron) => {
1734
+ return invoke$4('DragAndDrop.getDroppedUrisByDropId', dropId, isElectron);
1735
+ };
1736
+
1737
+ const {
1738
+ invoke: invoke$3,
1739
+ set: set$4
1740
+ } = create$3(IconThemeWorker);
1741
+ const getIcons = async iconRequests => {
1742
+ // @ts-ignore
1743
+ return invoke$3('IconTheme.getIcons', iconRequests);
1744
+ };
1745
+
1746
+ const {
1747
+ invoke: invoke$2,
1748
+ set: set$3
1749
+ } = create$3(RendererProcess);
1750
+
1751
+ const {
1752
+ invoke: invoke$1,
1753
+ invokeAndTransfer,
1754
+ set: set$2
1755
+ } = create$3(RendererWorker);
1756
+ const handleModifiedStatusChange$1 = async (uri, modified) => {
1757
+ return invoke$1('Main.handleModifiedStatusChange', uri, modified);
1758
+ };
1759
+ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1760
+ number(uid);
1761
+ number(menuId);
1762
+ number(x);
1763
+ number(y);
1764
+ await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1765
+ };
1766
+ const sendMessagePortToClipBoardWorker$1 = async (port, rpcId) => {
1767
+ const command = 'ClipBoard.handleMessagePort';
1768
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
1769
+ };
1770
+ const sendMessagePortToDragAndDropWorker = async port => {
1771
+ const command = 'DragAndDrop.handleMessagePort';
1772
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDragAndDropWorker', port, command);
1773
+ };
1774
+ const sendMessagePortToDialogWorker = async port => {
1775
+ const command = 'HandleMessagePort.handleMessagePort';
1776
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1777
+ };
1778
+ const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1779
+ const command = 'IconTheme.handleMessagePort';
1780
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1781
+ };
1782
+ const readFile = async uri => {
1783
+ return invoke$1('FileSystem.readFile', uri);
1784
+ };
1785
+ const confirm$1 = async (message, options) => {
1786
+ const result = await invoke$1('ConfirmPrompt.prompt', message, options);
1787
+ return result;
1843
1788
  };
1844
1789
 
1845
1790
  const addClosedTabs = (state, entries) => {
@@ -2075,7 +2020,7 @@ const withActiveEditorChangeAsync = fn => {
2075
2020
  };
2076
2021
  };
2077
2022
 
2078
- const registry = create$3();
2023
+ const registry = create$4();
2079
2024
  const {
2080
2025
  get,
2081
2026
  getCommandIds,
@@ -2429,15 +2374,15 @@ const saveEditor = async editorUid => {
2429
2374
  return invoke$1('Editor.save', editorUid);
2430
2375
  };
2431
2376
 
2432
- const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
2433
2377
  const confirm = async (message, options) => {
2434
2378
  try {
2435
- return await invoke$5('ConfirmPrompt.prompt', message, options);
2379
+ return await confirm$1(message, options);
2436
2380
  } catch (error) {
2437
- if (!String(error).includes(missingDialogWorkerRelay)) {
2381
+ const errorMessage = String(error);
2382
+ if (!errorMessage.includes('ConfirmPrompt.prompt') || !errorMessage.includes('not found')) {
2438
2383
  throw error;
2439
2384
  }
2440
- return confirm$1(message, options);
2385
+ return invoke$5('ConfirmPrompt.prompt', message, options);
2441
2386
  }
2442
2387
  };
2443
2388
  const promptSave = async title => {
@@ -2880,15 +2825,15 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
2880
2825
  set$1(uid, state, state);
2881
2826
  };
2882
2827
 
2883
- const isEqual$3 = (oldState, newState) => {
2828
+ const isEqual$2 = (oldState, newState) => {
2884
2829
  return false;
2885
2830
  };
2886
2831
 
2887
- const isEqual$2 = (oldState, newState) => {
2832
+ const isEqual$1 = (oldState, newState) => {
2888
2833
  return oldState.pointerDownGroupIndex === newState.pointerDownGroupIndex && oldState.pointerDownTabIndex === newState.pointerDownTabIndex;
2889
2834
  };
2890
2835
 
2891
- const isEqual$1 = (oldState, newState) => {
2836
+ const isEqual = (oldState, newState) => {
2892
2837
  return oldState.dragOverlay === newState.dragOverlay && oldState.layout === newState.layout;
2893
2838
  };
2894
2839
 
@@ -2901,7 +2846,7 @@ const RenderDragData = 13;
2901
2846
  const isPendingViewletUpdateEqual = (oldState, newState) => {
2902
2847
  return newState.pendingViewletUpdate === undefined;
2903
2848
  };
2904
- const modules = [isEqual$1, isEqual$3, isPendingViewletUpdateEqual, isEqual$2];
2849
+ const modules = [isEqual, isEqual$2, isPendingViewletUpdateEqual, isEqual$1];
2905
2850
  const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate, RenderDragData];
2906
2851
 
2907
2852
  const diff = (oldState, newState) => {
@@ -4877,6 +4822,60 @@ const handleDragLeave = state => {
4877
4822
  };
4878
4823
  };
4879
4824
 
4825
+ const getChildBounds = (bounds, direction, offset, size) => {
4826
+ if (direction === Horizontal) {
4827
+ return {
4828
+ height: bounds.height,
4829
+ width: bounds.width * size,
4830
+ x: bounds.x + bounds.width * offset,
4831
+ y: bounds.y
4832
+ };
4833
+ }
4834
+ return {
4835
+ height: bounds.height * size,
4836
+ width: bounds.width,
4837
+ x: bounds.x,
4838
+ y: bounds.y + bounds.height * offset
4839
+ };
4840
+ };
4841
+ const getEditorGroupBounds = (layout, width, height) => {
4842
+ const {
4843
+ direction,
4844
+ groups
4845
+ } = layout;
4846
+ const segments = getGroupSegments(groups, direction);
4847
+ const rootBounds = {
4848
+ height,
4849
+ width,
4850
+ x: 0,
4851
+ y: 0
4852
+ };
4853
+ const result = [];
4854
+ let segmentOffset = 0;
4855
+ for (const segment of segments) {
4856
+ const segmentSize = getSegmentSize(segment);
4857
+ const segmentBounds = getChildBounds(rootBounds, direction, segmentOffset / 100, segmentSize / 100);
4858
+ segmentOffset += segmentSize;
4859
+ if (segment.direction === undefined) {
4860
+ result.push({
4861
+ ...segmentBounds,
4862
+ group: segment.groups[0]
4863
+ });
4864
+ continue;
4865
+ }
4866
+ let groupOffset = 0;
4867
+ for (const group of segment.groups) {
4868
+ const groupBounds = getChildBounds(segmentBounds, segment.direction, groupOffset / segmentSize, group.size / segmentSize);
4869
+ groupOffset += group.size;
4870
+ result.push({
4871
+ ...groupBounds,
4872
+ group
4873
+ });
4874
+ }
4875
+ }
4876
+ return result;
4877
+ };
4878
+
4880
4879
  const None = 0;
4881
4880
  const Up = 1;
4882
4881
  const Down = 2;
@@ -4951,6 +4950,12 @@ const getSplitDirection = (x, y, width, height) => {
4951
4950
  const isNotEmpty = group => {
4952
4951
  return !group.isEmpty;
4953
4952
  };
4953
+ const getContentOffsetY = (targetIsEmpty, hasOpenEditor, tabHeight) => {
4954
+ if (targetIsEmpty !== undefined) {
4955
+ return targetIsEmpty ? 0 : tabHeight;
4956
+ }
4957
+ return hasOpenEditor ? tabHeight : 0;
4958
+ };
4954
4959
  const getDragOverlay = (state, eventX, eventY) => {
4955
4960
  const {
4956
4961
  height,
@@ -4963,24 +4968,41 @@ const getDragOverlay = (state, eventX, eventY) => {
4963
4968
  const {
4964
4969
  groups
4965
4970
  } = layout;
4971
+ const relativeEventX = Math.min(Math.max(eventX - x, 0), width);
4972
+ const relativeEventY = Math.min(Math.max(eventY - y, 0), height);
4973
+ const groupBounds = getEditorGroupBounds(layout, width, height);
4974
+ const target = groupBounds.find(bounds => {
4975
+ return relativeEventX >= bounds.x && relativeEventX <= bounds.x + bounds.width && relativeEventY >= bounds.y && relativeEventY <= bounds.y + bounds.height;
4976
+ });
4966
4977
  const hasOpenEditor = groups.some(isNotEmpty);
4967
- const contentY = hasOpenEditor ? tabHeight : 0;
4968
- const contentHeight = Math.max(0, height - contentY);
4969
- const relativeX = eventX - x;
4970
- const relativeY = eventY - y - contentY;
4971
- const splitDirection = getSplitDirection(relativeX, relativeY, width, contentHeight);
4972
- return getOverlay(0, contentY, width, contentHeight, splitDirection);
4978
+ const targetX = target?.x ?? 0;
4979
+ const targetY = target?.y ?? 0;
4980
+ const targetWidth = target?.width ?? width;
4981
+ const targetHeight = target?.height ?? height;
4982
+ const contentOffsetY = getContentOffsetY(target?.group.isEmpty, hasOpenEditor, tabHeight);
4983
+ const contentY = targetY + contentOffsetY;
4984
+ const contentHeight = Math.max(0, targetHeight - contentOffsetY);
4985
+ const relativeX = relativeEventX - targetX;
4986
+ const relativeY = relativeEventY - contentY;
4987
+ const splitDirection = getSplitDirection(relativeX, relativeY, targetWidth, contentHeight);
4988
+ return {
4989
+ ...getOverlay(targetX, contentY, targetWidth, contentHeight, splitDirection),
4990
+ ...(target && {
4991
+ targetGroupId: target.group.id
4992
+ })
4993
+ };
4973
4994
  };
4974
4995
 
4975
- const isEqual = (oldOverlay, newOverlay) => {
4976
- return oldOverlay?.x === newOverlay?.x && oldOverlay?.y === newOverlay?.y && oldOverlay?.width === newOverlay?.width && oldOverlay?.height === newOverlay?.height && oldOverlay?.splitDirection === newOverlay?.splitDirection;
4996
+ const isDragOverlayEqual = (oldOverlay, newOverlay) => {
4997
+ return oldOverlay?.x === newOverlay?.x && oldOverlay?.y === newOverlay?.y && oldOverlay?.width === newOverlay?.width && oldOverlay?.height === newOverlay?.height && oldOverlay?.splitDirection === newOverlay?.splitDirection && oldOverlay?.targetGroupId === newOverlay?.targetGroupId;
4977
4998
  };
4999
+
4978
5000
  const handleDragOver = (state, eventX, eventY) => {
4979
5001
  const {
4980
5002
  dragOverlay: oldDragOverlay
4981
5003
  } = state;
4982
5004
  const dragOverlay = getDragOverlay(state, eventX, eventY);
4983
- if (isEqual(oldDragOverlay, dragOverlay)) {
5005
+ if (isDragOverlayEqual(oldDragOverlay, dragOverlay)) {
4984
5006
  return state;
4985
5007
  }
4986
5008
  return {
@@ -5149,27 +5171,29 @@ const splitUp$1 = (state, groupId) => {
5149
5171
  return splitEditorGroup$1(state, resolvedGroupId, 'up');
5150
5172
  };
5151
5173
 
5152
- const splitForDrop = (state, splitDirection) => {
5174
+ const splitForDrop = (state, splitDirection, targetGroupId) => {
5153
5175
  switch (splitDirection) {
5154
5176
  case Down:
5155
- return splitDown$1(state);
5177
+ return splitDown$1(state, targetGroupId);
5156
5178
  case Left:
5157
- return splitLeft$1(state);
5179
+ return splitLeft$1(state, targetGroupId);
5158
5180
  case Right:
5159
- return splitRight$1(state);
5181
+ return splitRight$1(state, targetGroupId);
5160
5182
  case Up:
5161
- return splitUp$1(state);
5183
+ return splitUp$1(state, targetGroupId);
5162
5184
  default:
5163
5185
  return state;
5164
5186
  }
5165
5187
  };
5166
5188
 
5167
- const applyDropAction = async (context, action, splitDirection) => {
5189
+ const applyDropAction = async (context, action, splitDirection, targetGroupId) => {
5168
5190
  switch (action.command) {
5169
5191
  case 'openFiles':
5170
5192
  {
5171
5193
  if (action.uris.length > 0 && splitDirection !== None) {
5172
- await context.updateState(state => splitForDrop(state, splitDirection));
5194
+ await context.updateState(state => splitForDrop(state, splitDirection, targetGroupId));
5195
+ } else if (action.uris.length > 0 && targetGroupId !== undefined) {
5196
+ await context.updateState(state => focusEditorGroup(state, targetGroupId));
5173
5197
  }
5174
5198
  await openUrisWithContext(context, action.uris, splitDirection === None);
5175
5199
  break;
@@ -5207,18 +5231,27 @@ const getDropAction = async uris => {
5207
5231
  };
5208
5232
  };
5209
5233
 
5210
- const handleDrop = async (context, itemIds) => {
5211
- const splitDirection = context.getState().dragOverlay?.splitDirection ?? None;
5234
+ const handleDrop = async (context, dropIdOrItemIds) => {
5235
+ const {
5236
+ splitDirection = None,
5237
+ targetGroupId
5238
+ } = context.getState().dragOverlay ?? {};
5212
5239
  await context.updateState(handleDragLeave);
5213
5240
  const {
5214
5241
  platform
5215
5242
  } = context.getState();
5216
5243
  const isElectron = platform === Electron;
5217
- const {
5218
- uris
5219
- } = await getDroppedItems(itemIds, isElectron);
5244
+ let uris;
5245
+ if (typeof dropIdOrItemIds === 'number') {
5246
+ uris = await getDroppedUrisByDropId(dropIdOrItemIds, isElectron);
5247
+ } else {
5248
+ const {
5249
+ uris: droppedUris
5250
+ } = await getDroppedItems(dropIdOrItemIds, isElectron);
5251
+ uris = droppedUris;
5252
+ }
5220
5253
  const actions = await getDropAction(uris);
5221
- await applyDropAction(context, actions, splitDirection);
5254
+ await applyDropAction(context, actions, splitDirection, targetGroupId);
5222
5255
  };
5223
5256
 
5224
5257
  const EditorGroupHeader = 'EditorGroupHeader';
@@ -5440,7 +5473,7 @@ const handleIconThemeChange = async state => {
5440
5473
  };
5441
5474
  };
5442
5475
 
5443
- const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
5476
+ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcessFallback = true) => {
5444
5477
  const executeViewletCommand = async (uid, command, ...args) => {
5445
5478
  const fn = viewletCommandMap[`MainArea.${command}`];
5446
5479
  if (typeof fn !== 'function') {
@@ -5455,7 +5488,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
5455
5488
  },
5456
5489
  messagePort: port
5457
5490
  });
5458
- if (setAsRendererProcess) {
5491
+ if (setAsRendererProcessFallback) {
5459
5492
  set(rpc);
5460
5493
  }
5461
5494
  };
@@ -6265,7 +6298,7 @@ const hasActiveTextEditor = state => {
6265
6298
  return activeTab?.tab.editorInput?.type === 'editor';
6266
6299
  };
6267
6300
 
6268
- const initialize = async () => {
6301
+ const initialize$1 = async () => {
6269
6302
  // Kept as a compatibility command for existing renderer startup code.
6270
6303
  };
6271
6304
 
@@ -7775,8 +7808,10 @@ const render2 = (uid, diffResult) => {
7775
7808
  return renderDirect(uid, commands);
7776
7809
  };
7777
7810
  const renderDirect = async (uid, commands) => {
7778
- const transactionId = await invoke('Viewlet.queueCommands', uid, commands);
7779
- return [['Viewlet.commitPending', uid, transactionId]];
7811
+ const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
7812
+ const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
7813
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
7814
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
7780
7815
  };
7781
7816
 
7782
7817
  const renderEventListeners = () => {
@@ -7837,7 +7872,7 @@ const renderEventListeners = () => {
7837
7872
  params: ['handleDragLeave']
7838
7873
  }, {
7839
7874
  name: HandleDrop,
7840
- params: ['handleDrop', DataTransferFiles2],
7875
+ params: ['handleDrop', DropId],
7841
7876
  preventDefault: true
7842
7877
  }, {
7843
7878
  dragEffect: 'copyMove',
@@ -8317,7 +8352,7 @@ const resize = async (uid, dimensions) => {
8317
8352
  set$1(uid, instance.oldState, resizedState);
8318
8353
  return handleResize(resizedState, dimensions);
8319
8354
  };
8320
- const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
8355
+ const handleDirectMessagePort = (port, setAsRendererProcessFallback = true) => handleMessagePort(port, commandMap, setAsRendererProcessFallback);
8321
8356
  const handleTestWorkerMessagePort = port => handleMessagePort(port, commandMap, false);
8322
8357
  const commandMap = {
8323
8358
  'Main.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
@@ -8399,7 +8434,7 @@ const commandMap = {
8399
8434
  'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
8400
8435
  'MainArea.handleWorkspaceRefresh': wrapAsyncCommand(handleWorkspaceRefreshWithContext),
8401
8436
  'MainArea.hasActiveTextEditor': wrapGetter(hasActiveTextEditor),
8402
- 'MainArea.initialize': initialize,
8437
+ 'MainArea.initialize': initialize$1,
8403
8438
  'MainArea.loadContent': loadContentTracked,
8404
8439
  'MainArea.moveIntoNewWindow': wrapSerialCommand(moveIntoNewWindow),
8405
8440
  'MainArea.newFile': wrapSerialCommand(newFile),
@@ -8491,16 +8526,17 @@ const initializeIconThemeWorker = async () => {
8491
8526
  await refreshFileIcons();
8492
8527
  };
8493
8528
 
8494
- const initializeRendererWorker = async () => {
8495
- const rpc = await create$5({
8496
- commandMap: commandMap
8529
+ const initializeRendererWorker = async port => {
8530
+ const rpc = await create$8({
8531
+ commandMap: commandMap,
8532
+ messagePort: port
8497
8533
  });
8498
8534
  set$2(rpc);
8499
8535
  };
8500
8536
 
8501
- const listen = async () => {
8537
+ const listen = async port => {
8502
8538
  registerCommands(commandMap);
8503
- await Promise.all([initializeRendererWorker(), initializeIconThemeWorker(), initializeClipBoardWorker(), initializeDragAndDropWorker()]);
8539
+ await Promise.all([initializeRendererWorker(port), initializeIconThemeWorker(), initializeClipBoardWorker(), initializeDragAndDropWorker()]);
8504
8540
  const dialogRpc = await create$6({
8505
8541
  commandMap: {},
8506
8542
  send: sendMessagePortToDialogWorker
@@ -8508,17 +8544,22 @@ const listen = async () => {
8508
8544
  set$6(dialogRpc);
8509
8545
  };
8510
8546
 
8511
- const main$1 = async () => {
8512
- await listen();
8547
+ const main$1 = async port => {
8548
+ await listen(port);
8513
8549
  };
8514
8550
 
8551
+ const initialize = async (_type, port) => {
8552
+ await main$1(port);
8553
+ };
8515
8554
  const main = async () => {
8516
8555
  registerCommands(commandMap);
8517
8556
  const rpc = await create$5({
8518
- commandMap: commandMap
8557
+ commandMap: {
8558
+ ...commandMap,
8559
+ initialize
8560
+ }
8519
8561
  });
8520
- set$2(rpc);
8562
+ set(rpc);
8521
8563
  };
8522
8564
 
8523
- await main$1();
8524
8565
  await main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.49.0",
3
+ "version": "9.50.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",