@lvce-editor/output-view 2.17.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.
@@ -1117,7 +1117,7 @@ const createMockRpc = ({
1117
1117
  };
1118
1118
 
1119
1119
  const rpcs = Object.create(null);
1120
- const set$4 = (id, rpc) => {
1120
+ const set$6 = (id, rpc) => {
1121
1121
  rpcs[id] = rpc;
1122
1122
  };
1123
1123
  const get$1 = id => {
@@ -1150,7 +1150,7 @@ const create$2 = rpcId => {
1150
1150
  const mockRpc = createMockRpc({
1151
1151
  commandMap
1152
1152
  });
1153
- set$4(rpcId, mockRpc);
1153
+ set$6(rpcId, mockRpc);
1154
1154
  // @ts-ignore
1155
1155
  mockRpc[Symbol.dispose] = () => {
1156
1156
  remove(rpcId);
@@ -1159,7 +1159,7 @@ const create$2 = rpcId => {
1159
1159
  return mockRpc;
1160
1160
  },
1161
1161
  set(rpc) {
1162
- set$4(rpcId, rpc);
1162
+ set$6(rpcId, rpc);
1163
1163
  }
1164
1164
  };
1165
1165
  };
@@ -1167,34 +1167,40 @@ const create$2 = rpcId => {
1167
1167
  const ExtensionManagementWorker = 9006;
1168
1168
  const FileSystemWorker = 209;
1169
1169
  const OutputWorker = 7001;
1170
+ const RendererProcess = 1670;
1170
1171
  const RendererWorker = 1;
1171
1172
 
1172
1173
  const {
1173
- invoke: invoke$2,
1174
- set: set$3
1174
+ invoke: invoke$4,
1175
+ set: set$5
1175
1176
  } = create$2(ExtensionManagementWorker);
1176
1177
 
1177
1178
  const {
1178
- invoke: invoke$1,
1179
- set: set$2
1179
+ invoke: invoke$3,
1180
+ set: set$4
1180
1181
  } = create$2(FileSystemWorker);
1181
1182
  const readFile = async uri => {
1182
- return invoke$1('FileSystem.readFile', uri);
1183
+ return invoke$3('FileSystem.readFile', uri);
1183
1184
  };
1184
1185
  const writeFile = async (uri, content) => {
1185
- return invoke$1('FileSystem.writeFile', uri, content);
1186
+ return invoke$3('FileSystem.writeFile', uri, content);
1186
1187
  };
1187
1188
  const watchFile = async (watchId, uri, rpcId) => {
1188
- await invoke$1('FileSystem.watchFile', watchId, uri, rpcId);
1189
+ await invoke$3('FileSystem.watchFile', watchId, uri, rpcId);
1189
1190
  };
1190
1191
  const unwatchFile = async watchId => {
1191
- await invoke$1('FileSystem.unwatchFile', watchId);
1192
+ await invoke$3('FileSystem.unwatchFile', watchId);
1192
1193
  };
1193
1194
 
1194
1195
  const {
1195
- invoke,
1196
+ invoke: invoke$2,
1197
+ set: set$3
1198
+ } = create$2(RendererProcess);
1199
+
1200
+ const {
1201
+ invoke: invoke$1,
1196
1202
  invokeAndTransfer,
1197
- set: set$1
1203
+ set: set$2
1198
1204
  } = create$2(RendererWorker);
1199
1205
  const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
1200
1206
  const command = 'FileSystem.handleMessagePort';
@@ -1205,10 +1211,10 @@ const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
1205
1211
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
1206
1212
  };
1207
1213
  const showSaveFilePicker = async () => {
1208
- return invoke('FilePicker.showSaveFilePicker');
1214
+ return invoke$1('FilePicker.showSaveFilePicker');
1209
1215
  };
1210
1216
  const getLogsDir$1 = async () => {
1211
- return invoke('PlatformPaths.getLogsDir');
1217
+ return invoke$1('PlatformPaths.getLogsDir');
1212
1218
  };
1213
1219
 
1214
1220
  const toCommandId = key => {
@@ -1429,20 +1435,30 @@ const parseStructuredLogLine = line => {
1429
1435
  }, {
1430
1436
  className: OutputSourceLink,
1431
1437
  label: getSourceLabel(parsed.source, parsed.line),
1438
+ lineNumber: parsed.line,
1432
1439
  type: Link,
1433
1440
  value: parsed.source
1434
1441
  }];
1435
1442
  };
1436
1443
 
1437
1444
  const RE_SOURCE_LINK = /^lvce(?:-oss)?:\/\//;
1438
- const RE_SOURCE_LOCATION = /:\d+(?::\d+)?$/;
1445
+ const RE_SOURCE_LOCATION = /:(\d+)(?::(\d+))?$/;
1439
1446
  const getLinkPart = match => {
1440
1447
  if (RE_SOURCE_LINK.test(match)) {
1448
+ const locationMatch = match.match(RE_SOURCE_LOCATION);
1449
+ const lineNumber = locationMatch ? Number(locationMatch[1]) : undefined;
1450
+ const columnNumber = locationMatch?.[2] ? Number(locationMatch[2]) : undefined;
1441
1451
  return {
1442
1452
  className: OutputSourceLink,
1453
+ ...(columnNumber !== undefined && {
1454
+ columnNumber
1455
+ }),
1443
1456
  label: match,
1457
+ ...(lineNumber !== undefined && {
1458
+ lineNumber
1459
+ }),
1444
1460
  type: Link,
1445
- value: match.replace(RE_SOURCE_LOCATION, '')
1461
+ value: locationMatch ? match.slice(0, -locationMatch[0].length) : match
1446
1462
  };
1447
1463
  }
1448
1464
  return {
@@ -1489,7 +1505,7 @@ const parseLine = line => {
1489
1505
 
1490
1506
  const readOutput = async uri => {
1491
1507
  if (isExtensionOutputUri(uri)) {
1492
- return invoke$2('Extensions.readOutputChannel', uri);
1508
+ return invoke$4('Extensions.readOutputChannel', uri);
1493
1509
  }
1494
1510
  return readFile(uri);
1495
1511
  };
@@ -1520,7 +1536,7 @@ const loadLines = async uri => {
1520
1536
 
1521
1537
  const clearOutput$1 = async uri => {
1522
1538
  if (isExtensionOutputUri(uri)) {
1523
- await invoke$2('Extensions.clearOutputChannel', uri);
1539
+ await invoke$4('Extensions.clearOutputChannel', uri);
1524
1540
  return;
1525
1541
  }
1526
1542
  await writeFile(uri, '');
@@ -1570,7 +1586,7 @@ const {
1570
1586
  getCommandIds,
1571
1587
  getKeys,
1572
1588
  registerCommands,
1573
- set,
1589
+ set: set$1,
1574
1590
  wrapCommand,
1575
1591
  wrapGetter
1576
1592
  } = create$1();
@@ -1607,7 +1623,7 @@ const create = (id, uri, x, y, width, height, platform, parentId) => {
1607
1623
  x,
1608
1624
  y
1609
1625
  };
1610
- set(id, state, state);
1626
+ set$1(id, state, state);
1611
1627
  };
1612
1628
 
1613
1629
  const isEqual$2 = (oldState, newState) => {
@@ -1824,6 +1840,31 @@ const handleFilterInput = async (state, value, inputSource = User) => {
1824
1840
  };
1825
1841
  };
1826
1842
 
1843
+ const state = {
1844
+ connected: false
1845
+ };
1846
+ const isConnected = () => {
1847
+ const {
1848
+ connected
1849
+ } = state;
1850
+ return connected;
1851
+ };
1852
+ const invoke = (method, ...params) => {
1853
+ return invoke$2(method, ...params);
1854
+ };
1855
+ const set = rpc => {
1856
+ set$3(rpc);
1857
+ state.connected = true;
1858
+ };
1859
+
1860
+ const handleMessagePort = async port => {
1861
+ const rpc = await create$6({
1862
+ commandMap: {},
1863
+ messagePort: port
1864
+ });
1865
+ set(rpc);
1866
+ };
1867
+
1827
1868
  const createWatchId = () => {
1828
1869
  const watchId = Math.random();
1829
1870
  return watchId;
@@ -1835,7 +1876,7 @@ const handleFileChange = async watchId => {
1835
1876
  const instance = get(key);
1836
1877
  if (instance.newState.watchId === watchId) {
1837
1878
  // @ts-ignore
1838
- await invoke('Output.refresh');
1879
+ await invoke$1('Output.refresh');
1839
1880
  }
1840
1881
  }
1841
1882
  };
@@ -1904,11 +1945,21 @@ const handleSelect = async (state, id) => {
1904
1945
  return selectChannel(state, id);
1905
1946
  };
1906
1947
 
1907
- const handleSourceLinkClick = async (state, uri) => {
1948
+ const handleSourceLinkClick = async (state, uri, lineNumber, columnNumber) => {
1908
1949
  if (!uri) {
1909
1950
  return state;
1910
1951
  }
1911
- await invoke('Main.openUri', uri);
1952
+ const line = Number(lineNumber);
1953
+ if (!Number.isSafeInteger(line) || line <= 0) {
1954
+ await invoke$1('Main.openUri', uri);
1955
+ return state;
1956
+ }
1957
+ const column = Number(columnNumber);
1958
+ const rowIndex = line - 1;
1959
+ const columnIndex = Number.isSafeInteger(column) && column > 0 ? column - 1 : 0;
1960
+ await invoke$1('Main.openUri', uri, true, {
1961
+ selections: new Uint32Array([rowIndex, columnIndex, rowIndex, columnIndex])
1962
+ });
1912
1963
  return state;
1913
1964
  };
1914
1965
 
@@ -1922,7 +1973,7 @@ const createExtensionManagementWorkerRpc = async () => {
1922
1973
 
1923
1974
  const initializeExtensionManagementWorker = async () => {
1924
1975
  const rpc = await createExtensionManagementWorkerRpc();
1925
- set$3(rpc);
1976
+ set$5(rpc);
1926
1977
  };
1927
1978
 
1928
1979
  const sendMessagePortToFileSystemWorker = async port => {
@@ -1943,7 +1994,7 @@ const createFileSystemWorkerRpc = async () => {
1943
1994
 
1944
1995
  const initializeFileSystemWorker = async () => {
1945
1996
  const rpc = await createFileSystemWorkerRpc();
1946
- set$2(rpc);
1997
+ set$4(rpc);
1947
1998
  };
1948
1999
 
1949
2000
  const initialize = async () => {
@@ -2018,7 +2069,7 @@ const error = error => {
2018
2069
 
2019
2070
  const getExtensionOptions = async () => {
2020
2071
  try {
2021
- const channels = await invoke$2('Extensions.getOutputChannelProviders');
2072
+ const channels = await invoke$4('Extensions.getOutputChannelProviders');
2022
2073
  return channels;
2023
2074
  } catch (error$1) {
2024
2075
  error(error$1);
@@ -2215,6 +2266,12 @@ const getLinePartDom = part => {
2215
2266
  ...(part.className && {
2216
2267
  className: part.className
2217
2268
  }),
2269
+ ...(part.columnNumber !== undefined && {
2270
+ 'data-column': part.columnNumber
2271
+ }),
2272
+ ...(part.lineNumber !== undefined && {
2273
+ 'data-line': part.lineNumber
2274
+ }),
2218
2275
  ...(isSourceLink && {
2219
2276
  onClick: HandleSourceLinkClick
2220
2277
  })
@@ -2344,14 +2401,23 @@ const applyRender = (oldState, newState, diffResult) => {
2344
2401
  return commands;
2345
2402
  };
2346
2403
 
2404
+ const renderDirect = async (uid, commands) => {
2405
+ const rendererWorkerCommands = commands.filter(command => command[0] === 'Viewlet.setFocusContext');
2406
+ const rendererProcessCommands = commands.filter(command => command[0] !== 'Viewlet.setFocusContext');
2407
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
2408
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
2409
+ };
2347
2410
  const render2 = (uid, diffResult) => {
2348
2411
  const {
2349
2412
  newState,
2350
2413
  oldState
2351
2414
  } = get(uid);
2352
- set(uid, newState, newState);
2415
+ set$1(uid, newState, newState);
2353
2416
  const commands = applyRender(oldState, newState, diffResult);
2354
- return commands;
2417
+ if (!isConnected()) {
2418
+ return commands;
2419
+ }
2420
+ return renderDirect(uid, commands);
2355
2421
  };
2356
2422
 
2357
2423
  const getActionButtonVirtualDom = button => {
@@ -2464,7 +2530,7 @@ const renderEventListeners = () => {
2464
2530
  params: ['clearFilter']
2465
2531
  }, {
2466
2532
  name: HandleSourceLinkClick,
2467
- params: ['handleSourceLinkClick', 'event.target.href'],
2533
+ params: ['handleSourceLinkClick', 'event.target.href', 'event.target.dataset.line', 'event.target.dataset.column'],
2468
2534
  preventDefault: true
2469
2535
  }, {
2470
2536
  name: HandlePointerDown,
@@ -2552,6 +2618,7 @@ const commandMap = {
2552
2618
  'Output.handleData': wrapCommand(handleData),
2553
2619
  'Output.handleError': wrapCommand(handleError),
2554
2620
  'Output.handleFilterInput': wrapCommand(handleFilterInput),
2621
+ 'Output.handleMessagePort': handleMessagePort,
2555
2622
  'Output.handleSelect': wrapCommand(handleSelect),
2556
2623
  'Output.handleSourceLinkClick': wrapCommand(handleSourceLinkClick),
2557
2624
  'Output.initialize': initialize,
@@ -2578,7 +2645,7 @@ const listen = async () => {
2578
2645
  const rpc = await create$3({
2579
2646
  commandMap: commandMapRef
2580
2647
  });
2581
- set$1(rpc);
2648
+ set$2(rpc);
2582
2649
  };
2583
2650
 
2584
2651
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",