@lvce-editor/panel-worker 1.6.0 → 1.8.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/panelWorkerMain.js +74 -49
- package/package.json +1 -1
package/dist/panelWorkerMain.js
CHANGED
|
@@ -64,7 +64,7 @@ const Object$1 = 1;
|
|
|
64
64
|
const Number$1 = 2;
|
|
65
65
|
const Array$1 = 3;
|
|
66
66
|
const String = 4;
|
|
67
|
-
const Boolean = 5;
|
|
67
|
+
const Boolean$1 = 5;
|
|
68
68
|
const Function = 6;
|
|
69
69
|
const Null = 7;
|
|
70
70
|
const Unknown = 8;
|
|
@@ -85,7 +85,7 @@ const getType = value => {
|
|
|
85
85
|
}
|
|
86
86
|
return Object$1;
|
|
87
87
|
case 'boolean':
|
|
88
|
-
return Boolean;
|
|
88
|
+
return Boolean$1;
|
|
89
89
|
default:
|
|
90
90
|
return Unknown;
|
|
91
91
|
}
|
|
@@ -463,12 +463,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
463
463
|
switch (type) {
|
|
464
464
|
case DomException:
|
|
465
465
|
return DOMException;
|
|
466
|
-
case TypeError$1:
|
|
467
|
-
return TypeError;
|
|
468
|
-
case SyntaxError$1:
|
|
469
|
-
return SyntaxError;
|
|
470
466
|
case ReferenceError$1:
|
|
471
467
|
return ReferenceError;
|
|
468
|
+
case SyntaxError$1:
|
|
469
|
+
return SyntaxError;
|
|
470
|
+
case TypeError$1:
|
|
471
|
+
return TypeError;
|
|
472
472
|
default:
|
|
473
473
|
return Error;
|
|
474
474
|
}
|
|
@@ -624,27 +624,27 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
624
624
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
625
625
|
return {
|
|
626
626
|
code: MethodNotFound,
|
|
627
|
-
|
|
628
|
-
|
|
627
|
+
data: error.stack,
|
|
628
|
+
message: error.message
|
|
629
629
|
};
|
|
630
630
|
}
|
|
631
631
|
return {
|
|
632
632
|
code: Custom,
|
|
633
|
-
message: prettyError.message,
|
|
634
633
|
data: {
|
|
635
|
-
stack: getStack(prettyError),
|
|
636
|
-
codeFrame: prettyError.codeFrame,
|
|
637
|
-
type: getErrorType(prettyError),
|
|
638
634
|
code: prettyError.code,
|
|
639
|
-
|
|
640
|
-
|
|
635
|
+
codeFrame: prettyError.codeFrame,
|
|
636
|
+
name: prettyError.name,
|
|
637
|
+
stack: getStack(prettyError),
|
|
638
|
+
type: getErrorType(prettyError)
|
|
639
|
+
},
|
|
640
|
+
message: prettyError.message
|
|
641
641
|
};
|
|
642
642
|
};
|
|
643
643
|
const create$1$1 = (id, error) => {
|
|
644
644
|
return {
|
|
645
|
-
|
|
645
|
+
error,
|
|
646
646
|
id,
|
|
647
|
-
|
|
647
|
+
jsonrpc: Two$1
|
|
648
648
|
};
|
|
649
649
|
};
|
|
650
650
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
@@ -655,8 +655,8 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
655
655
|
};
|
|
656
656
|
const create$7 = (message, result) => {
|
|
657
657
|
return {
|
|
658
|
-
jsonrpc: Two$1,
|
|
659
658
|
id: message.id,
|
|
659
|
+
jsonrpc: Two$1,
|
|
660
660
|
result: result ?? null
|
|
661
661
|
};
|
|
662
662
|
};
|
|
@@ -666,14 +666,14 @@ const getSuccessResponse = (message, result) => {
|
|
|
666
666
|
};
|
|
667
667
|
const getErrorResponseSimple = (id, error) => {
|
|
668
668
|
return {
|
|
669
|
-
jsonrpc: Two$1,
|
|
670
|
-
id,
|
|
671
669
|
error: {
|
|
672
670
|
code: Custom,
|
|
671
|
+
data: error,
|
|
673
672
|
// @ts-ignore
|
|
674
|
-
message: error.message
|
|
675
|
-
|
|
676
|
-
|
|
673
|
+
message: error.message
|
|
674
|
+
},
|
|
675
|
+
id,
|
|
676
|
+
jsonrpc: Two$1
|
|
677
677
|
};
|
|
678
678
|
};
|
|
679
679
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -703,35 +703,35 @@ const normalizeParams = args => {
|
|
|
703
703
|
if (args.length === 1) {
|
|
704
704
|
const options = args[0];
|
|
705
705
|
return {
|
|
706
|
+
execute: options.execute,
|
|
706
707
|
ipc: options.ipc,
|
|
708
|
+
logError: options.logError || defaultLogError,
|
|
707
709
|
message: options.message,
|
|
708
|
-
execute: options.execute,
|
|
709
|
-
resolve: options.resolve || defaultResolve,
|
|
710
710
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
711
|
-
|
|
712
|
-
|
|
711
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
712
|
+
resolve: options.resolve || defaultResolve
|
|
713
713
|
};
|
|
714
714
|
}
|
|
715
715
|
return {
|
|
716
|
+
execute: args[2],
|
|
716
717
|
ipc: args[0],
|
|
718
|
+
logError: args[5],
|
|
717
719
|
message: args[1],
|
|
718
|
-
execute: args[2],
|
|
719
|
-
resolve: args[3],
|
|
720
720
|
preparePrettyError: args[4],
|
|
721
|
-
|
|
722
|
-
|
|
721
|
+
requiresSocket: args[6],
|
|
722
|
+
resolve: args[3]
|
|
723
723
|
};
|
|
724
724
|
};
|
|
725
725
|
const handleJsonRpcMessage = async (...args) => {
|
|
726
726
|
const options = normalizeParams(args);
|
|
727
727
|
const {
|
|
728
|
-
message,
|
|
729
|
-
ipc,
|
|
730
728
|
execute,
|
|
731
|
-
|
|
732
|
-
preparePrettyError,
|
|
729
|
+
ipc,
|
|
733
730
|
logError,
|
|
734
|
-
|
|
731
|
+
message,
|
|
732
|
+
preparePrettyError,
|
|
733
|
+
requiresSocket,
|
|
734
|
+
resolve
|
|
735
735
|
} = options;
|
|
736
736
|
if ('id' in message) {
|
|
737
737
|
if ('method' in message) {
|
|
@@ -792,7 +792,6 @@ const registerPromise = map => {
|
|
|
792
792
|
};
|
|
793
793
|
};
|
|
794
794
|
|
|
795
|
-
// @ts-ignore
|
|
796
795
|
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
797
796
|
const {
|
|
798
797
|
id,
|
|
@@ -886,6 +885,7 @@ const create$3 = async ({
|
|
|
886
885
|
};
|
|
887
886
|
|
|
888
887
|
const Tab = 'tab';
|
|
888
|
+
const TabList = 'tablist';
|
|
889
889
|
const ToolBar = 'toolbar';
|
|
890
890
|
|
|
891
891
|
const Button = 1;
|
|
@@ -893,9 +893,10 @@ const Div = 4;
|
|
|
893
893
|
const Text = 12;
|
|
894
894
|
const Reference = 100;
|
|
895
895
|
|
|
896
|
+
const TargetName = 'event.target.name';
|
|
897
|
+
|
|
896
898
|
const RendererWorker = 1;
|
|
897
899
|
|
|
898
|
-
const SetDom2 = 'Viewlet.setDom2';
|
|
899
900
|
const SetPatches = 'Viewlet.setPatches';
|
|
900
901
|
|
|
901
902
|
const createMockRpc = ({
|
|
@@ -1093,7 +1094,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1093
1094
|
};
|
|
1094
1095
|
|
|
1095
1096
|
const isEqual = (oldState, newState) => {
|
|
1096
|
-
return oldState.assetDir === newState.assetDir && oldState.initial === newState.initial && oldState.currentViewletId === newState.currentViewletId && oldState.selectedIndex === newState.selectedIndex && oldState.views === newState.views;
|
|
1097
|
+
return oldState.assetDir === newState.assetDir && oldState.initial === newState.initial && oldState.currentViewletId === newState.currentViewletId && oldState.selectedIndex === newState.selectedIndex && oldState.views === newState.views && oldState.childUid === newState.childUid && oldState.actionsUid === newState.actionsUid;
|
|
1097
1098
|
};
|
|
1098
1099
|
|
|
1099
1100
|
const RenderItems = 4;
|
|
@@ -1204,7 +1205,10 @@ const loadContent = (state, savedState) => {
|
|
|
1204
1205
|
};
|
|
1205
1206
|
|
|
1206
1207
|
const selectIndex = async (state, index) => {
|
|
1207
|
-
|
|
1208
|
+
const {
|
|
1209
|
+
views
|
|
1210
|
+
} = state;
|
|
1211
|
+
await openViewlet(state, views[index]);
|
|
1208
1212
|
return {
|
|
1209
1213
|
...state,
|
|
1210
1214
|
selectedIndex: index
|
|
@@ -1239,6 +1243,21 @@ const toggleView = async (state, name) => {
|
|
|
1239
1243
|
return selectIndex(state, index);
|
|
1240
1244
|
};
|
|
1241
1245
|
|
|
1246
|
+
const selectName = async (state, name) => {
|
|
1247
|
+
if (!name) {
|
|
1248
|
+
return state;
|
|
1249
|
+
}
|
|
1250
|
+
const index = state.views.indexOf(name);
|
|
1251
|
+
if (index === -1) {
|
|
1252
|
+
return state;
|
|
1253
|
+
}
|
|
1254
|
+
return selectIndex(state, index);
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
const mergeClassNames = (...classNames) => {
|
|
1258
|
+
return classNames.filter(Boolean).join(' ');
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1242
1261
|
const text = data => {
|
|
1243
1262
|
return {
|
|
1244
1263
|
childCount: 0,
|
|
@@ -1567,6 +1586,7 @@ const getActionsDom = newState => {
|
|
|
1567
1586
|
const HandleClickClose = 'handleClickClose';
|
|
1568
1587
|
const HandleClickMaximize = 'handleClickMaximize';
|
|
1569
1588
|
const HandleClickSelectTab = 'HandleClickSelectTab';
|
|
1589
|
+
const HandleClickTab = 'HandleClickTab';
|
|
1570
1590
|
|
|
1571
1591
|
const emptyObject = {};
|
|
1572
1592
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
@@ -1594,7 +1614,7 @@ const getGlobalActionsDom = () => {
|
|
|
1594
1614
|
return [{
|
|
1595
1615
|
childCount: 2,
|
|
1596
1616
|
className: PanelToolBar,
|
|
1597
|
-
role:
|
|
1617
|
+
role: ToolBar,
|
|
1598
1618
|
type: Div
|
|
1599
1619
|
}, {
|
|
1600
1620
|
ariaLabel: maximize(),
|
|
@@ -1605,7 +1625,7 @@ const getGlobalActionsDom = () => {
|
|
|
1605
1625
|
type: Button
|
|
1606
1626
|
}, {
|
|
1607
1627
|
childCount: 0,
|
|
1608
|
-
className:
|
|
1628
|
+
className: mergeClassNames(MaskIcon, MaskIconChevronUp),
|
|
1609
1629
|
type: Div
|
|
1610
1630
|
}, {
|
|
1611
1631
|
ariaLabel: close(),
|
|
@@ -1616,7 +1636,7 @@ const getGlobalActionsDom = () => {
|
|
|
1616
1636
|
type: Button
|
|
1617
1637
|
}, {
|
|
1618
1638
|
childCount: 0,
|
|
1619
|
-
className:
|
|
1639
|
+
className: mergeClassNames(MaskIcon, MaskIconClose),
|
|
1620
1640
|
type: Div
|
|
1621
1641
|
}];
|
|
1622
1642
|
};
|
|
@@ -1628,6 +1648,7 @@ const getTabClassName = isSelected => {
|
|
|
1628
1648
|
}
|
|
1629
1649
|
return className;
|
|
1630
1650
|
};
|
|
1651
|
+
|
|
1631
1652
|
const createPanelTab = (tab, badgeCount, isSelected, index) => {
|
|
1632
1653
|
const label = tab;
|
|
1633
1654
|
const className = getTabClassName(isSelected);
|
|
@@ -1638,7 +1659,7 @@ const createPanelTab = (tab, badgeCount, isSelected, index) => {
|
|
|
1638
1659
|
className,
|
|
1639
1660
|
'data-index': index,
|
|
1640
1661
|
name: tab,
|
|
1641
|
-
onClick:
|
|
1662
|
+
onClick: HandleClickTab,
|
|
1642
1663
|
role: Tab,
|
|
1643
1664
|
type: Button
|
|
1644
1665
|
};
|
|
@@ -1673,6 +1694,7 @@ const getPanelHeaderDom = newState => {
|
|
|
1673
1694
|
}, {
|
|
1674
1695
|
childCount: newState.views.length,
|
|
1675
1696
|
className: PanelTabs,
|
|
1697
|
+
role: TabList,
|
|
1676
1698
|
type: Div
|
|
1677
1699
|
}, ...tabsDom, ...getActionsDom(newState), ...getGlobalActionsDom()];
|
|
1678
1700
|
};
|
|
@@ -1693,19 +1715,18 @@ const getPanelDom = newState => {
|
|
|
1693
1715
|
|
|
1694
1716
|
const renderItems = (oldState, newState) => {
|
|
1695
1717
|
const {
|
|
1696
|
-
initial
|
|
1697
|
-
uid
|
|
1718
|
+
initial
|
|
1698
1719
|
} = newState;
|
|
1699
1720
|
if (initial) {
|
|
1700
|
-
return [
|
|
1721
|
+
return [];
|
|
1701
1722
|
}
|
|
1702
1723
|
const dom = getPanelDom(newState);
|
|
1703
|
-
return
|
|
1724
|
+
return dom;
|
|
1704
1725
|
};
|
|
1705
1726
|
|
|
1706
1727
|
const renderIncremental = (oldState, newState) => {
|
|
1707
|
-
const oldDom = renderItems(oldState, oldState)
|
|
1708
|
-
const newDom = renderItems(newState, newState)
|
|
1728
|
+
const oldDom = renderItems(oldState, oldState);
|
|
1729
|
+
const newDom = renderItems(newState, newState);
|
|
1709
1730
|
const patches = diffTree(oldDom, newDom);
|
|
1710
1731
|
return [SetPatches, newState.uid, patches];
|
|
1711
1732
|
};
|
|
@@ -1753,6 +1774,9 @@ const renderEventListeners = () => {
|
|
|
1753
1774
|
}, {
|
|
1754
1775
|
name: HandleClickSelectTab,
|
|
1755
1776
|
params: ['selectIndexRaw', 'event.target.dataset.index']
|
|
1777
|
+
}, {
|
|
1778
|
+
name: HandleClickTab,
|
|
1779
|
+
params: ['selectName', TargetName]
|
|
1756
1780
|
}];
|
|
1757
1781
|
};
|
|
1758
1782
|
|
|
@@ -1803,6 +1827,7 @@ const commandMap = {
|
|
|
1803
1827
|
'Panel.saveState': wrapGetter(saveState),
|
|
1804
1828
|
'Panel.selectIndex': wrapCommand(selectIndex),
|
|
1805
1829
|
'Panel.selectIndexRaw': wrapCommand(selectRaw),
|
|
1830
|
+
'Panel.selectName': wrapCommand(selectName),
|
|
1806
1831
|
'Panel.setBadgeCount': wrapCommand(setBadgeCount),
|
|
1807
1832
|
'Panel.terminate': terminate,
|
|
1808
1833
|
'Panel.toggleView': wrapCommand(toggleView)
|