@lvce-editor/main-area-worker 1.7.0 → 1.9.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/mainAreaWorkerMain.js +59 -23
- package/package.json +2 -2
|
@@ -96,12 +96,6 @@ const object = value => {
|
|
|
96
96
|
throw new AssertionError('expected value to be of type object');
|
|
97
97
|
}
|
|
98
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
99
|
|
|
106
100
|
const isMessagePort = value => {
|
|
107
101
|
return value && value instanceof MessagePort;
|
|
@@ -1250,12 +1244,43 @@ const handleClick = async (state, name) => {
|
|
|
1250
1244
|
return state;
|
|
1251
1245
|
};
|
|
1252
1246
|
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1255
|
-
|
|
1247
|
+
const closeTab = (state, groupId, tabId) => {
|
|
1248
|
+
const groups = state.layout.groups.map(group => {
|
|
1249
|
+
if (group.id === groupId) {
|
|
1250
|
+
const newTabs = group.tabs.filter(tab => tab.id !== tabId);
|
|
1251
|
+
let newActiveTabId = group.activeTabId;
|
|
1252
|
+
if (group.activeTabId === tabId) {
|
|
1253
|
+
const tabIndex = group.tabs.findIndex(tab => tab.id === tabId);
|
|
1254
|
+
if (newTabs.length > 0) {
|
|
1255
|
+
newActiveTabId = newTabs[Math.min(tabIndex, newTabs.length - 1)].id;
|
|
1256
|
+
} else {
|
|
1257
|
+
newActiveTabId = undefined;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
return {
|
|
1261
|
+
...group,
|
|
1262
|
+
activeTabId: newActiveTabId,
|
|
1263
|
+
tabs: newTabs
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
return group;
|
|
1267
|
+
});
|
|
1268
|
+
return {
|
|
1269
|
+
...state,
|
|
1270
|
+
layout: {
|
|
1271
|
+
...state.layout,
|
|
1272
|
+
groups
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1256
1275
|
};
|
|
1257
1276
|
|
|
1258
|
-
const
|
|
1277
|
+
const handleClickCloseTab = (state, rawGroupId, rawTabId) => {
|
|
1278
|
+
const groupId = Number.parseInt(rawGroupId);
|
|
1279
|
+
const tabId = Number.parseInt(rawTabId);
|
|
1280
|
+
return closeTab(state, groupId, tabId);
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
const selectTab = async (state, groupIndex, index) => {
|
|
1259
1284
|
const {
|
|
1260
1285
|
layout
|
|
1261
1286
|
} = state;
|
|
@@ -1296,6 +1321,15 @@ const handleClickTab = async (state, groupIndex, index) => {
|
|
|
1296
1321
|
};
|
|
1297
1322
|
};
|
|
1298
1323
|
|
|
1324
|
+
const handleClickTab = async (state, groupIndexRaw, indexRaw) => {
|
|
1325
|
+
if (!groupIndexRaw || !indexRaw) {
|
|
1326
|
+
return state;
|
|
1327
|
+
}
|
|
1328
|
+
const groupIndex = Number.parseInt(groupIndexRaw);
|
|
1329
|
+
const index = Number.parseInt(indexRaw);
|
|
1330
|
+
return selectTab(state, groupIndex, index);
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1299
1333
|
const id = 7201;
|
|
1300
1334
|
const sendMessagePortToExtensionHostWorker = async port => {
|
|
1301
1335
|
await sendMessagePortToExtensionHostWorker$1(port, id);
|
|
@@ -1318,7 +1352,7 @@ const initialize = async () => {
|
|
|
1318
1352
|
set$2(rpc);
|
|
1319
1353
|
};
|
|
1320
1354
|
|
|
1321
|
-
const
|
|
1355
|
+
const getTabs = async () => {
|
|
1322
1356
|
const tabs = [{
|
|
1323
1357
|
content: '',
|
|
1324
1358
|
editorType: 'text',
|
|
@@ -1332,6 +1366,11 @@ const loadContent = async state => {
|
|
|
1332
1366
|
isDirty: false,
|
|
1333
1367
|
title: 'tab 2'
|
|
1334
1368
|
}];
|
|
1369
|
+
return tabs;
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
const loadContent = async state => {
|
|
1373
|
+
const tabs = await getTabs();
|
|
1335
1374
|
return {
|
|
1336
1375
|
...state,
|
|
1337
1376
|
layout: {
|
|
@@ -1400,9 +1439,10 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
1400
1439
|
return [{
|
|
1401
1440
|
childCount: 2,
|
|
1402
1441
|
className: isActive ? 'MainTab MainTabSelected' : 'MainTab',
|
|
1403
|
-
'data-
|
|
1442
|
+
'data-groupIndex': groupIndex,
|
|
1404
1443
|
'data-index': tabIndex,
|
|
1405
1444
|
onClick: HandleClickTab,
|
|
1445
|
+
role: 'tab',
|
|
1406
1446
|
type: Div
|
|
1407
1447
|
}, {
|
|
1408
1448
|
childCount: 1,
|
|
@@ -1411,6 +1451,8 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
1411
1451
|
}, text(tab.isDirty ? `*${tab.title}` : tab.title), {
|
|
1412
1452
|
childCount: 1,
|
|
1413
1453
|
className: 'EditorTabCloseButton',
|
|
1454
|
+
'data-groupIndex': groupIndex,
|
|
1455
|
+
'data-index': tabIndex,
|
|
1414
1456
|
onClick: HandleClickClose,
|
|
1415
1457
|
type: Button
|
|
1416
1458
|
}, text('×')];
|
|
@@ -1509,19 +1551,12 @@ const resize = (state, dimensions) => {
|
|
|
1509
1551
|
};
|
|
1510
1552
|
};
|
|
1511
1553
|
|
|
1512
|
-
const saveState =
|
|
1513
|
-
number(uid);
|
|
1514
|
-
const value = get(uid);
|
|
1554
|
+
const saveState = state => {
|
|
1515
1555
|
const {
|
|
1516
|
-
|
|
1517
|
-
} =
|
|
1518
|
-
const {
|
|
1519
|
-
statusBarItemsLeft,
|
|
1520
|
-
statusBarItemsRight
|
|
1521
|
-
} = newState;
|
|
1556
|
+
layout
|
|
1557
|
+
} = state;
|
|
1522
1558
|
return {
|
|
1523
|
-
|
|
1524
|
-
itemsRight: statusBarItemsRight
|
|
1559
|
+
layout
|
|
1525
1560
|
};
|
|
1526
1561
|
};
|
|
1527
1562
|
|
|
@@ -1539,6 +1574,7 @@ const commandMap = {
|
|
|
1539
1574
|
'MainArea.renderEventListeners': renderEventListeners,
|
|
1540
1575
|
'MainArea.resize': wrapCommand(resize),
|
|
1541
1576
|
'MainArea.saveState': saveState,
|
|
1577
|
+
'MainArea.selectTab': wrapCommand(selectTab),
|
|
1542
1578
|
'MainArea.terminate': terminate
|
|
1543
1579
|
};
|
|
1544
1580
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/main-area-worker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Main Area Worker",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/mainAreaWorkerMain.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@lvce-editor/virtual-dom-worker": "^5.
|
|
14
|
+
"@lvce-editor/virtual-dom-worker": "^5.1.0"
|
|
15
15
|
}
|
|
16
16
|
}
|