@lvce-editor/output-view 2.12.0 → 2.13.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.
@@ -1298,12 +1298,6 @@ const isFileNotFoundError = error => {
1298
1298
  return error?.message?.includes('File not found') ?? false;
1299
1299
  };
1300
1300
 
1301
- const RE_URL = /(?:https?:\/\/\S+|file:\/\/\S+)/;
1302
- const getLinkMatch = text => {
1303
- const match = text.match(RE_URL);
1304
- return match ? match[0] : null;
1305
- };
1306
-
1307
1301
  const Filter$2 = 'Filter';
1308
1302
  const IconButton = 'IconButton';
1309
1303
  const InputBox = 'InputBox';
@@ -1321,6 +1315,20 @@ const Line = 'Line';
1321
1315
  const OutputRepeatCount = 'OutputRepeatCount';
1322
1316
  const OutputSourceLink = 'OutputSourceLink';
1323
1317
 
1318
+ const RE_URL = /(?:https?:\/\/|file:\/\/|lvce(?:-oss)?:\/\/)\S+/;
1319
+ const trailingPunctuation = '!),.;?]}';
1320
+ const trimTrailingPunctuation = value => {
1321
+ let end = value.length;
1322
+ while (end > 0 && trailingPunctuation.includes(value[end - 1])) {
1323
+ end--;
1324
+ }
1325
+ return value.slice(0, end);
1326
+ };
1327
+ const getLinkMatch = text => {
1328
+ const match = text.match(RE_URL);
1329
+ return match ? trimTrailingPunctuation(match[0]) : null;
1330
+ };
1331
+
1324
1332
  const isStructuredLogEntry = value => {
1325
1333
  return value?.category === 'Window' && typeof value.level === 'string' && typeof value.line === 'number' && typeof value.message === 'string' && typeof value.source === 'string' && typeof value.timestamp === 'string';
1326
1334
  };
@@ -1356,7 +1364,6 @@ const parseStructuredLogLine = line => {
1356
1364
  if (!parsed.source) {
1357
1365
  return parts;
1358
1366
  }
1359
- const href = parsed.line > 0 ? `${parsed.source}:${parsed.line}` : parsed.source;
1360
1367
  return [...parts, {
1361
1368
  type: Text,
1362
1369
  value: ' '
@@ -1364,10 +1371,26 @@ const parseStructuredLogLine = line => {
1364
1371
  className: OutputSourceLink,
1365
1372
  label: getSourceLabel(parsed.source, parsed.line),
1366
1373
  type: Link,
1367
- value: href
1374
+ value: parsed.source
1368
1375
  }];
1369
1376
  };
1370
1377
 
1378
+ const RE_SOURCE_LINK = /^lvce(?:-oss)?:\/\//;
1379
+ const RE_SOURCE_LOCATION = /:\d+(?::\d+)?$/;
1380
+ const getLinkPart = match => {
1381
+ if (RE_SOURCE_LINK.test(match)) {
1382
+ return {
1383
+ className: OutputSourceLink,
1384
+ label: match,
1385
+ type: Link,
1386
+ value: match.replace(RE_SOURCE_LOCATION, '')
1387
+ };
1388
+ }
1389
+ return {
1390
+ type: Link,
1391
+ value: match
1392
+ };
1393
+ };
1371
1394
  const parseLine = line => {
1372
1395
  const structuredLine = parseStructuredLogLine(line);
1373
1396
  if (structuredLine) {
@@ -1393,10 +1416,7 @@ const parseLine = line => {
1393
1416
  value: rest.slice(0, index)
1394
1417
  });
1395
1418
  }
1396
- parts.push({
1397
- type: Link,
1398
- value: match
1399
- });
1419
+ parts.push(getLinkPart(match));
1400
1420
  rest = rest.slice(index + match.length);
1401
1421
  }
