@lvce-editor/activity-bar-worker 1.2.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 +122 -97
- package/package.json +1 -1
|
@@ -388,11 +388,11 @@ const remove = id => {
|
|
|
388
388
|
delete callbacks[id];
|
|
389
389
|
};
|
|
390
390
|
let id = 0;
|
|
391
|
-
const create$3 = () => {
|
|
391
|
+
const create$3$1 = () => {
|
|
392
392
|
return ++id;
|
|
393
393
|
};
|
|
394
394
|
const registerPromise = () => {
|
|
395
|
-
const id = create$3();
|
|
395
|
+
const id = create$3$1();
|
|
396
396
|
const {
|
|
397
397
|
resolve,
|
|
398
398
|
promise
|
|
@@ -822,7 +822,7 @@ const listen$1 = async (module, options) => {
|
|
|
822
822
|
const ipc = module.wrap(rawIpc);
|
|
823
823
|
return ipc;
|
|
824
824
|
};
|
|
825
|
-
const create$
|
|
825
|
+
const create$3 = async ({
|
|
826
826
|
commandMap
|
|
827
827
|
}) => {
|
|
828
828
|
// TODO create a commandMap per rpc instance
|
|
@@ -834,7 +834,7 @@ const create$2 = async ({
|
|
|
834
834
|
};
|
|
835
835
|
const WebWorkerRpcClient = {
|
|
836
836
|
__proto__: null,
|
|
837
|
-
create: create$
|
|
837
|
+
create: create$3
|
|
838
838
|
};
|
|
839
839
|
const createMockRpc = ({
|
|
840
840
|
commandMap
|
|
@@ -860,7 +860,7 @@ const toCommandId = key => {
|
|
|
860
860
|
const dotIndex = key.indexOf('.');
|
|
861
861
|
return key.slice(dotIndex + 1);
|
|
862
862
|
};
|
|
863
|
-
const create$
|
|
863
|
+
const create$2 = () => {
|
|
864
864
|
const states = Object.create(null);
|
|
865
865
|
const commandMapRef = {};
|
|
866
866
|
return {
|
|
@@ -947,7 +947,70 @@ const {
|
|
|
947
947
|
getCommandIds,
|
|
948
948
|
wrapGetter,
|
|
949
949
|
wrapCommand
|
|
950
|
-
} = create$
|
|
950
|
+
} = create$2();
|
|
951
|
+
|
|
952
|
+
// TODO parentUid might ot be needed
|
|
953
|
+
const create$1 = (id, uri, x, y, width, height, args, parentUid, platform = 0) => {
|
|
954
|
+
const state = {
|
|
955
|
+
currentViewletId: '',
|
|
956
|
+
uid: id,
|
|
957
|
+
focus: 0,
|
|
958
|
+
focused: false,
|
|
959
|
+
focusedIndex: -1,
|
|
960
|
+
scrollBarHeight: 0,
|
|
961
|
+
width: 0,
|
|
962
|
+
x: 0,
|
|
963
|
+
y: 0,
|
|
964
|
+
sideBarVisible: false,
|
|
965
|
+
activityBarItems: [],
|
|
966
|
+
selectedIndex: -1
|
|
967
|
+
};
|
|
968
|
+
set$3(state.uid, state, state);
|
|
969
|
+
return state;
|
|
970
|
+
};
|
|
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
|
+
};
|
|
951
1014
|
|
|
952
1015
|
const List = 1;
|
|
953
1016
|
|
|
@@ -991,14 +1054,6 @@ const focusNone = state => {
|
|
|
991
1054
|
return focusIndex(state, -1);
|
|
992
1055
|
};
|
|
993
1056
|
|
|
994
|
-
const Button = 'event.button';
|
|
995
|
-
const ClientX = 'event.clientX';
|
|
996
|
-
const ClientY = 'event.clientY';
|
|
997
|
-
const CtrlKey = 'event.ctrlKey';
|
|
998
|
-
const DeltaMode = 'event.deltaMode';
|
|
999
|
-
const DeltaY = 'event.deltaY';
|
|
1000
|
-
const TargetValue = 'event.target.value';
|
|
1001
|
-
|
|
1002
1057
|
const Enter = 3;
|
|
1003
1058
|
const Space = 9;
|
|
1004
1059
|
const PageUp = 10;
|
|
@@ -1013,7 +1068,11 @@ const LeftClick = 0;
|
|
|
1013
1068
|
const DebugWorker = 55;
|
|
1014
1069
|
const RendererWorker$1 = 1;
|
|
1015
1070
|
|
|
1071
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
1072
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1073
|
+
|
|
1016
1074
|
const FocusActivityBar = 5;
|
|
1075
|
+
const FocusExplorer = 13;
|
|
1017
1076
|
|
|
1018
1077
|
const getKeyBindings$1 = () => {
|
|
1019
1078
|
return [{
|
|
@@ -1501,6 +1560,10 @@ const handleClick = async (state, button, index, x, y) => {
|
|
|
1501
1560
|
}
|
|
1502
1561
|
};
|
|
1503
1562
|
|
|
1563
|
+
const handleResize = state => {
|
|
1564
|
+
return state;
|
|
1565
|
+
};
|
|
1566
|
+
|
|
1504
1567
|
const findIndex = (activityBarItems, id) => {
|
|
1505
1568
|
for (let i = 0; i < activityBarItems.length; i++) {
|
|
1506
1569
|
if (activityBarItems[i].id === id) {
|
|
@@ -1518,100 +1581,58 @@ const handleSideBarViewletChange = (state, id, ...args) => {
|
|
|
1518
1581
|
};
|
|
1519
1582
|
};
|
|
1520
1583
|
|
|
1584
|
+
const loadContent = async (state, savedState) => {
|
|
1585
|
+
return {
|
|
1586
|
+
...state
|
|
1587
|
+
};
|
|
1588
|
+
};
|
|
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
|
+
|
|
1521
1612
|
const applyRender = (oldState, newState, diffResult) => {
|
|
1522
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
|
+
}
|
|
1523
1621
|
return commands;
|
|
1524
1622
|
};
|
|
1525
1623
|
|
|
1526
1624
|
const render2 = (uid, diffResult) => {
|
|
1527
1625
|
const {
|
|
1626
|
+
oldState,
|
|
1528
1627
|
newState
|
|
1529
1628
|
} = get$1(uid);
|
|
1530
1629
|
set$3(uid, newState, newState);
|
|
1531
|
-
const commands = applyRender();
|
|
1630
|
+
const commands = applyRender(oldState, newState, diffResult);
|
|
1532
1631
|
return commands;
|
|
1533
1632
|
};
|
|
1534
1633
|
|
|
1535
|
-
const HandleClick = 1;
|
|
1536
|
-
const HandleClickOpenFolder = 2;
|
|
1537
|
-
const HandleContextMenu = 3;
|
|
1538
|
-
const HandleDragLeave = 4;
|
|
1539
|
-
const HandleDragOver = 5;
|
|
1540
|
-
const HandleDrop = 6;
|
|
1541
|
-
const HandleEditingInput = 7;
|
|
1542
|
-
const HandleInputBlur = 8;
|
|
1543
|
-
const HandleInputClick = 9;
|
|
1544
|
-
const HandleListBlur = 11;
|
|
1545
|
-
const HandleListFocus = 12;
|
|
1546
|
-
const HandlePointerDown = 14;
|
|
1547
|
-
const HandleWheel = 15;
|
|
1548
|
-
const HandleDragStart = 17;
|
|
1549
|
-
|
|
1550
1634
|
const renderEventListeners = () => {
|
|
1551
|
-
return [
|
|
1552
|
-
name: HandleInputBlur,
|
|
1553
|
-
params: ['handleInputBlur']
|
|
1554
|
-
},
|
|
1555
|
-
// {
|
|
1556
|
-
// name: DomEventListenersFunctions.HandleInputKeyDown,
|
|
1557
|
-
// params: ['handleInputKeyDown'],
|
|
1558
|
-
// stopPropagation: true, // TODO find a way to do this without stopPropagation
|
|
1559
|
-
// },
|
|
1560
|
-
// {
|
|
1561
|
-
// name: DomEventListenersFunctions.HandleListKeyDown,
|
|
1562
|
-
// params: ['handleKeyDown', 'event.key'],
|
|
1563
|
-
// preventDefault: true,
|
|
1564
|
-
// },
|
|
1565
|
-
{
|
|
1566
|
-
name: HandleListFocus,
|
|
1567
|
-
params: ['handleFocus', 'event.isTrusted', 'event.target.className']
|
|
1568
|
-
}, {
|
|
1569
|
-
name: HandleListBlur,
|
|
1570
|
-
params: ['handleBlur']
|
|
1571
|
-
}, {
|
|
1572
|
-
name: HandleClick,
|
|
1573
|
-
params: ['handleClickAt', 'event.defaultPrevented', Button, CtrlKey, 'event.shiftKey', ClientX, ClientY],
|
|
1574
|
-
preventDefault: true
|
|
1575
|
-
}, {
|
|
1576
|
-
name: HandleInputClick,
|
|
1577
|
-
params: ['handleInputClick'],
|
|
1578
|
-
preventDefault: true
|
|
1579
|
-
}, {
|
|
1580
|
-
name: HandleClickOpenFolder,
|
|
1581
|
-
params: ['handleClickOpenFolder'],
|
|
1582
|
-
preventDefault: true
|
|
1583
|
-
}, {
|
|
1584
|
-
name: HandlePointerDown,
|
|
1585
|
-
params: ['handlePointerDown', Button, ClientX, ClientY]
|
|
1586
|
-
// preventDefault: true,
|
|
1587
|
-
}, {
|
|
1588
|
-
name: HandleEditingInput,
|
|
1589
|
-
params: ['updateEditingValue', TargetValue]
|
|
1590
|
-
}, {
|
|
1591
|
-
name: HandleContextMenu,
|
|
1592
|
-
params: ['handleContextMenu', Button, ClientX, ClientY],
|
|
1593
|
-
preventDefault: true
|
|
1594
|
-
}, {
|
|
1595
|
-
name: HandleWheel,
|
|
1596
|
-
params: ['handleWheel', DeltaMode, DeltaY],
|
|
1597
|
-
passive: true
|
|
1598
|
-
}, {
|
|
1599
|
-
name: HandleDragOver,
|
|
1600
|
-
params: ['handleDragOver', ClientX, ClientY],
|
|
1601
|
-
preventDefault: true
|
|
1602
|
-
}, {
|
|
1603
|
-
name: HandleDrop,
|
|
1604
|
-
params: ['handleDrop', ClientX, ClientY, 'event.dataTransfer.files2', 'event.dataTransfer.files'],
|
|
1605
|
-
preventDefault: true
|
|
1606
|
-
}, {
|
|
1607
|
-
name: HandleDragLeave,
|
|
1608
|
-
params: ['handleDragLeave']
|
|
1609
|
-
}, {
|
|
1610
|
-
name: HandleDragStart,
|
|
1611
|
-
params: ['handleDragStart'],
|
|
1612
|
-
// @ts-ignore
|
|
1613
|
-
dragEffect: 'copyMove'
|
|
1614
|
-
}];
|
|
1635
|
+
return [];
|
|
1615
1636
|
};
|
|
1616
1637
|
|
|
1617
1638
|
const saveState = state => {
|
|
@@ -1624,17 +1645,21 @@ const saveState = state => {
|
|
|
1624
1645
|
};
|
|
1625
1646
|
|
|
1626
1647
|
const commandMap = {
|
|
1648
|
+
'ActivityBar.create': create$1,
|
|
1649
|
+
'ActivityBar.diff2': diff2,
|
|
1627
1650
|
'ActivityBar.focus': wrapCommand(focus),
|
|
1628
1651
|
'ActivityBar.focusFirst': wrapCommand(focusFirst),
|
|
1629
1652
|
'ActivityBar.focusIndex': wrapCommand(focusIndex),
|
|
1630
1653
|
'ActivityBar.focusLast': wrapCommand(focusLast),
|
|
1631
1654
|
'ActivityBar.focusNext': wrapCommand(focusNext),
|
|
1632
|
-
'ActivityBar.handleBlur': wrapCommand(handleBlur),
|
|
1633
1655
|
'ActivityBar.focusNone': wrapCommand(focusNone),
|
|
1634
|
-
'ActivityBar.
|
|
1656
|
+
'ActivityBar.getCommandIds': getCommandIds,
|
|
1635
1657
|
'ActivityBar.getKeyBindings': getKeyBindings$1,
|
|
1658
|
+
'ActivityBar.handleBlur': wrapCommand(handleBlur),
|
|
1659
|
+
'ActivityBar.handleResize': wrapCommand(handleResize),
|
|
1636
1660
|
'ActivityBar.handleClick': wrapCommand(handleClick),
|
|
1637
|
-
'ActivityBar.
|
|
1661
|
+
'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
|
|
1662
|
+
'ActivityBar.loadContent': wrapCommand(loadContent),
|
|
1638
1663
|
'ActivityBar.render2': render2,
|
|
1639
1664
|
'ActivityBar.renderEventListeners': renderEventListeners,
|
|
1640
1665
|
'ActivityBar.saveState': wrapGetter(saveState),
|