@lvce-editor/output-view 1.14.0 → 1.15.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,72 +1286,319 @@ 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
 
1505
- const isFileNotFoundError = error => {
1506
- return error.message.includes('File not found');
1297
+ const filterItems = (items, filterValue) => {
1298
+ if (!filterValue) {
1299
+ return items;
1300
+ }
1301
+ return items.filter(item => item.includes(filterValue));
1302
+ };
1303
+
1304
+ const isFileNotFoundError = error => {
1305
+ return error.message.includes('File not found');
1306
+ };
1307
+
1308
+ const loadLines = async uri => {
1309
+ try {
1310
+ // TODO use log stream, updating the output when the file is changed
1311
+ const content = await readFile(uri);
1312
+ const lines = content.split('\n');
1313
+ return {
1314
+ error: '',
1315
+ lines,
1316
+ code: 0
1317
+ };
1318
+ } catch (error) {
1319
+ if (isFileNotFoundError(error)) {
1320
+ return {
1321
+ error: `log file not found`,
1322
+ lines: [],
1323
+ code: 1
1324
+ };
1325
+ }
1326
+ return {
1327
+ error: `${error}`,
1328
+ lines: [],
1329
+ code: 2
1330
+ };
1331
+ }
1332
+ };
1333
+
1334
+ const clear = async state => {
1335
+ const {
1336
+ selectedOption,
1337
+ options,
1338
+ filterValue
1339
+ } = state;
1340
+ // TODO make uri a property of state to make the code simpler
1341
+ const option = options.find(option => option.id === selectedOption);
1342
+ if (!option) {
1343
+ return state;
1344
+ }
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;
1507
1454
  };
1508
1455
 
1509
- const loadLines = async uri => {
1510
- try {
1511
- // TODO use log stream, updating the output when the file is changed
1512
- const content = await readFile(uri);
1513
- const lines = content.split('\n');
1514
- return {
1515
- error: '',
1516
- lines,
1517
- code: 0
1518
- };
1519
- } catch (error) {
1520
- if (isFileNotFoundError(error)) {
1521
- return {
1522
- error: `log file not found`,
1523
- lines: [],
1524
- code: 1
1525
- };
1526
- }
1527
- return {
1528
- error: `${error}`,
1529
- lines: [],
1530
- code: 2
1531
- };
1456
+ const disableScrollLock = async state => {
1457
+ const {
1458
+ scrollLockEnabled
1459
+ } = state;
1460
+ if (!scrollLockEnabled) {
1461
+ return state;
1532
1462
  }
1463
+ return {
1464
+ ...state,
1465
+ scrollLockEnabled: false
1466
+ };
1533
1467
  };
1534
1468
 
1535
- const clear = async state => {
1469
+ const enableScrollLock = async state => {
1536
1470
  const {
1537
- selectedOption,
1538
- options
1471
+ scrollLockEnabled
1539
1472
  } = state;
1540
- const option = options.find(option => option.id === selectedOption);
1541
- if (!option) {
1473
+ if (scrollLockEnabled) {
1542
1474
  return state;
1543
1475
  }
1544
- const {
1545
- uri
1546
- } = option;
1547
- await writeFile(uri, '');
1548
- const {
1549
- lines,
1550
- code,
1551
- error
1552
- } = await loadLines(uri);
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
 
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
+
1561
1600
  const Filter = 'filter';
1562
- const Output$2 = 'output';
1601
+ const Output$1 = 'output';
1563
1602
  const MainProcess = 'MainProcess';
1564
1603
  const SharedProcess = 'SharedProcess';
1565
1604
  const Clear = 'Clear';
@@ -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 () => {
@@ -1766,7 +1813,7 @@ const loadButtons = () => {
1766
1813
  }, {
1767
1814
  id: Settings,
1768
1815
  label: 'Settings',
1769
- icon: 'MaskIconListFlat'
1816
+ icon: 'MaskIconSettingsGear'
1770
1817
  }];
1771
1818
  };
1772
1819
 
@@ -1819,7 +1866,8 @@ const getMatchingOpen = (options, id) => {
1819
1866
  };
1820
1867
  const loadContent = async (state, savedState) => {
1821
1868
  const {
1822
- platform
1869
+ platform,
1870
+ watchId
1823
1871
  } = state;
1824
1872
  const collapsedUris = getSavedCollapsedUris(savedState);
1825
1873
  const selectedId = getSelectedItem(platform);
@@ -1836,8 +1884,8 @@ const loadContent = async (state, savedState) => {
1836
1884
  error,
1837
1885
  code
1838
1886
  } = await loadLines(uri);
1839
- const watchId = createWatchId();
1840
- await setupChangeListener(watchId, uri);
1887
+ const newWatchId = createWatchId();
1888
+ await setupChangeListener(watchId, newWatchId, uri);
1841
1889
  const buttons = loadButtons();
1842
1890
  return {
1843
1891
  ...state,
@@ -1850,7 +1898,7 @@ const loadContent = async (state, savedState) => {
1850
1898
  options,
1851
1899
  selectedOption: selectedId,
1852
1900
  buttons,
1853
- watchId
1901
+ watchId: newWatchId
1854
1902
  };
1855
1903
  };
1856
1904
 
@@ -1861,73 +1909,8 @@ const openFindWidget = async state => {
1861
1909
  };
1862
1910
  };
1863
1911
 
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
1912
  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
- }];
1913
+ return [];
1931
1914
  };
1932
1915
 
1933
1916
  const refresh = async state => {
@@ -1989,7 +1972,25 @@ const getContentDom = (lines, error) => {
1989
1972
  }, ...lines.flatMap(getLineDom)];
1990
1973
  };
1991
1974
 
1992
- const LogFileNotFound = 1;
1975
+ const LogFileNotFound$1 = 1;
1976
+
1977
+ const emptyObject = {};
1978
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1979
+ const i18nString = (key, placeholders = emptyObject) => {
1980
+ if (placeholders === emptyObject) {
1981
+ return key;
1982
+ }
1983
+ const replacer = (match, rest) => {
1984
+ return placeholders[rest];
1985
+ };
1986
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1987
+ };
1988
+
1989
+ const LogFileNotFound = 'The log file was not found.';
1990
+
1991
+ const logFileNotFound = () => {
1992
+ return i18nString(LogFileNotFound);
1993
+ };
1993
1994
 
1994
1995
  const getLogFileNotFoundDom = () => {
1995
1996
  return [{
@@ -2004,7 +2005,7 @@ const getErrorDom = (errorCode, error) => {
2004
2005
  if (!error) {
2005
2006
  return [];
2006
2007
  }
2007
- if (errorCode === LogFileNotFound) {
2008
+ if (errorCode === LogFileNotFound$1) {
2008
2009
  return getLogFileNotFoundDom();
2009
2010
  }
2010
2011
  return [{
@@ -2030,7 +2031,7 @@ const renderItems = (oldState, newState) => {
2030
2031
 
2031
2032
  const renderSelectedItem = (oldState, newState) => {
2032
2033
  const value = newState.selectedOption;
2033
- const name = Output$2;
2034
+ const name = Output$1;
2034
2035
  return ['Viewlet.setValueByName', newState.parentId, name, value];
2035
2036
  };
2036
2037
 
@@ -2060,8 +2061,8 @@ const render2 = (uid, diffResult) => {
2060
2061
  const {
2061
2062
  oldState,
2062
2063
  newState
2063
- } = get$1(uid);
2064
- set$4(uid, newState, newState);
2064
+ } = get(uid);
2065
+ set$2(uid, newState, newState);
2065
2066
  const commands = applyRender(oldState, newState, diffResult);
2066
2067
  return commands;
2067
2068
  };
@@ -2131,7 +2132,7 @@ const getSelectVirtualDom = options => {
2131
2132
  type: VirtualDomElements.Select,
2132
2133
  className: Select,
2133
2134
  childCount: options.length,
2134
- name: Output$2,
2135
+ name: Output$1,
2135
2136
  onChange: HandleSelect
2136
2137
  }, ...options.flatMap(getOptionVirtualDom)];
2137
2138
  };
@@ -2194,14 +2195,30 @@ const resize = (state, dimensions) => {
2194
2195
  };
2195
2196
  };
2196
2197
 
2198
+ const saveOutputAs = async state => {
2199
+ // TODO show open file picker
2200
+ // TODO write to file
2201
+ // TODO if error occurs, show error dialog
2202
+ return state;
2203
+ };
2204
+
2197
2205
  const saveState = state => {
2198
2206
  const {
2199
2207
  filterValue,
2200
- collapsedUris
2208
+ collapsedUris,
2209
+ selectedOption
2201
2210
  } = state;
2202
2211
  return {
2203
2212
  filterValue,
2204
- collapsedUris
2213
+ collapsedUris,
2214
+ selectedOption
2215
+ };
2216
+ };
2217
+
2218
+ const setLogLevel = async (state, logLevel) => {
2219
+ return {
2220
+ ...state,
2221
+ logLevel
2205
2222
  };
2206
2223
  };
2207
2224
 
@@ -2213,31 +2230,37 @@ const setOutputChannel = async state => {
2213
2230
  };
2214
2231
 
2215
2232
  const commandMap = {
2233
+ 'Output.clear': wrapCommand(clear),
2216
2234
  'Output.closeFindWidget': wrapCommand(closeFindWidget),
2217
- 'Output.create': create$1,
2235
+ 'Output.create': create,
2218
2236
  'Output.diff2': diff2,
2237
+ 'Output.disableScrollLock': wrapCommand(disableScrollLock),
2238
+ 'Output.enableScrollLock': wrapCommand(enableScrollLock),
2219
2239
  'Output.executeWatchCallback': executeWatchCallBack,
2220
2240
  'Output.focusIndex': wrapCommand(focusIndex),
2221
2241
  'Output.getActions': getActions,
2222
2242
  'Output.getCommandIds': getCommandIds,
2223
2243
  'Output.getKeyBindings': getKeyBindings,
2224
2244
  'Output.handleButtonClick': wrapCommand(handleButtonClick),
2245
+ 'Output.handleContextMenu': wrapCommand(handleContextMenu),
2225
2246
  'Output.handleData': wrapCommand(handleData),
2226
2247
  'Output.handleError': wrapCommand(handleError),
2227
- 'Output.selectChannel': wrapCommand(selectChannel),
2228
2248
  'Output.handleFilterInput': wrapCommand(handleFilterInput),
2229
2249
  'Output.handleSelect': wrapCommand(handleSelect),
2230
2250
  'Output.initialize': initialize,
2231
2251
  'Output.loadContent2': wrapCommand(loadContent),
2232
2252
  'Output.openFindWidget': wrapCommand(openFindWidget),
2253
+ 'Output.refresh': wrapCommand(refresh),
2233
2254
  'Output.render2': render2,
2234
2255
  'Output.renderActions': wrapGetter(renderActions),
2235
2256
  'Output.renderEventListeners': renderEventListeners,
2236
2257
  'Output.resize': resize,
2258
+ 'Output.saveOutputAs': wrapCommand(saveOutputAs),
2237
2259
  'Output.saveState': saveState,
2260
+ 'Output.selectChannel': wrapCommand(selectChannel),
2261
+ 'Output.setLogLevel': setLogLevel,
2238
2262
  'Output.setOutputChannel': wrapCommand(setOutputChannel),
2239
- 'Output.terminate': terminate,
2240
- 'Output.refresh': wrapCommand(refresh)
2263
+ 'Output.terminate': terminate
2241
2264
  };
2242
2265
 
2243
2266
  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.15.0",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",