1402
1422
  if (parts.length === 0) {
@@ -1789,6 +1809,14 @@ const handleSelect = async (state, id) => {
1789
1809
  return selectChannel(state, id);
1790
1810
  };
1791
1811
 
1812
+ const handleSourceLinkClick = async (state, uri) => {
1813
+ if (!uri) {
1814
+ return state;
1815
+ }
1816
+ await invoke$1('Main.openUri', uri);
1817
+ return state;
1818
+ };
1819
+
1792
1820
  const sendMessagePortToExtensionHostWorker2 = async port => {
1793
1821
  await sendMessagePortToExtensionHostWorker(port);
1794
1822
  };
@@ -2078,6 +2106,15 @@ const renderFilterValue = (oldState, newState) => {
2078
2106
  return ['Viewlet.setValueByName', Filter$1, newState.filterValue];
2079
2107
  };
2080
2108
 
2109
+ const HandleBlur = 'handleBlur';
2110
+ const HandleClearFilterClick = 'handleClearFilterClick';
2111
+ const HandleContextMenu = 'handleContextMenu';
2112
+ const HandleFilterInput = 'handleFilterInput';
2113
+ const HandlePointerDown = 'handlePointerDown';
2114
+ const HandleSelect = 'handleSelect';
2115
+ const HandleButtonClick = 'handleButtonClick';
2116
+ const HandleSourceLinkClick = 'handleSourceLinkClick';
2117
+
2081
2118
  const noNodes = [];
2082
2119
  const repeatCountNode = {
2083
2120
  childCount: 1,
@@ -2092,6 +2129,7 @@ const getLinePartDom = part => {
2092
2129
  switch (part.type) {
2093
2130
  case Link:
2094
2131
  {
2132
+ const isSourceLink = part.className === OutputSourceLink;
2095
2133
  const linkNode = {
2096
2134
  childCount: 1,
2097
2135
  href: part.value,
@@ -2100,6 +2138,9 @@ const getLinePartDom = part => {
2100
2138
  type: A,
2101
2139
  ...(part.className && {
2102
2140
  className: part.className
2141
+ }),
2142
+ ...(isSourceLink && {
2143
+ onClick: HandleSourceLinkClick
2103
2144
  })
2104
2145
  };
2105
2146
  return {
@@ -2237,14 +2278,6 @@ const render2 = (uid, diffResult) => {
2237
2278
  return commands;
2238
2279
  };
2239
2280
 
2240
- const HandleBlur = 'handleBlur';
2241
- const HandleClearFilterClick = 'handleClearFilterClick';
2242
- const HandleContextMenu = 'handleContextMenu';
2243
- const HandleFilterInput = 'handleFilterInput';
2244
- const HandlePointerDown = 'handlePointerDown';
2245
- const HandleSelect = 'handleSelect';
2246
- const HandleButtonClick = 'handleButtonClick';
2247
-
2248
2281
  const getActionButtonVirtualDom = button => {
2249
2282
  const {
2250
2283
  icon,
@@ -2353,6 +2386,10 @@ const renderEventListeners = () => {
2353
2386
  }, {
2354
2387
  name: HandleClearFilterClick,
2355
2388
  params: ['clearFilter']
2389
+ }, {
2390
+ name: HandleSourceLinkClick,
2391
+ params: ['handleSourceLinkClick', 'event.target.href'],
2392
+ preventDefault: true
2356
2393
  }, {
2357
2394
  name: HandlePointerDown,
2358
2395
  params: ['handleClickAt', 'event.clientX', 'event.clientY']
@@ -2440,6 +2477,7 @@ const commandMap = {
2440
2477
  'Output.handleError': wrapCommand(handleError),
2441
2478
  'Output.handleFilterInput': wrapCommand(handleFilterInput),
2442
2479
  'Output.handleSelect': wrapCommand(handleSelect),
2480
+ 'Output.handleSourceLinkClick': wrapCommand(handleSourceLinkClick),
2443
2481
  'Output.initialize': initialize,
2444
2482
  'Output.loadContent2': wrapCommand(loadContent),
2445
2483
  'Output.openFindWidget': wrapCommand(openFindWidget),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",