@lvce-editor/main-area-worker 9.48.0 → 9.50.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.
@@ -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) => {
@@ -4823,6 +4768,7 @@ const show2 = async (uid, menuId, x, y, args) => {
4823
4768
  };
4824
4769
 
4825
4770
  const NoGroupId = -1;
4771
+ const RendererWorkerForwardDelay$1 = 50;
4826
4772
  const handleContextMenu = async (state, rawGroupId, x, y) => {
4827
4773
  const {
4828
4774
  uid
@@ -4836,6 +4782,15 @@ const handleContextMenu = async (state, rawGroupId, x, y) => {
4836
4782
  if (Number.isNaN(groupId)) {
4837
4783
  return state;
4838
4784
  }
4785
+ if (isConnected()) {
4786
+ setTimeout(() => {
4787
+ void show2(uid, Main$1, x, y, {
4788
+ groupId,
4789
+ menuId: Main$1
4790
+ });
4791
+ }, RendererWorkerForwardDelay$1);
4792
+ return state;
4793
+ }
4839
4794
  await show2(uid, Main$1, x, y, {
4840
4795
  groupId,
4841
4796
  menuId: Main$1
@@ -4972,15 +4927,16 @@ const getDragOverlay = (state, eventX, eventY) => {
4972
4927
  return getOverlay(0, contentY, width, contentHeight, splitDirection);
4973
4928
  };
4974
4929
 
4975
- const isEqual = (oldOverlay, newOverlay) => {
4930
+ const isDragOverlayEqual = (oldOverlay, newOverlay) => {
4976
4931
  return oldOverlay?.x === newOverlay?.x && oldOverlay?.y === newOverlay?.y && oldOverlay?.width === newOverlay?.width && oldOverlay?.height === newOverlay?.height && oldOverlay?.splitDirection === newOverlay?.splitDirection;
4977
4932
  };
4933
+
4978
4934
  const handleDragOver = (state, eventX, eventY) => {
4979
4935
  const {
4980
4936
  dragOverlay: oldDragOverlay
4981
4937
  } = state;
4982
4938
  const dragOverlay = getDragOverlay(state, eventX, eventY);
4983
- if (isEqual(oldDragOverlay, dragOverlay)) {
4939
+ if (isDragOverlayEqual(oldDragOverlay, dragOverlay)) {
4984
4940
  return state;
4985
4941
  }
4986
4942
  return {
@@ -5207,16 +5163,22 @@ const getDropAction = async uris => {
5207
5163
  };
5208
5164
  };
5209
5165
 
5210
- const handleDrop = async (context, itemIds) => {
5166
+ const handleDrop = async (context, dropIdOrItemIds) => {
5211
5167
  const splitDirection = context.getState().dragOverlay?.splitDirection ?? None;
5212
5168
  await context.updateState(handleDragLeave);
5213
5169
  const {
5214
5170
  platform
5215
5171
  } = context.getState();
5216
5172
  const isElectron = platform === Electron;
5217
- const {
5218
- uris
5219
- } = await getDroppedItems(itemIds, isElectron);
5173
+ let uris;
5174
+ if (typeof dropIdOrItemIds === 'number') {
5175
+ uris = await getDroppedUrisByDropId(dropIdOrItemIds, isElectron);
5176
+ } else {
5177
+ const {
5178
+ uris: droppedUris
5179
+ } = await getDroppedItems(dropIdOrItemIds, isElectron);
5180
+ uris = droppedUris;
5181
+ }
5220
5182
  const actions = await getDropAction(uris);
5221
5183
  await applyDropAction(context, actions, splitDirection);
5222
5184
  };
@@ -5440,13 +5402,21 @@ const handleIconThemeChange = async state => {
5440
5402
  };
5441
5403
  };
5442
5404
 
5443
- const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
5405
+ const RendererWorkerCallbackDelay = 50;
5406
+ const commandsWithDeferredRender = new Set(['handleContextMenu', 'handleTabContextMenu']);
5407
+ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcessFallback = true) => {
5444
5408
  const executeViewletCommand = async (uid, command, ...args) => {
5445
5409
  const fn = viewletCommandMap[`MainArea.${command}`];
5446
5410
  if (typeof fn !== 'function') {
5447
5411
  throw new TypeError(`Viewlet command not found: ${command}`);
5448
5412
  }
5449
5413
  await fn(uid, ...args);
5414
+ if (commandsWithDeferredRender.has(command)) {
5415
+ setTimeout(() => {
5416
+ void invoke$1('Viewlet.requestRender', uid);
5417
+ }, RendererWorkerCallbackDelay);
5418
+ return;
5419
+ }
5450
5420
  await invoke$1('Viewlet.requestRender', uid);
5451
5421
  };
5452
5422
  const rpc = await create$8({
@@ -5455,7 +5425,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
5455
5425
  },
5456
5426
  messagePort: port
5457
5427
  });
5458
- if (setAsRendererProcess) {
5428
+ if (setAsRendererProcessFallback) {
5459
5429
  set(rpc);
5460
5430
  }
5461
5431
  };
@@ -5831,6 +5801,7 @@ const handleSashPointerUp = async state => {
5831
5801
  };
5832
5802
  };
5833
5803
 
5804
+ const RendererWorkerForwardDelay = 50;
5834
5805
  const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tabIndexRaw = '') => {
5835
5806
  number(x);
5836
5807
  number(y);
@@ -5845,6 +5816,15 @@ const handleTabContextMenu = async (state, button, x, y, groupIndexRaw = '', tab
5845
5816
  groupId: group.id,
5846
5817
  tabId: tab.id
5847
5818
  } : {};
5819
+ if (isConnected()) {
5820
+ setTimeout(() => {
5821
+ void show2(uid, Tab, x, y, {
5822
+ menuId: Tab,
5823
+ ...target
5824
+ });
5825
+ }, RendererWorkerForwardDelay);
5826
+ return state;
5827
+ }
5848
5828
  await show2(uid, Tab, x, y, {
5849
5829
  menuId: Tab,
5850
5830
  ...target
@@ -6265,7 +6245,7 @@ const hasActiveTextEditor = state => {
6265
6245
  return activeTab?.tab.editorInput?.type === 'editor';
6266
6246
  };
6267
6247
 
6268
- const initialize = async () => {
6248
+ const initialize$1 = async () => {
6269
6249
  // Kept as a compatibility command for existing renderer startup code.
6270
6250
  };
6271
6251
 
@@ -7775,8 +7755,10 @@ const render2 = (uid, diffResult) => {
7775
7755
  return renderDirect(uid, commands);
7776
7756
  };
7777
7757
  const renderDirect = async (uid, commands) => {
7778
- const transactionId = await invoke('Viewlet.queueCommands', uid, commands);
7779
- return [['Viewlet.commitPending', uid, transactionId]];
7758
+ const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
7759
+ const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
7760
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
7761
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
7780
7762
  };
7781
7763
 
7782
7764
  const renderEventListeners = () => {
@@ -7837,7 +7819,7 @@ const renderEventListeners = () => {
7837
7819
  params: ['handleDragLeave']
7838
7820
  }, {
7839
7821
  name: HandleDrop,
7840
- params: ['handleDrop', DataTransferFiles2],
7822
+ params: ['handleDrop', DropId],
7841
7823
  preventDefault: true
7842
7824
  }, {
7843
7825
  dragEffect: 'copyMove',
@@ -8317,7 +8299,7 @@ const resize = async (uid, dimensions) => {
8317
8299
  set$1(uid, instance.oldState, resizedState);
8318
8300
  return handleResize(resizedState, dimensions);
8319
8301
  };
8320
- const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
8302
+ const handleDirectMessagePort = (port, setAsRendererProcessFallback = true) => handleMessagePort(port, commandMap, setAsRendererProcessFallback);
8321
8303
  const handleTestWorkerMessagePort = port => handleMessagePort(port, commandMap, false);
8322
8304
  const commandMap = {
8323
8305
  'Main.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
@@ -8399,7 +8381,7 @@ const commandMap = {
8399
8381
  'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
8400
8382
  'MainArea.handleWorkspaceRefresh': wrapAsyncCommand(handleWorkspaceRefreshWithContext),
8401
8383
  'MainArea.hasActiveTextEditor': wrapGetter(hasActiveTextEditor),
8402
- 'MainArea.initialize': initialize,
8384
+ 'MainArea.initialize': initialize$1,
8403
8385
  'MainArea.loadContent': loadContentTracked,
8404
8386
  'MainArea.moveIntoNewWindow': wrapSerialCommand(moveIntoNewWindow),
8405
8387
  'MainArea.newFile': wrapSerialCommand(newFile),
@@ -8491,16 +8473,17 @@ const initializeIconThemeWorker = async () => {
8491
8473
  await refreshFileIcons();
8492
8474
  };
8493
8475
 
8494
- const initializeRendererWorker = async () => {
8495
- const rpc = await create$5({
8496
- commandMap: commandMap
8476
+ const initializeRendererWorker = async port => {
8477
+ const rpc = await create$8({
8478
+ commandMap: commandMap,
8479
+ messagePort: port
8497
8480
  });
8498
8481
  set$2(rpc);
8499
8482
  };
8500
8483
 
8501
- const listen = async () => {
8484
+ const listen = async port => {
8502
8485
  registerCommands(commandMap);
8503
- await Promise.all([initializeRendererWorker(), initializeIconThemeWorker(), initializeClipBoardWorker(), initializeDragAndDropWorker()]);
8486
+ await Promise.all([initializeRendererWorker(port), initializeIconThemeWorker(), initializeClipBoardWorker(), initializeDragAndDropWorker()]);
8504
8487
  const dialogRpc = await create$6({
8505
8488
  commandMap: {},
8506
8489
  send: sendMessagePortToDialogWorker
@@ -8508,17 +8491,22 @@ const listen = async () => {
8508
8491
  set$6(dialogRpc);
8509
8492
  };
8510
8493
 
8511
- const main$1 = async () => {
8512
- await listen();
8494
+ const main$1 = async port => {
8495
+ await listen(port);
8513
8496
  };
8514
8497
 
8498
+ const initialize = async (_type, port) => {
8499
+ await main$1(port);
8500
+ };
8515
8501
  const main = async () => {
8516
8502
  registerCommands(commandMap);
8517
8503
  const rpc = await create$5({
8518
- commandMap: commandMap
8504
+ commandMap: {
8505
+ ...commandMap,
8506
+ initialize
8507
+ }
8519
8508
  });
8520
- set$2(rpc);
8509
+ set(rpc);
8521
8510
  };
8522
8511
 
8523
- await main$1();
8524
8512
  await main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.48.0",
3
+ "version": "9.50.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",