@lvce-editor/activity-bar-worker 1.3.0 → 1.4.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.
- package/dist/activityBarWorkerMain.js +91 -94
- package/package.json +1 -1
|
@@ -969,6 +969,49 @@ const create$1 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
969
969
|
return state;
|
|
970
970
|
};
|
|
971
971
|
|
|
972
|
+
const isEqual$2 = (oldState, newState) => {
|
|
973
|
+
// TODO compute css more optimized
|
|
974
|
+
// maybe only when items change, and even then not
|
|
975
|
+
// always, but only when it affects the css
|
|
976
|
+
return false;
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
const isEqual$1 = (oldState, newState) => {
|
|
980
|
+
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
const isEqual = (oldState, newState) => {
|
|
984
|
+
return oldState.focusedIndex === newState.focusedIndex;
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
const RenderItems = 4;
|
|
988
|
+
const RenderFocus = 6;
|
|
989
|
+
const RenderFocusContext = 7;
|
|
990
|
+
const RenderCss = 11;
|
|
991
|
+
|
|
992
|
+
const modules = [isEqual, isEqual$1, isEqual$1, isEqual$2];
|
|
993
|
+
const numbers = [RenderItems, RenderFocus, RenderFocusContext, RenderCss];
|
|
994
|
+
|
|
995
|
+
const diff = (oldState, newState) => {
|
|
996
|
+
const diffResult = [];
|
|
997
|
+
for (let i = 0; i < modules.length; i++) {
|
|
998
|
+
const fn = modules[i];
|
|
999
|
+
if (!fn(oldState, newState)) {
|
|
1000
|
+
diffResult.push(numbers[i]);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
return diffResult;
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
const diff2 = uid => {
|
|
1007
|
+
const {
|
|
1008
|
+
oldState,
|
|
1009
|
+
newState
|
|
1010
|
+
} = get$1(uid);
|
|
1011
|
+
const result = diff(oldState, newState);
|
|
1012
|
+
return result;
|
|
1013
|
+
};
|
|
1014
|
+
|
|
972
1015
|
const List = 1;
|
|
973
1016
|
|
|
974
1017
|
const focus = state => {
|
|
@@ -1011,14 +1054,6 @@ const focusNone = state => {
|
|
|
1011
1054
|
return focusIndex(state, -1);
|
|
1012
1055
|
};
|
|
1013
1056
|
|
|
1014
|
-
const Button = 'event.button';
|
|
1015
|
-
const ClientX = 'event.clientX';
|
|
1016
|
-
const ClientY = 'event.clientY';
|
|
1017
|
-
const CtrlKey = 'event.ctrlKey';
|
|
1018
|
-
const DeltaMode = 'event.deltaMode';
|
|
1019
|
-
const DeltaY = 'event.deltaY';
|
|
1020
|
-
const TargetValue = 'event.target.value';
|
|
1021
|
-
|
|
1022
1057
|
const Enter = 3;
|
|
1023
1058
|
const Space = 9;
|
|
1024
1059
|
const PageUp = 10;
|
|
@@ -1033,7 +1068,11 @@ const LeftClick = 0;
|
|
|
1033
1068
|
const DebugWorker = 55;
|
|
1034
1069
|
const RendererWorker$1 = 1;
|
|
1035
1070
|
|
|
1071
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
1072
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1073
|
+
|
|
1036
1074
|
const FocusActivityBar = 5;
|
|
1075
|
+
const FocusExplorer = 13;
|
|
1037
1076
|
|
|
1038
1077
|
const getKeyBindings$1 = () => {
|
|
1039
1078
|
return [{
|
|
@@ -1521,6 +1560,10 @@ const handleClick = async (state, button, index, x, y) => {
|
|
|
1521
1560
|
}
|
|
1522
1561
|
};
|
|
1523
1562
|
|
|
1563
|
+
const handleResize = state => {
|
|
1564
|
+
return state;
|
|
1565
|
+
};
|
|
1566
|
+
|
|
1524
1567
|
const findIndex = (activityBarItems, id) => {
|
|
1525
1568
|
for (let i = 0; i < activityBarItems.length; i++) {
|
|
1526
1569
|
if (activityBarItems[i].id === id) {
|
|
@@ -1544,100 +1587,52 @@ const loadContent = async (state, savedState) => {
|
|
|
1544
1587
|
};
|
|
1545
1588
|
};
|
|
1546
1589
|
|
|
1590
|
+
const renderFocusContext = (oldState, newState) => {
|
|
1591
|
+
if (newState.focus === List) {
|
|
1592
|
+
return [SetFocusContext, newState.uid, FocusExplorer];
|
|
1593
|
+
}
|
|
1594
|
+
return [];
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
const renderItems = (oldState, newState) => {
|
|
1598
|
+
return [SetDom2, []];
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
const getRenderer = diffType => {
|
|
1602
|
+
switch (diffType) {
|
|
1603
|
+
case RenderItems:
|
|
1604
|
+
return renderItems;
|
|
1605
|
+
case RenderFocusContext:
|
|
1606
|
+
return renderFocusContext;
|
|
1607
|
+
default:
|
|
1608
|
+
throw new Error('unknown renderer');
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1547
1612
|
const applyRender = (oldState, newState, diffResult) => {
|
|
1548
1613
|
const commands = [];
|
|
1614
|
+
for (const item of diffResult) {
|
|
1615
|
+
const fn = getRenderer(item);
|
|
1616
|
+
const result = fn(oldState, newState);
|
|
1617
|
+
if (result.length > 0) {
|
|
1618
|
+
commands.push(result);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1549
1621
|
return commands;
|
|
1550
1622
|
};
|
|
1551
1623
|
|
|
1552
1624
|
const render2 = (uid, diffResult) => {
|
|
1553
1625
|
const {
|
|
1626
|
+
oldState,
|
|
1554
1627
|
newState
|
|
1555
1628
|
} = get$1(uid);
|
|
1556
1629
|
set$3(uid, newState, newState);
|
|
1557
|
-
const commands = applyRender();
|
|
1630
|
+
const commands = applyRender(oldState, newState, diffResult);
|
|
1558
1631
|
return commands;
|
|
1559
1632
|
};
|
|
1560
1633
|
|
|
1561
|
-
const HandleClick = 1;
|
|
1562
|
-
const HandleClickOpenFolder = 2;
|
|
1563
|
-
const HandleContextMenu = 3;
|
|
1564
|
-
const HandleDragLeave = 4;
|
|
1565
|
-
const HandleDragOver = 5;
|
|
1566
|
-
const HandleDrop = 6;
|
|
1567
|
-
const HandleEditingInput = 7;
|
|
1568
|
-
const HandleInputBlur = 8;
|
|
1569
|
-
const HandleInputClick = 9;
|
|
1570
|
-
const HandleListBlur = 11;
|
|
1571
|
-
const HandleListFocus = 12;
|
|
1572
|
-
const HandlePointerDown = 14;
|
|
1573
|
-
const HandleWheel = 15;
|
|
1574
|
-
const HandleDragStart = 17;
|
|
1575
|
-
|
|
1576
1634
|
const renderEventListeners = () => {
|
|
1577
|
-
return [
|
|
1578
|
-
name: HandleInputBlur,
|
|
1579
|
-
params: ['handleInputBlur']
|
|
1580
|
-
},
|
|
1581
|
-
// {
|
|
1582
|
-
// name: DomEventListenersFunctions.HandleInputKeyDown,
|
|
1583
|
-
// params: ['handleInputKeyDown'],
|
|
1584
|
-
// stopPropagation: true, // TODO find a way to do this without stopPropagation
|
|
1585
|
-
// },
|
|
1586
|
-
// {
|
|
1587
|
-
// name: DomEventListenersFunctions.HandleListKeyDown,
|
|
1588
|
-
// params: ['handleKeyDown', 'event.key'],
|
|
1589
|
-
// preventDefault: true,
|
|
1590
|
-
// },
|
|
1591
|
-
{
|
|
1592
|
-
name: HandleListFocus,
|
|
1593
|
-
params: ['handleFocus', 'event.isTrusted', 'event.target.className']
|
|
1594
|
-
}, {
|
|
1595
|
-
name: HandleListBlur,
|
|
1596
|
-
params: ['handleBlur']
|
|
1597
|
-
}, {
|
|
1598
|
-
name: HandleClick,
|
|
1599
|
-
params: ['handleClickAt', 'event.defaultPrevented', Button, CtrlKey, 'event.shiftKey', ClientX, ClientY],
|
|
1600
|
-
preventDefault: true
|
|
1601
|
-
}, {
|
|
1602
|
-
name: HandleInputClick,
|
|
1603
|
-
params: ['handleInputClick'],
|
|
1604
|
-
preventDefault: true
|
|
1605
|
-
}, {
|
|
1606
|
-
name: HandleClickOpenFolder,
|
|
1607
|
-
params: ['handleClickOpenFolder'],
|
|
1608
|
-
preventDefault: true
|
|
1609
|
-
}, {
|
|
1610
|
-
name: HandlePointerDown,
|
|
1611
|
-
params: ['handlePointerDown', Button, ClientX, ClientY]
|
|
1612
|
-
// preventDefault: true,
|
|
1613
|
-
}, {
|
|
1614
|
-
name: HandleEditingInput,
|
|
1615
|
-
params: ['updateEditingValue', TargetValue]
|
|
1616
|
-
}, {
|
|
1617
|
-
name: HandleContextMenu,
|
|
1618
|
-
params: ['handleContextMenu', Button, ClientX, ClientY],
|
|
1619
|
-
preventDefault: true
|
|
1620
|
-
}, {
|
|
1621
|
-
name: HandleWheel,
|
|
1622
|
-
params: ['handleWheel', DeltaMode, DeltaY],
|
|
1623
|
-
passive: true
|
|
1624
|
-
}, {
|
|
1625
|
-
name: HandleDragOver,
|
|
1626
|
-
params: ['handleDragOver', ClientX, ClientY],
|
|
1627
|
-
preventDefault: true
|
|
1628
|
-
}, {
|
|
1629
|
-
name: HandleDrop,
|
|
1630
|
-
params: ['handleDrop', ClientX, ClientY, 'event.dataTransfer.files2', 'event.dataTransfer.files'],
|
|
1631
|
-
preventDefault: true
|
|
1632
|
-
}, {
|
|
1633
|
-
name: HandleDragLeave,
|
|
1634
|
-
params: ['handleDragLeave']
|
|
1635
|
-
}, {
|
|
1636
|
-
name: HandleDragStart,
|
|
1637
|
-
params: ['handleDragStart'],
|
|
1638
|
-
// @ts-ignore
|
|
1639
|
-
dragEffect: 'copyMove'
|
|
1640
|
-
}];
|
|
1635
|
+
return [];
|
|
1641
1636
|
};
|
|
1642
1637
|
|
|
1643
1638
|
const saveState = state => {
|
|
@@ -1650,23 +1645,25 @@ const saveState = state => {
|
|
|
1650
1645
|
};
|
|
1651
1646
|
|
|
1652
1647
|
const commandMap = {
|
|
1648
|
+
'ActivityBar.create': create$1,
|
|
1649
|
+
'ActivityBar.diff2': diff2,
|
|
1653
1650
|
'ActivityBar.focus': wrapCommand(focus),
|
|
1654
1651
|
'ActivityBar.focusFirst': wrapCommand(focusFirst),
|
|
1655
1652
|
'ActivityBar.focusIndex': wrapCommand(focusIndex),
|
|
1656
|
-
'ActivityBar.loadContent': wrapCommand(loadContent),
|
|
1657
1653
|
'ActivityBar.focusLast': wrapCommand(focusLast),
|
|
1658
1654
|
'ActivityBar.focusNext': wrapCommand(focusNext),
|
|
1659
|
-
'ActivityBar.handleBlur': wrapCommand(handleBlur),
|
|
1660
1655
|
'ActivityBar.focusNone': wrapCommand(focusNone),
|
|
1661
|
-
'ActivityBar.
|
|
1656
|
+
'ActivityBar.getCommandIds': getCommandIds,
|
|
1662
1657
|
'ActivityBar.getKeyBindings': getKeyBindings$1,
|
|
1658
|
+
'ActivityBar.handleBlur': wrapCommand(handleBlur),
|
|
1659
|
+
'ActivityBar.handleResize': wrapCommand(handleResize),
|
|
1663
1660
|
'ActivityBar.handleClick': wrapCommand(handleClick),
|
|
1664
|
-
'ActivityBar.
|
|
1661
|
+
'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
|
|
1662
|
+
'ActivityBar.loadContent': wrapCommand(loadContent),
|
|
1665
1663
|
'ActivityBar.render2': render2,
|
|
1666
1664
|
'ActivityBar.renderEventListeners': renderEventListeners,
|
|
1667
1665
|
'ActivityBar.saveState': wrapGetter(saveState),
|
|
1668
|
-
'ActivityBar.terminate': terminate
|
|
1669
|
-
'ActivityBar.create': create$1
|
|
1666
|
+
'ActivityBar.terminate': terminate
|
|
1670
1667
|
};
|
|
1671
1668
|
|
|
1672
1669
|
const listen = async () => {
|