@lvce-editor/panel-worker 2.16.0 → 2.18.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 +93 -104
- package/package.json +1 -1
package/dist/panelWorkerMain.js
CHANGED
|
@@ -54,61 +54,6 @@ class VError extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
class AssertionError extends Error {
|
|
58
|
-
constructor(message) {
|
|
59
|
-
super(message);
|
|
60
|
-
this.name = 'AssertionError';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const Object$1 = 1;
|
|
64
|
-
const Number$1 = 2;
|
|
65
|
-
const Array$1 = 3;
|
|
66
|
-
const String$1 = 4;
|
|
67
|
-
const Boolean$1 = 5;
|
|
68
|
-
const Function = 6;
|
|
69
|
-
const Null = 7;
|
|
70
|
-
const Unknown = 8;
|
|
71
|
-
const getType = value => {
|
|
72
|
-
switch (typeof value) {
|
|
73
|
-
case 'number':
|
|
74
|
-
return Number$1;
|
|
75
|
-
case 'function':
|
|
76
|
-
return Function;
|
|
77
|
-
case 'string':
|
|
78
|
-
return String$1;
|
|
79
|
-
case 'object':
|
|
80
|
-
if (value === null) {
|
|
81
|
-
return Null;
|
|
82
|
-
}
|
|
83
|
-
if (Array.isArray(value)) {
|
|
84
|
-
return Array$1;
|
|
85
|
-
}
|
|
86
|
-
return Object$1;
|
|
87
|
-
case 'boolean':
|
|
88
|
-
return Boolean$1;
|
|
89
|
-
default:
|
|
90
|
-
return Unknown;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const object = value => {
|
|
94
|
-
const type = getType(value);
|
|
95
|
-
if (type !== Object$1) {
|
|
96
|
-
throw new AssertionError('expected value to be of type object');
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const number = value => {
|
|
100
|
-
const type = getType(value);
|
|
101
|
-
if (type !== Number$1) {
|
|
102
|
-
throw new AssertionError('expected value to be of type number');
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const string = value => {
|
|
106
|
-
const type = getType(value);
|
|
107
|
-
if (type !== String$1) {
|
|
108
|
-
throw new AssertionError('expected value to be of type string');
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
57
|
const isMessagePort = value => {
|
|
113
58
|
return value && value instanceof MessagePort;
|
|
114
59
|
};
|
|
@@ -1109,7 +1054,7 @@ const createMockRpc = ({
|
|
|
1109
1054
|
};
|
|
1110
1055
|
|
|
1111
1056
|
const rpcs = Object.create(null);
|
|
1112
|
-
const set$
|
|
1057
|
+
const set$3 = (id, rpc) => {
|
|
1113
1058
|
rpcs[id] = rpc;
|
|
1114
1059
|
};
|
|
1115
1060
|
const get$1 = id => {
|
|
@@ -1121,37 +1066,38 @@ const remove = id => {
|
|
|
1121
1066
|
|
|
1122
1067
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1123
1068
|
const create$2 = rpcId => {
|
|
1069
|
+
// Set by set() only: a mock rpc from registerMockRpc does not count as connected.
|
|
1070
|
+
let connected = false;
|
|
1124
1071
|
return {
|
|
1125
1072
|
async dispose() {
|
|
1126
1073
|
const rpc = get$1(rpcId);
|
|
1074
|
+
connected = false;
|
|
1127
1075
|
await rpc.dispose();
|
|
1128
1076
|
},
|
|
1129
|
-
// @ts-ignore
|
|
1130
1077
|
invoke(method, ...params) {
|
|
1131
1078
|
const rpc = get$1(rpcId);
|
|
1132
|
-
// @ts-ignore
|
|
1133
1079
|
return rpc.invoke(method, ...params);
|
|
1134
1080
|
},
|
|
1135
|
-
// @ts-ignore
|
|
1136
1081
|
invokeAndTransfer(method, ...params) {
|
|
1137
1082
|
const rpc = get$1(rpcId);
|
|
1138
|
-
// @ts-ignore
|
|
1139
1083
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1140
1084
|
},
|
|
1085
|
+
isConnected() {
|
|
1086
|
+
return connected;
|
|
1087
|
+
},
|
|
1141
1088
|
registerMockRpc(commandMap) {
|
|
1142
1089
|
const mockRpc = createMockRpc({
|
|
1143
1090
|
commandMap
|
|
1144
1091
|
});
|
|
1145
|
-
set$
|
|
1146
|
-
// @ts-ignore
|
|
1092
|
+
set$3(rpcId, mockRpc);
|
|
1147
1093
|
mockRpc[Symbol.dispose] = () => {
|
|
1148
1094
|
remove(rpcId);
|
|
1149
1095
|
};
|
|
1150
|
-
// @ts-ignore
|
|
1151
1096
|
return mockRpc;
|
|
1152
1097
|
},
|
|
1153
1098
|
set(rpc) {
|
|
1154
|
-
set$
|
|
1099
|
+
set$3(rpcId, rpc);
|
|
1100
|
+
connected = true;
|
|
1155
1101
|
}
|
|
1156
1102
|
};
|
|
1157
1103
|
};
|
|
@@ -1185,20 +1131,79 @@ const RendererWorker = 1;
|
|
|
1185
1131
|
const SetPatches = 'Viewlet.setPatches';
|
|
1186
1132
|
|
|
1187
1133
|
const {
|
|
1188
|
-
invoke: invoke$
|
|
1189
|
-
|
|
1134
|
+
invoke: invoke$1,
|
|
1135
|
+
isConnected,
|
|
1136
|
+
set: set$2
|
|
1190
1137
|
} = create$2(RendererProcess);
|
|
1191
1138
|
|
|
1139
|
+
class AssertionError extends Error {
|
|
1140
|
+
constructor(message) {
|
|
1141
|
+
super(message);
|
|
1142
|
+
this.name = 'AssertionError';
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
const Object$1 = 1;
|
|
1146
|
+
const Number$1 = 2;
|
|
1147
|
+
const Array$1 = 3;
|
|
1148
|
+
const String$1 = 4;
|
|
1149
|
+
const Boolean$1 = 5;
|
|
1150
|
+
const Function = 6;
|
|
1151
|
+
const Null = 7;
|
|
1152
|
+
const Unknown = 8;
|
|
1153
|
+
const getType = value => {
|
|
1154
|
+
switch (typeof value) {
|
|
1155
|
+
case 'number':
|
|
1156
|
+
return Number$1;
|
|
1157
|
+
case 'function':
|
|
1158
|
+
return Function;
|
|
1159
|
+
case 'string':
|
|
1160
|
+
return String$1;
|
|
1161
|
+
case 'object':
|
|
1162
|
+
if (value === null) {
|
|
1163
|
+
return Null;
|
|
1164
|
+
}
|
|
1165
|
+
if (Array.isArray(value)) {
|
|
1166
|
+
return Array$1;
|
|
1167
|
+
}
|
|
1168
|
+
return Object$1;
|
|
1169
|
+
case 'boolean':
|
|
1170
|
+
return Boolean$1;
|
|
1171
|
+
default:
|
|
1172
|
+
return Unknown;
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
const object = value => {
|
|
1176
|
+
const type = getType(value);
|
|
1177
|
+
if (type !== Object$1) {
|
|
1178
|
+
throw new AssertionError('expected value to be of type object');
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
const number = value => {
|
|
1182
|
+
const type = getType(value);
|
|
1183
|
+
if (type !== Number$1) {
|
|
1184
|
+
throw new AssertionError('expected value to be of type number');
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
const string = value => {
|
|
1188
|
+
const type = getType(value);
|
|
1189
|
+
if (type !== String$1) {
|
|
1190
|
+
throw new AssertionError('expected value to be of type string');
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1192
1194
|
const {
|
|
1193
|
-
invoke
|
|
1194
|
-
set: set$
|
|
1195
|
+
invoke,
|
|
1196
|
+
set: set$1
|
|
1195
1197
|
} = create$2(RendererWorker);
|
|
1196
1198
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1197
1199
|
number(uid);
|
|
1198
1200
|
number(menuId);
|
|
1199
1201
|
number(x);
|
|
1200
1202
|
number(y);
|
|
1201
|
-
await invoke
|
|
1203
|
+
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1204
|
+
};
|
|
1205
|
+
const resizeViewlet = async (uid, dimensions) => {
|
|
1206
|
+
return invoke('Viewlet.resize', uid, dimensions);
|
|
1202
1207
|
};
|
|
1203
1208
|
|
|
1204
1209
|
const toCommandId = key => {
|
|
@@ -1467,7 +1472,7 @@ const {
|
|
|
1467
1472
|
get,
|
|
1468
1473
|
getCommandIds,
|
|
1469
1474
|
registerCommands,
|
|
1470
|
-
set
|
|
1475
|
+
set,
|
|
1471
1476
|
wrapCommand,
|
|
1472
1477
|
wrapGetter
|
|
1473
1478
|
} = create$1();
|
|
@@ -1499,7 +1504,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir, applicationId
|
|
|
1499
1504
|
x,
|
|
1500
1505
|
y
|
|
1501
1506
|
};
|
|
1502
|
-
set
|
|
1507
|
+
set(uid, state, state);
|
|
1503
1508
|
};
|
|
1504
1509
|
|
|
1505
1510
|
const isEqual$1 = (oldState, newState) => {
|
|
@@ -1604,21 +1609,6 @@ const getMenuIds = () => {
|
|
|
1604
1609
|
return [Tab];
|
|
1605
1610
|
};
|
|
1606
1611
|
|
|
1607
|
-
const state = {
|
|
1608
|
-
connected: false
|
|
1609
|
-
};
|
|
1610
|
-
const isConnected = () => {
|
|
1611
|
-
const {
|
|
1612
|
-
connected
|
|
1613
|
-
} = state;
|
|
1614
|
-
return connected;
|
|
1615
|
-
};
|
|
1616
|
-
const invoke = (method, ...params) => invoke$2(method, ...params);
|
|
1617
|
-
const set = rpc => {
|
|
1618
|
-
set$3(rpc);
|
|
1619
|
-
state.connected = true;
|
|
1620
|
-
};
|
|
1621
|
-
|
|
1622
1612
|
const layoutCommands = {
|
|
1623
1613
|
handleClickClose: 'Layout.hidePanel',
|
|
1624
1614
|
handleClickMaximize: 'Layout.maximizePanel',
|
|
@@ -1626,7 +1616,7 @@ const layoutCommands = {
|
|
|
1626
1616
|
};
|
|
1627
1617
|
const forwardLayoutCommand = layoutCommand => {
|
|
1628
1618
|
setTimeout(() => {
|
|
1629
|
-
void invoke('Viewlet.forwardRendererWorkerCommand', layoutCommand);
|
|
1619
|
+
void invoke$1('Viewlet.forwardRendererWorkerCommand', layoutCommand);
|
|
1630
1620
|
}, 0);
|
|
1631
1621
|
};
|
|
1632
1622
|
const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
|
|
@@ -1642,7 +1632,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
1642
1632
|
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
1643
1633
|
}
|
|
1644
1634
|
await fn(uid, ...args);
|
|
1645
|
-
await invoke
|
|
1635
|
+
await invoke('Viewlet.requestRender', uid);
|
|
1646
1636
|
};
|
|
1647
1637
|
const rpc = await create$4({
|
|
1648
1638
|
commandMap: {
|
|
@@ -1651,7 +1641,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
1651
1641
|
messagePort: port
|
|
1652
1642
|
});
|
|
1653
1643
|
if (setAsRendererProcess) {
|
|
1654
|
-
set(rpc);
|
|
1644
|
+
set$2(rpc);
|
|
1655
1645
|
}
|
|
1656
1646
|
};
|
|
1657
1647
|
|
|
@@ -1702,16 +1692,16 @@ const handleTabContextMenu = async (state, _button, x, y) => {
|
|
|
1702
1692
|
};
|
|
1703
1693
|
|
|
1704
1694
|
const handleClickClose = async state => {
|
|
1705
|
-
await invoke
|
|
1695
|
+
await invoke('Layout.hidePanel');
|
|
1706
1696
|
return state;
|
|
1707
1697
|
};
|
|
1708
1698
|
|
|
1709
1699
|
const handleClickMaximize = async state => {
|
|
1710
|
-
await invoke
|
|
1700
|
+
await invoke('Layout.maximizePanel');
|
|
1711
1701
|
return state;
|
|
1712
1702
|
};
|
|
1713
1703
|
const handleClickUnmaximize = async state => {
|
|
1714
|
-
await invoke
|
|
1704
|
+
await invoke('Layout.unmaximizePanel');
|
|
1715
1705
|
return state;
|
|
1716
1706
|
};
|
|
1717
1707
|
|
|
@@ -1742,7 +1732,7 @@ const handleFilterInput = async (state, value) => {
|
|
|
1742
1732
|
currentViewletId
|
|
1743
1733
|
} = state;
|
|
1744
1734
|
const fullCommand = `${currentViewletId}.handleFilterInput`;
|
|
1745
|
-
await invoke
|
|
1735
|
+
await invoke(fullCommand, value);
|
|
1746
1736
|
return state;
|
|
1747
1737
|
};
|
|
1748
1738
|
|
|
@@ -1778,9 +1768,9 @@ const getSavedViewletId = savedState => {
|
|
|
1778
1768
|
|
|
1779
1769
|
const createViewlet = async (viewletModuleId, editorUid, tabId, actionsUid, bounds, uri, focus, applicationId) => {
|
|
1780
1770
|
if (applicationId === undefined) {
|
|
1781
|
-
await invoke
|
|
1771
|
+
await invoke('Layout.createPanelViewlet', viewletModuleId, editorUid, tabId, actionsUid, bounds, uri, focus);
|
|
1782
1772
|
} else {
|
|
1783
|
-
await invoke
|
|
1773
|
+
await invoke('Application.execute', applicationId, 'Layout.createPanelViewlet', viewletModuleId, editorUid, tabId, actionsUid, bounds, uri, focus);
|
|
1784
1774
|
}
|
|
1785
1775
|
};
|
|
1786
1776
|
|
|
@@ -1821,11 +1811,11 @@ const isCommandNotFoundError = error => {
|
|
|
1821
1811
|
return message.includes(command.toLowerCase()) && message.includes('not found');
|
|
1822
1812
|
};
|
|
1823
1813
|
const saveViewletState = async (childUid, viewletId) => {
|
|
1824
|
-
if (childUid <= 0
|
|
1814
|
+
if (!viewletId || childUid <= 0) {
|
|
1825
1815
|
return;
|
|
1826
1816
|
}
|
|
1827
1817
|
try {
|
|
1828
|
-
await invoke
|
|
1818
|
+
await invoke(command, childUid, viewletId);
|
|
1829
1819
|
} catch (error) {
|
|
1830
1820
|
if (!isCommandNotFoundError(error)) {
|
|
1831
1821
|
throw error;
|
|
@@ -2500,7 +2490,7 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
2500
2490
|
|
|
2501
2491
|
const hideViewlet = async uid => {
|
|
2502
2492
|
try {
|
|
2503
|
-
const commands = await invoke
|
|
2493
|
+
const commands = await invoke('Viewlet.hide', uid);
|
|
2504
2494
|
if (Array.isArray(commands)) {
|
|
2505
2495
|
return commands;
|
|
2506
2496
|
}
|
|
@@ -2510,7 +2500,7 @@ const hideViewlet = async uid => {
|
|
|
2510
2500
|
throw error;
|
|
2511
2501
|
}
|
|
2512
2502
|
}
|
|
2513
|
-
const commands = await invoke
|
|
2503
|
+
const commands = await invoke('Viewlet.dispose', uid, true);
|
|
2514
2504
|
return Array.isArray(commands) ? commands : [];
|
|
2515
2505
|
};
|
|
2516
2506
|
|
|
@@ -2519,7 +2509,7 @@ const render2 = async (uid, diffResult) => {
|
|
|
2519
2509
|
newState,
|
|
2520
2510
|
oldState
|
|
2521
2511
|
} = get(uid);
|
|
2522
|
-
set
|
|
2512
|
+
set(uid, newState, newState);
|
|
2523
2513
|
const commands = [...applyRender(oldState, newState, diffResult)];
|
|
2524
2514
|
// Keep referenced DOM nodes until the parent patches have replaced them.
|
|
2525
2515
|
for (const childUid of take(uid)) {
|
|
@@ -2529,7 +2519,7 @@ const render2 = async (uid, diffResult) => {
|
|
|
2529
2519
|
return renderDirect(uid, commands);
|
|
2530
2520
|
};
|
|
2531
2521
|
const renderDirect = async (uid, commands) => {
|
|
2532
|
-
const transactionId = await invoke('Viewlet.queueCommands', uid, commands);
|
|
2522
|
+
const transactionId = await invoke$1('Viewlet.queueCommands', uid, commands);
|
|
2533
2523
|
return [['Viewlet.commitPending', uid, transactionId]];
|
|
2534
2524
|
};
|
|
2535
2525
|
|
|
@@ -2571,8 +2561,7 @@ const resize = async (state, dimensions) => {
|
|
|
2571
2561
|
...newState
|
|
2572
2562
|
};
|
|
2573
2563
|
}
|
|
2574
|
-
|
|
2575
|
-
await invoke$1('Viewlet.resize', childUid, dimensions);
|
|
2564
|
+
await resizeViewlet(childUid, dimensions);
|
|
2576
2565
|
return {
|
|
2577
2566
|
...newState
|
|
2578
2567
|
};
|
|
@@ -2705,7 +2694,7 @@ const listen = async () => {
|
|
|
2705
2694
|
const rpc = await create$3({
|
|
2706
2695
|
commandMap: commandMap
|
|
2707
2696
|
});
|
|
2708
|
-
set$
|
|
2697
|
+
set$1(rpc);
|
|
2709
2698
|
};
|
|
2710
2699
|
|
|
2711
2700
|
const main = async () => {
|