@lvce-editor/output-view 1.14.0 → 1.16.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.
@@ -515,7 +515,7 @@ const create$4$1 = (method, params) => {
515
515
  };
516
516
  };
517
517
  const callbacks = Object.create(null);
518
- const set$5 = (id, fn) => {
518
+ const set$4 = (id, fn) => {
519
519
  callbacks[id] = fn;
520
520
  };
521
521
  const get$2 = id => {
@@ -534,7 +534,7 @@ const registerPromise = () => {
534
534
  resolve,
535
535
  promise
536
536
  } = Promise.withResolvers();
537
- set$5(id, resolve);
537
+ set$4(id, resolve);
538
538
  return {
539
539
  id,
540
540
  promise
@@ -1092,235 +1092,27 @@ const terminate = () => {
1092
1092
  globalThis.close();
1093
1093
  };
1094
1094
 
1095
- const closeFindWidget = async state => {
1096
- // TODO
1097
- return {
1098
- ...state
1099
- };
1100
- };
1101
-
1102
- const User = 1;
1103
- const Script = 2;
1104
-
1105
- const {
1106
- get: get$1,
1107
- set: set$4,
1108
- wrapCommand,
1109
- wrapGetter,
1110
- getKeys
1111
- } = create$2();
1112
-
1113
- const create$1 = (id, uri, x, y, width, height, platform, parentId) => {
1114
- number(parentId);
1115
- const state = {
1116
- uid: id,
1117
- parentId,
1118
- uri,
1119
- focusedIndex: -2,
1120
- message: '',
1121
- itemHeight: 22,
1122
- x,
1123
- y,
1124
- width,
1125
- height,
1126
- filterValue: '',
1127
- inputSource: User,
1128
- minLineY: 0,
1129
- maxLineY: 0,
1130
- listItems: [],
1131
- collapsedUris: [],
1132
- selectedOption: '',
1133
- smallWidthBreakPoint: 650,
1134
- workspaceUri: '',
1135
- options: [],
1136
- error: '',
1137
- errorCode: 0,
1138
- buttons: [],
1139
- filteredItems: [],
1140
- platform,
1141
- watchId: 0
1142
- };
1143
- set$4(id, state, state);
1144
- };
1145
-
1146
- const isEqual$2 = (oldState, newState) => {
1147
- return newState.inputSource === User || oldState.filterValue === newState.filterValue;
1148
- };
1149
-
1150
- const isEqual$1 = (oldState, newState) => {
1151
- return oldState.selectedOption === newState.selectedOption && oldState.listItems === newState.listItems && oldState.filteredItems === newState.filteredItems;
1152
- };
1153
-
1154
- const isEqual = (oldState, newState) => {
1155
- return oldState.selectedOption === newState.selectedOption;
1156
- };
1157
-
1158
- const RenderItems = 1;
1159
- const RenderFilterValue = 2;
1160
- const RenderSelectedItem = 3;
1161
-
1162
- const modules = [isEqual$1, isEqual$2, isEqual];
1163
- const numbers = [RenderItems, RenderFilterValue, RenderSelectedItem];
1164
-
1165
- const diff = (oldState, newState) => {
1166
- const diffResult = [];
1167
- for (let i = 0; i < modules.length; i++) {
1168
- const fn = modules[i];
1169
- if (!fn(oldState, newState)) {
1170
- diffResult.push(numbers[i]);
1171
- }
1172
- }
1173
- return diffResult;
1174
- };
1175
-
1176
- const diff2 = uid => {
1177
- const {
1178
- oldState,
1179
- newState
1180
- } = get$1(uid);
1181
- const diffResult = diff(oldState, newState);
1182
- return diffResult;
1183
- };
1184
-
1185
- const focusIndex = (state, index) => {
1186
- return {
1187
- ...state,
1188
- focusedIndex: index
1189
- };
1190
- };
1191
-
1192
- const commandMapRef = {};
1193
-
1194
- const toCommandId = key => {
1195
- const dotIndex = key.indexOf('.');
1196
- return key.slice(dotIndex + 1);
1197
- };
1198
- const getCommandIds = () => {
1199
- const keys = Object.keys(commandMapRef);
1200
- const ids = keys.map(toCommandId);
1201
- return ids;
1202
- };
1203
-
1204
- const ToolBar = 'toolbar';
1205
- const AriaRoles = {
1206
- __proto__: null,
1207
- ToolBar};
1208
- const Space = 9;
1209
- const PageUp = 10;
1210
- const PageDown = 11;
1211
- const End = 255;
1212
- const Home = 12;
1213
- const LeftArrow = 13;
1214
- const UpArrow = 14;
1215
- const RightArrow = 15;
1216
- const DownArrow = 16;
1217
- const KeyCode = {
1218
- __proto__: null,
1219
- DownArrow,
1220
- End,
1221
- Home,
1222
- LeftArrow,
1223
- PageDown,
1224
- PageUp,
1225
- RightArrow,
1226
- Space,
1227
- UpArrow
1228
- };
1229
- const mergeClassNames = (...classNames) => {
1230
- return classNames.filter(Boolean).join(' ');
1231
- };
1232
- const Button$1 = 1;
1233
- const Div = 4;
1234
- const Input = 6;
1235
- const Text = 12;
1236
- const Select$2 = 63;
1237
- const Option$1 = 64;
1238
- const VirtualDomElements = {
1239
- __proto__: null,
1240
- Button: Button$1,
1241
- Div,
1242
- Input,
1243
- Option: Option$1,
1244
- Select: Select$2};
1245
- const text = data => {
1246
- return {
1247
- type: Text,
1248
- text: data,
1249
- childCount: 0
1250
- };
1251
- };
1252
-
1253
- const FocusProblems = 19;
1254
-
1255
- const getKeyBindings = () => {
1256
- return [{
1257
- key: KeyCode.DownArrow,
1258
- command: 'Problems.focusNext',
1259
- when: FocusProblems
1260
- }, {
1261
- key: KeyCode.UpArrow,
1262
- command: 'Problems.focusPrevious',
1263
- when: FocusProblems
1264
- }, {
1265
- key: KeyCode.Home,
1266
- command: 'Problems.focusFirst',
1267
- when: FocusProblems
1268
- }, {
1269
- key: KeyCode.PageUp,
1270
- command: 'Problems.focusFirst',
1271
- when: FocusProblems
1272
- }, {
1273
- key: KeyCode.PageDown,
1274
- command: 'Problems.focusLast',
1275
- when: FocusProblems
1276
- }, {
1277
- key: KeyCode.End,
1278
- command: 'Problems.focusLast',
1279
- when: FocusProblems
1280
- }, {
1281
- key: KeyCode.Space,
1282
- command: 'Problems.selectCurrent',
1283
- when: FocusProblems
1284
- }, {
1285
- key: KeyCode.Home,
1286
- command: 'Problems.focusFirst',
1287
- when: FocusProblems
1288
- }, {
1289
- key: KeyCode.End,
1290
- command: 'Problems.focusLast',
1291
- when: FocusProblems
1292
- }, {
1293
- key: KeyCode.LeftArrow,
1294
- command: 'Problems.handleArrowLeft',
1295
- when: FocusProblems
1296
- }, {
1297
- key: KeyCode.RightArrow,
1298
- command: 'Problems.handleArrowRight',
1299
- when: FocusProblems
1300
- }];
1301
- };
1302
-
1303
1095
  const rpcs = Object.create(null);
1304
1096
  const set$g = (id, rpc) => {
1305
1097
  rpcs[id] = rpc;
1306
1098
  };
1307
- const get = id => {
1099
+ const get$1 = id => {
1308
1100
  return rpcs[id];
1309
1101
  };
1310
1102
 
1311
1103
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
1312
1104
 
1313
- const create = rpcId => {
1105
+ const create$1 = rpcId => {
1314
1106
  return {
1315
1107
  // @ts-ignore
1316
1108
  invoke(method, ...params) {
1317
- const rpc = get(rpcId);
1109
+ const rpc = get$1(rpcId);
1318
1110
  // @ts-ignore
1319
1111
  return rpc.invoke(method, ...params);
1320
1112
  },
1321
1113
  // @ts-ignore
1322
1114
  invokeAndTransfer(method, ...params) {
1323
- const rpc = get(rpcId);
1115
+ const rpc = get$1(rpcId);
1324
1116
  // @ts-ignore
1325
1117
  return rpc.invokeAndTransfer(method, ...params);
1326
1118
  },
@@ -1328,7 +1120,7 @@ const create = rpcId => {
1328
1120
  set$g(rpcId, rpc);
1329
1121
  },
1330
1122
  async dispose() {
1331
- const rpc = get(rpcId);
1123
+ const rpc = get$1(rpcId);
1332
1124
  await rpc.dispose();
1333
1125
  }
1334
1126
  };
@@ -1388,7 +1180,7 @@ const RpcId = {
1388
1180
  };
1389
1181
  const {
1390
1182
  invoke: invoke$9,
1391
- set: set$9} = create(ExtensionHostWorker);
1183
+ set: set$9} = create$1(ExtensionHostWorker);
1392
1184
  const ExtensionHost = {
1393
1185
  __proto__: null,
1394
1186
  invoke: invoke$9,
@@ -1399,7 +1191,7 @@ const {
1399
1191
  invokeAndTransfer: invokeAndTransfer$7,
1400
1192
  set: set$7,
1401
1193
  dispose: dispose$7
1402
- } = create(FileSystemWorker$1);
1194
+ } = create$1(FileSystemWorker$1);
1403
1195
  const remove = async dirent => {
1404
1196
  return invoke$7('FileSystem.remove', dirent);
1405
1197
  };
@@ -1475,7 +1267,7 @@ const FileSystemWorker = {
1475
1267
  const {
1476
1268
  invoke: invoke$3,
1477
1269
  invokeAndTransfer: invokeAndTransfer$3,
1478
- set: set$3} = create(RendererWorker$1);
1270
+ set: set$3$1} = create$1(RendererWorker$1);
1479
1271
  const sendMessagePortToFileSystemWorker$2 = async (port, rpcId) => {
1480
1272
  const command = 'FileSystem.handleMessagePort';
1481
1273
  // @ts-ignore
@@ -1494,14 +1286,21 @@ const RendererWorker = {
1494
1286
  invoke: invoke$3,
1495
1287
  sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
1496
1288
  sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
1497
- set: set$3};
1289
+ set: set$3$1};
1498
1290
 
1499
1291
  const {
1500
- set: set$2,
1292
+ set: set$3,
1501
1293
  readFile,
1502
1294
  writeFile
1503
1295
  } = FileSystemWorker;
1504
1296
 
1297
+ const filterItems = (items, filterValue) => {
1298
+ if (!filterValue) {
1299
+ return items;
1300
+ }
1301
+ return items.filter(item => item.includes(filterValue));
1302
+ };
1303
+
1505
1304
  const isFileNotFoundError = error => {
1506
1305
  return error.message.includes('File not found');
1507
1306
  };
@@ -1535,35 +1334,275 @@ const loadLines = async uri => {
1535
1334
  const clear = async state => {
1536
1335
  const {
1537
1336
  selectedOption,
1538
- options
1337
+ options,
1338
+ filterValue
1539
1339
  } = state;
1340
+ // TODO make uri a property of state to make the code simpler
1540
1341
  const option = options.find(option => option.id === selectedOption);
1541
1342
  if (!option) {
1542
1343
  return state;
1543
1344
  }
1544
- const {
1545
- uri
1546
- } = option;
1547
- await writeFile(uri, '');
1548
- const {
1549
- lines,
1550
- code,
1551
- error
1552
- } = await loadLines(uri);
1345
+ const {
1346
+ uri
1347
+ } = option;
1348
+ await writeFile(uri, '');
1349
+ const {
1350
+ lines,
1351
+ code,
1352
+ error
1353
+ } = await loadLines(uri);
1354
+ const filteredItems = filterItems(lines, filterValue);
1355
+ return {
1356
+ ...state,
1357
+ listItems: lines,
1358
+ error,
1359
+ errorCode: code,
1360
+ filteredItems
1361
+ };
1362
+ };
1363
+
1364
+ const closeFindWidget = async state => {
1365
+ // TODO
1366
+ return {
1367
+ ...state
1368
+ };
1369
+ };
1370
+
1371
+ const User = 1;
1372
+ const Script = 2;
1373
+
1374
+ const {
1375
+ get,
1376
+ set: set$2,
1377
+ wrapCommand,
1378
+ wrapGetter,
1379
+ getKeys
1380
+ } = create$2();
1381
+
1382
+ const create = (id, uri, x, y, width, height, platform, parentId) => {
1383
+ number(parentId);
1384
+ const state = {
1385
+ buttons: [],
1386
+ collapsedUris: [],
1387
+ error: '',
1388
+ errorCode: 0,
1389
+ filteredItems: [],
1390
+ filterValue: '',
1391
+ focusedIndex: -2,
1392
+ height,
1393
+ inputSource: User,
1394
+ itemHeight: 22,
1395
+ listItems: [],
1396
+ logLevel: 0,
1397
+ maxLineY: 0,
1398
+ message: '',
1399
+ minLineY: 0,
1400
+ options: [],
1401
+ parentId,
1402
+ platform,
1403
+ scrollLockEnabled: false,
1404
+ selectedOption: '',
1405
+ smallWidthBreakPoint: 650,
1406
+ uid: id,
1407
+ uri,
1408
+ watchId: 0,
1409
+ width,
1410
+ workspaceUri: '',
1411
+ x,
1412
+ y
1413
+ };
1414
+ set$2(id, state, state);
1415
+ };
1416
+
1417
+ const isEqual$2 = (oldState, newState) => {
1418
+ return newState.inputSource === User || oldState.filterValue === newState.filterValue;
1419
+ };
1420
+
1421
+ const isEqual$1 = (oldState, newState) => {
1422
+ return oldState.selectedOption === newState.selectedOption && oldState.listItems === newState.listItems && oldState.filteredItems === newState.filteredItems;
1423
+ };
1424
+
1425
+ const isEqual = (oldState, newState) => {
1426
+ return oldState.selectedOption === newState.selectedOption;
1427
+ };
1428
+
1429
+ const RenderItems = 1;
1430
+ const RenderFilterValue = 2;
1431
+ const RenderSelectedItem = 3;
1432
+
1433
+ const modules = [isEqual$1, isEqual$2, isEqual];
1434
+ const numbers = [RenderItems, RenderFilterValue, RenderSelectedItem];
1435
+
1436
+ const diff = (oldState, newState) => {
1437
+ const diffResult = [];
1438
+ for (let i = 0; i < modules.length; i++) {
1439
+ const fn = modules[i];
1440
+ if (!fn(oldState, newState)) {
1441
+ diffResult.push(numbers[i]);
1442
+ }
1443
+ }
1444
+ return diffResult;
1445
+ };
1446
+
1447
+ const diff2 = uid => {
1448
+ const {
1449
+ oldState,
1450
+ newState
1451
+ } = get(uid);
1452
+ const diffResult = diff(oldState, newState);
1453
+ return diffResult;
1454
+ };
1455
+
1456
+ const disableScrollLock = async state => {
1457
+ const {
1458
+ scrollLockEnabled
1459
+ } = state;
1460
+ if (!scrollLockEnabled) {
1461
+ return state;
1462
+ }
1463
+ return {
1464
+ ...state,
1465
+ scrollLockEnabled: false
1466
+ };
1467
+ };
1468
+
1469
+ const enableScrollLock = async state => {
1470
+ const {
1471
+ scrollLockEnabled
1472
+ } = state;
1473
+ if (scrollLockEnabled) {
1474
+ return state;
1475
+ }
1553
1476
  return {
1554
1477
  ...state,
1555
- listItems: lines,
1556
- error,
1557
- errorCode: code
1478
+ scrollLockEnabled: true
1479
+ };
1480
+ };
1481
+
1482
+ const focusIndex = (state, index) => {
1483
+ return {
1484
+ ...state,
1485
+ focusedIndex: index
1486
+ };
1487
+ };
1488
+
1489
+ const commandMapRef = {};
1490
+
1491
+ const toCommandId = key => {
1492
+ const dotIndex = key.indexOf('.');
1493
+ return key.slice(dotIndex + 1);
1494
+ };
1495
+ const getCommandIds = () => {
1496
+ const keys = Object.keys(commandMapRef);
1497
+ const ids = keys.map(toCommandId);
1498
+ return ids;
1499
+ };
1500
+
1501
+ const ToolBar = 'toolbar';
1502
+ const AriaRoles = {
1503
+ __proto__: null,
1504
+ ToolBar};
1505
+ const Space = 9;
1506
+ const PageUp = 10;
1507
+ const PageDown = 11;
1508
+ const End = 255;
1509
+ const Home = 12;
1510
+ const LeftArrow = 13;
1511
+ const UpArrow = 14;
1512
+ const RightArrow = 15;
1513
+ const DownArrow = 16;
1514
+ const KeyCode = {
1515
+ __proto__: null,
1516
+ DownArrow,
1517
+ End,
1518
+ Home,
1519
+ LeftArrow,
1520
+ PageDown,
1521
+ PageUp,
1522
+ RightArrow,
1523
+ Space,
1524
+ UpArrow
1525
+ };
1526
+ const mergeClassNames = (...classNames) => {
1527
+ return classNames.filter(Boolean).join(' ');
1528
+ };
1529
+ const Button = 1;
1530
+ const Div = 4;
1531
+ const Input = 6;
1532
+ const Text = 12;
1533
+ const Select$1 = 63;
1534
+ const Option$1 = 64;
1535
+ const VirtualDomElements = {
1536
+ __proto__: null,
1537
+ Button,
1538
+ Div,
1539
+ Input,
1540
+ Option: Option$1,
1541
+ Select: Select$1};
1542
+ const text = data => {
1543
+ return {
1544
+ type: Text,
1545
+ text: data,
1546
+ childCount: 0
1558
1547
  };
1559
1548
  };
1560
1549
 
1561
- const Filter = 'filter';
1562
- const Output$2 = 'output';
1550
+ const FocusProblems = 19;
1551
+
1552
+ const getKeyBindings = () => {
1553
+ return [{
1554
+ key: KeyCode.DownArrow,
1555
+ command: 'Problems.focusNext',
1556
+ when: FocusProblems
1557
+ }, {
1558
+ key: KeyCode.UpArrow,
1559
+ command: 'Problems.focusPrevious',
1560
+ when: FocusProblems
1561
+ }, {
1562
+ key: KeyCode.Home,
1563
+ command: 'Problems.focusFirst',
1564
+ when: FocusProblems
1565
+ }, {
1566
+ key: KeyCode.PageUp,
1567
+ command: 'Problems.focusFirst',
1568
+ when: FocusProblems
1569
+ }, {
1570
+ key: KeyCode.PageDown,
1571
+ command: 'Problems.focusLast',
1572
+ when: FocusProblems
1573
+ }, {
1574
+ key: KeyCode.End,
1575
+ command: 'Problems.focusLast',
1576
+ when: FocusProblems
1577
+ }, {
1578
+ key: KeyCode.Space,
1579
+ command: 'Problems.selectCurrent',
1580
+ when: FocusProblems
1581
+ }, {
1582
+ key: KeyCode.Home,
1583
+ command: 'Problems.focusFirst',
1584
+ when: FocusProblems
1585
+ }, {
1586
+ key: KeyCode.End,
1587
+ command: 'Problems.focusLast',
1588
+ when: FocusProblems
1589
+ }, {
1590
+ key: KeyCode.LeftArrow,
1591
+ command: 'Problems.handleArrowLeft',
1592
+ when: FocusProblems
1593
+ }, {
1594
+ key: KeyCode.RightArrow,
1595
+ command: 'Problems.handleArrowRight',
1596
+ when: FocusProblems
1597
+ }];
1598
+ };
1599
+
1600
+ const Filter$1 = 'filter';
1601
+ const Output$1 = 'output';
1563
1602
  const MainProcess = 'MainProcess';
1564
1603
  const SharedProcess = 'SharedProcess';
1565
1604
  const Clear = 'Clear';
1566
- const Settings = 'Settings';
1605
+ const Settings$1 = 'Settings';
1567
1606
  const ScrollLock = 'ScrollLock';
1568
1607
 
1569
1608
  const noop = async state => {
@@ -1583,6 +1622,11 @@ const handleButtonClick = async (state, name) => {
1583
1622
  return fn(state);
1584
1623
  };
1585
1624
 
1625
+ const handleContextMenu = async (state, x, y, button) => {
1626
+ // TODO open context menu
1627
+ return state;
1628
+ };
1629
+
1586
1630
  const handleData = async state => {
1587
1631
  // TODO
1588
1632
  return {
@@ -1597,13 +1641,6 @@ const handleError = async state => {
1597
1641
  };
1598
1642
  };
1599
1643
 
1600
- const filterItems = (items, filterValue) => {
1601
- if (!filterValue) {
1602
- return items;
1603
- }
1604
- return items.filter(item => item.includes(filterValue));
1605
- };
1606
-
1607
1644
  const handleFilterInput = async (state, value, inputSource = User) => {
1608
1645
  const {
1609
1646
  listItems
@@ -1633,7 +1670,7 @@ const {
1633
1670
  const handleFileChange = async watchId => {
1634
1671
  const keys = getKeys();
1635
1672
  for (const key of keys) {
1636
- const instance = get$1(key);
1673
+ const instance = get(key);
1637
1674
  if (instance.newState.watchId === watchId) {
1638
1675
  // @ts-ignore
1639
1676
  await invoke$1('Output.refresh');
@@ -1648,13 +1685,22 @@ const registerWatchCallback = (id, fn) => {
1648
1685
  const executeWatchCallBack = id => {
1649
1686
  watchCallbacks[id](id);
1650
1687
  };
1688
+ const unregisterWatchCallback = id => {
1689
+ delete watchCallbacks[id];
1690
+ };
1651
1691
 
1652
- const setupChangeListener = async (watchId, uri) => {
1692
+ const setupChangeListener = async (oldWatchId, newWatchId, uri) => {
1653
1693
  try {
1694
+ if (oldWatchId) {
1695
+ unregisterWatchCallback(oldWatchId);
1696
+ // @ts-ignore
1697
+ await FileSystemWorker.invoke('FileSystem.unwatchFile', oldWatchId);
1698
+ }
1699
+ // TODO dispose old watcher
1654
1700
  const rpcId = RpcId.OutputWorker;
1655
- registerWatchCallback(watchId, handleFileChange);
1701
+ registerWatchCallback(newWatchId, handleFileChange);
1656
1702
  // @ts-ignore
1657
- await FileSystemWorker.invoke(/* OutputChannel.open */'FileSystem.watchFile', watchId, /* path */uri, rpcId);
1703
+ await FileSystemWorker.invoke('FileSystem.watchFile', newWatchId, /* path */uri, rpcId);
1658
1704
  } catch {
1659
1705
  // ignore
1660
1706
  }
@@ -1663,7 +1709,8 @@ const setupChangeListener = async (watchId, uri) => {
1663
1709
  const selectChannel = async (state, id) => {
1664
1710
  const {
1665
1711
  options,
1666
- filterValue
1712
+ filterValue,
1713
+ watchId
1667
1714
  } = state;
1668
1715
  const matchingOption = options.find(option => option.id === id);
1669
1716
  if (!matchingOption) {
@@ -1677,8 +1724,8 @@ const selectChannel = async (state, id) => {
1677
1724
  } = await loadLines(matchingOption.uri);
1678
1725
 
1679
1726
  // TODO memory leak and race condition, need to dispose file watcher of previous uri
1680
- const watchId = createWatchId();
1681
- await setupChangeListener(watchId, matchingOption.uri);
1727
+ const newWatchId = createWatchId();
1728
+ await setupChangeListener(watchId, newWatchId, matchingOption.uri);
1682
1729
  const filteredItems = filterItems(lines, filterValue);
1683
1730
  return {
1684
1731
  ...state,
@@ -1687,7 +1734,7 @@ const selectChannel = async (state, id) => {
1687
1734
  listItems: lines,
1688
1735
  filteredItems,
1689
1736
  selectedOption: id,
1690
- watchId
1737
+ watchId: newWatchId
1691
1738
  };
1692
1739
  };
1693
1740
 
@@ -1738,7 +1785,7 @@ const createFileSystemWorkerRpc = async () => {
1738
1785
 
1739
1786
  const initializeFileSystemWorker = async () => {
1740
1787
  const rpc = await createFileSystemWorkerRpc();
1741
- set$2(rpc);
1788
+ set$3(rpc);
1742
1789
  };
1743
1790
 
1744
1791
  const initialize = async () => {
@@ -1747,26 +1794,59 @@ const initialize = async () => {
1747
1794
 
1748
1795
  const Web = 1;
1749
1796
 
1750
- const getSelectedItem = platform => {
1797
+ const getSelectedItem = (selectedOption, platform) => {
1798
+ if (selectedOption) {
1799
+ return selectedOption;
1800
+ }
1751
1801
  if (platform === Web) {
1752
1802
  return '';
1753
1803
  }
1754
1804
  return MainProcess;
1755
1805
  };
1756
1806
 
1807
+ const emptyObject = {};
1808
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1809
+ const i18nString = (key, placeholders = emptyObject) => {
1810
+ if (placeholders === emptyObject) {
1811
+ return key;
1812
+ }
1813
+ const replacer = (match, rest) => {
1814
+ return placeholders[rest];
1815
+ };
1816
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1817
+ };
1818
+
1819
+ const ClearOutput = 'clear output';
1820
+ const LogFileNotFound$1 = 'The log file was not found.';
1821
+ const Settings = 'Settings';
1822
+ const TurnOffAutoScroll = 'Turn auto scrolling off';
1823
+
1824
+ const clearOutput = () => {
1825
+ return i18nString(ClearOutput);
1826
+ };
1827
+ const turnOffAutoScroll = () => {
1828
+ return i18nString(TurnOffAutoScroll);
1829
+ };
1830
+ const settings = () => {
1831
+ return i18nString(Settings);
1832
+ };
1833
+ const logFileNotFound = () => {
1834
+ return i18nString(LogFileNotFound$1);
1835
+ };
1836
+
1757
1837
  const loadButtons = () => {
1758
1838
  return [{
1759
1839
  id: Clear,
1760
- label: 'Clear',
1840
+ label: clearOutput(),
1761
1841
  icon: 'MaskIconClearAll'
1762
1842
  }, {
1763
1843
  id: ScrollLock,
1764
- label: 'Scroll Lock',
1844
+ label: turnOffAutoScroll(),
1765
1845
  icon: 'MaskIconListFlat'
1766
1846
  }, {
1767
- id: Settings,
1768
- label: 'Settings',
1769
- icon: 'MaskIconListFlat'
1847
+ id: Settings$1,
1848
+ label: settings(),
1849
+ icon: 'MaskIconSettingsGear'
1770
1850
  }];
1771
1851
  };
1772
1852
 
@@ -1805,6 +1885,35 @@ const loadOptions = async platform => {
1805
1885
  }, ...extensionOptions];
1806
1886
  };
1807
1887
 
1888
+ const getSavedFilterValue = savedState => {
1889
+ if (savedState && typeof savedState.filterValue === 'string') {
1890
+ return savedState.filterValue;
1891
+ }
1892
+ return '';
1893
+ };
1894
+ const getSavedSelectedOption = savedState => {
1895
+ if (savedState && typeof savedState.selectedOption === 'string') {
1896
+ return savedState.selectedOption;
1897
+ }
1898
+ return '';
1899
+ };
1900
+ const getSavedScrollLockEnabled = savedState => {
1901
+ if (savedState && typeof savedState.scrollLockEnabled === 'boolean') {
1902
+ return savedState.scrollLockEnabled;
1903
+ }
1904
+ return false;
1905
+ };
1906
+ const restoreState = savedState => {
1907
+ const filterValue = getSavedFilterValue(savedState);
1908
+ const selectedOption = getSavedSelectedOption(savedState);
1909
+ const scrollLockEnabled = getSavedScrollLockEnabled(savedState);
1910
+ return {
1911
+ filterValue,
1912
+ selectedOption,
1913
+ scrollLockEnabled
1914
+ };
1915
+ };
1916
+
1808
1917
  const isString = value => {
1809
1918
  return typeof value === 'string';
1810
1919
  };
@@ -1819,10 +1928,16 @@ const getMatchingOpen = (options, id) => {
1819
1928
  };
1820
1929
  const loadContent = async (state, savedState) => {
1821
1930
  const {
1822
- platform
1931
+ platform,
1932
+ watchId
1823
1933
  } = state;
1824
1934
  const collapsedUris = getSavedCollapsedUris(savedState);
1825
- const selectedId = getSelectedItem(platform);
1935
+ const {
1936
+ selectedOption,
1937
+ filterValue,
1938
+ scrollLockEnabled
1939
+ } = restoreState(savedState);
1940
+ const selectedId = getSelectedItem(selectedOption, platform);
1826
1941
  const options = await loadOptions(platform);
1827
1942
  const option = getMatchingOpen(options, selectedId);
1828
1943
  if (!option) {
@@ -1836,21 +1951,24 @@ const loadContent = async (state, savedState) => {
1836
1951
  error,
1837
1952
  code
1838
1953
  } = await loadLines(uri);
1839
- const watchId = createWatchId();
1840
- await setupChangeListener(watchId, uri);
1954
+ const filteredItems = filterItems(lines, filterValue);
1955
+ const newWatchId = createWatchId();
1956
+ await setupChangeListener(watchId, newWatchId, uri);
1841
1957
  const buttons = loadButtons();
1842
1958
  return {
1843
1959
  ...state,
1960
+ buttons,
1844
1961
  collapsedUris,
1845
1962
  error,
1846
1963
  errorCode: code,
1964
+ filteredItems,
1965
+ filterValue,
1847
1966
  inputSource: Script,
1848
1967
  listItems: lines,
1849
- filteredItems: lines,
1850
1968
  options,
1969
+ scrollLockEnabled,
1851
1970
  selectedOption: selectedId,
1852
- buttons,
1853
- watchId
1971
+ watchId: newWatchId
1854
1972
  };
1855
1973
  };
1856
1974
 
@@ -1861,73 +1979,8 @@ const openFindWidget = async state => {
1861
1979
  };
1862
1980
  };
1863
1981
 
1864
- const Button = 1;
1865
- const Select$1 = 2;
1866
-
1867
- const Blank = 'Blank';
1868
- const ClearAll = 'ClearAll';
1869
-
1870
- const emptyObject = {};
1871
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1872
- const i18nString = (key, placeholders = emptyObject) => {
1873
- if (placeholders === emptyObject) {
1874
- return key;
1875
- }
1876
- const replacer = (match, rest) => {
1877
- return placeholders[rest];
1878
- };
1879
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1880
- };
1881
-
1882
- const Output$1 = 'output';
1883
- const ClearOutput = 'clear output';
1884
- const TurnOffAutoScroll = 'Turn auto scrolling off';
1885
- const OpenLogFile = 'open output log file';
1886
- const LogFileNotFound$1 = 'The log file was not found.';
1887
-
1888
- const output = () => {
1889
- return i18nString(Output$1);
1890
- };
1891
- const clearOutput = () => {
1892
- return i18nString(ClearOutput);
1893
- };
1894
- const turnOffAutoScroll = () => {
1895
- return i18nString(TurnOffAutoScroll);
1896
- };
1897
- const openLogFile = () => {
1898
- return i18nString(OpenLogFile);
1899
- };
1900
- const logFileNotFound = () => {
1901
- return i18nString(LogFileNotFound$1);
1902
- };
1903
-
1904
- const toSelectOption = option => {
1905
- return option.name;
1906
- };
1907
- const toSelectOptions = options => {
1908
- return options.map(toSelectOption);
1909
- };
1910
1982
  const getActions = state => {
1911
- const {
1912
- options
1913
- } = state;
1914
- return [{
1915
- type: Select$1,
1916
- id: output(),
1917
- options: toSelectOptions(options)
1918
- }, {
1919
- type: Button,
1920
- id: clearOutput(),
1921
- icon: ClearAll
1922
- }, {
1923
- type: Button,
1924
- id: turnOffAutoScroll(),
1925
- icon: Blank
1926
- }, {
1927
- type: Button,
1928
- id: openLogFile(),
1929
- icon: Blank
1930
- }];
1983
+ return [];
1931
1984
  };
1932
1985
 
1933
1986
  const refresh = async state => {
@@ -1956,20 +2009,27 @@ const refresh = async state => {
1956
2009
  };
1957
2010
 
1958
2011
  const renderFilterValue = (oldState, newState) => {
1959
- return ['Viewlet.setValueByName', newState.parentId, Filter, newState.filterValue];
2012
+ return ['Viewlet.setValueByName', newState.parentId, Filter$1, newState.filterValue];
1960
2013
  };
1961
2014
 
2015
+ const Filter = 'Filter';
1962
2016
  const IconButton = 'IconButton';
2017
+ const InputBox = 'InputBox';
1963
2018
  const MaskIcon = 'MaskIcon';
2019
+ const FilterInput = 'FilterInput';
2020
+ const OutputContent = 'OutputContent';
1964
2021
  const Actions = 'Actions';
2022
+ const Message = 'Message';
1965
2023
  const Viewlet = 'Viewlet';
1966
2024
  const Output = 'Output';
1967
2025
  const Option = 'Option';
1968
2026
  const Select = 'Select';
2027
+ const Error$1 = 'Error';
2028
+ const Line = 'Line';
1969
2029
 
1970
2030
  const parentNode = {
1971
2031
  type: VirtualDomElements.Div,
1972
- className: 'Line',
2032
+ className: Line,
1973
2033
  childCount: 1
1974
2034
  };
1975
2035
  const getLineDom = line => {
@@ -1982,7 +2042,7 @@ const getContentDom = (lines, error) => {
1982
2042
  }
1983
2043
  return [{
1984
2044
  type: VirtualDomElements.Div,
1985
- className: 'OutputContent',
2045
+ className: OutputContent,
1986
2046
  role: 'log',
1987
2047
  tabIndex: 0,
1988
2048
  childCount: lines.length
@@ -1994,7 +2054,7 @@ const LogFileNotFound = 1;
1994
2054
  const getLogFileNotFoundDom = () => {
1995
2055
  return [{
1996
2056
  type: VirtualDomElements.Div,
1997
- className: 'Message',
2057
+ className: Message,
1998
2058
  tabIndex: 0,
1999
2059
  childCount: 1
2000
2060
  }, text(logFileNotFound())];
@@ -2009,7 +2069,7 @@ const getErrorDom = (errorCode, error) => {
2009
2069
  }
2010
2070
  return [{
2011
2071
  type: VirtualDomElements.Div,
2012
- className: 'Error',
2072
+ className: Error$1,
2013
2073
  tabIndex: 0,
2014
2074
  childCount: 1
2015
2075
  }, text(error)];
@@ -2030,7 +2090,7 @@ const renderItems = (oldState, newState) => {
2030
2090
 
2031
2091
  const renderSelectedItem = (oldState, newState) => {
2032
2092
  const value = newState.selectedOption;
2033
- const name = Output$2;
2093
+ const name = Output$1;
2034
2094
  return ['Viewlet.setValueByName', newState.parentId, name, value];
2035
2095
  };
2036
2096
 
@@ -2060,8 +2120,8 @@ const render2 = (uid, diffResult) => {
2060
2120
  const {
2061
2121
  oldState,
2062
2122
  newState
2063
- } = get$1(uid);
2064
- set$4(uid, newState, newState);
2123
+ } = get(uid);
2124
+ set$2(uid, newState, newState);
2065
2125
  const commands = applyRender(oldState, newState, diffResult);
2066
2126
  return commands;
2067
2127
  };
@@ -2101,15 +2161,15 @@ const getFilterVirtualDom = () => {
2101
2161
  const placeholder = 'Filter';
2102
2162
  return [{
2103
2163
  type: VirtualDomElements.Div,
2104
- className: 'Filter',
2164
+ className: Filter,
2105
2165
  childCount: 1
2106
2166
  }, {
2107
2167
  type: VirtualDomElements.Input,
2108
- className: 'InputBox FilterInput',
2168
+ className: mergeClassNames(InputBox, FilterInput),
2109
2169
  childCount: 0,
2110
2170
  placeholder,
2111
2171
  onInput: HandleFilterInput,
2112
- name: Filter
2172
+ name: Filter$1
2113
2173
  }];
2114
2174
  };
2115
2175
 
@@ -2131,7 +2191,7 @@ const getSelectVirtualDom = options => {
2131
2191
  type: VirtualDomElements.Select,
2132
2192
  className: Select,
2133
2193
  childCount: options.length,
2134
- name: Output$2,
2194
+ name: Output$1,
2135
2195
  onChange: HandleSelect
2136
2196
  }, ...options.flatMap(getOptionVirtualDom)];
2137
2197
  };
@@ -2194,14 +2254,32 @@ const resize = (state, dimensions) => {
2194
2254
  };
2195
2255
  };
2196
2256
 
2257
+ const saveOutputAs = async state => {
2258
+ // TODO show open file picker
2259
+ // TODO write to file
2260
+ // TODO if error occurs, show error dialog
2261
+ return state;
2262
+ };
2263
+
2197
2264
  const saveState = state => {
2198
2265
  const {
2199
2266
  filterValue,
2200
- collapsedUris
2267
+ collapsedUris,
2268
+ selectedOption,
2269
+ scrollLockEnabled
2201
2270
  } = state;
2202
2271
  return {
2203
2272
  filterValue,
2204
- collapsedUris
2273
+ collapsedUris,
2274
+ selectedOption,
2275
+ scrollLockEnabled
2276
+ };
2277
+ };
2278
+
2279
+ const setLogLevel = async (state, logLevel) => {
2280
+ return {
2281
+ ...state,
2282
+ logLevel
2205
2283
  };
2206
2284
  };
2207
2285
 
@@ -2213,31 +2291,37 @@ const setOutputChannel = async state => {
2213
2291
  };
2214
2292
 
2215
2293
  const commandMap = {
2294
+ 'Output.clear': wrapCommand(clear),
2216
2295
  'Output.closeFindWidget': wrapCommand(closeFindWidget),
2217
- 'Output.create': create$1,
2296
+ 'Output.create': create,
2218
2297
  'Output.diff2': diff2,
2298
+ 'Output.disableScrollLock': wrapCommand(disableScrollLock),
2299
+ 'Output.enableScrollLock': wrapCommand(enableScrollLock),
2219
2300
  'Output.executeWatchCallback': executeWatchCallBack,
2220
2301
  'Output.focusIndex': wrapCommand(focusIndex),
2221
2302
  'Output.getActions': getActions,
2222
2303
  'Output.getCommandIds': getCommandIds,
2223
2304
  'Output.getKeyBindings': getKeyBindings,
2224
2305
  'Output.handleButtonClick': wrapCommand(handleButtonClick),
2306
+ 'Output.handleContextMenu': wrapCommand(handleContextMenu),
2225
2307
  'Output.handleData': wrapCommand(handleData),
2226
2308
  'Output.handleError': wrapCommand(handleError),
2227
- 'Output.selectChannel': wrapCommand(selectChannel),
2228
2309
  'Output.handleFilterInput': wrapCommand(handleFilterInput),
2229
2310
  'Output.handleSelect': wrapCommand(handleSelect),
2230
2311
  'Output.initialize': initialize,
2231
2312
  'Output.loadContent2': wrapCommand(loadContent),
2232
2313
  'Output.openFindWidget': wrapCommand(openFindWidget),
2314
+ 'Output.refresh': wrapCommand(refresh),
2233
2315
  'Output.render2': render2,
2234
2316
  'Output.renderActions': wrapGetter(renderActions),
2235
2317
  'Output.renderEventListeners': renderEventListeners,
2236
2318
  'Output.resize': resize,
2237
- 'Output.saveState': saveState,
2319
+ 'Output.saveOutputAs': wrapCommand(saveOutputAs),
2320
+ 'Output.saveState': wrapGetter(saveState),
2321
+ 'Output.selectChannel': wrapCommand(selectChannel),
2322
+ 'Output.setLogLevel': setLogLevel,
2238
2323
  'Output.setOutputChannel': wrapCommand(setOutputChannel),
2239
- 'Output.terminate': terminate,
2240
- 'Output.refresh': wrapCommand(refresh)
2324
+ 'Output.terminate': terminate
2241
2325
  };
2242
2326
 
2243
2327
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",