@lvce-editor/output-view 2.24.6 → 2.24.8

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.
@@ -694,7 +694,7 @@ const applyDirectProperties = (restoredError, error) => {
694
694
  }
695
695
  };
696
696
  const restoreMessageError = (error, _currentStack) => {
697
- const restoredError = constructError(error.message, error.type, error.name);
697
+ const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
698
698
  if (typeof error.code === 'string' || typeof error.code === 'number') {
699
699
  Object.defineProperty(restoredError, 'code', {
700
700
  configurable: true,
@@ -709,6 +709,23 @@ const restoreMessageError = (error, _currentStack) => {
709
709
  }
710
710
  return restoredError;
711
711
  };
712
+ const getFallbackMessage = error => {
713
+ if (error && typeof error.message === 'string' && error.message) {
714
+ return error.message;
715
+ }
716
+ if (error && error.data) {
717
+ return getFallbackMessage(error.data);
718
+ }
719
+ const stringified = String(error);
720
+ if (stringified !== '[object Object]') {
721
+ return stringified;
722
+ }
723
+ try {
724
+ return JSON.stringify(error);
725
+ } catch {
726
+ return stringified;
727
+ }
728
+ };
712
729
  const restoreJsonRpcError = error => {
713
730
  const currentStack = getCurrentStack();
714
731
  if (error && error instanceof Error) {
@@ -717,13 +734,13 @@ const restoreJsonRpcError = error => {
717
734
  if (error && error.code && error.code === MethodNotFound) {
718
735
  return restoreMethodNotFoundError(error, currentStack);
719
736
  }
737
+ if (error && error.error) {
738
+ return restoreJsonRpcError(error.error);
739
+ }
720
740
  if (error && error.message) {
721
741
  return restoreMessageError(error);
722
742
  }
723
- if (typeof error === 'string') {
724
- return new Error(`JsonRpc Error: ${error}`);
725
- }
726
- return new Error(`JsonRpc Error: ${error}`);
743
+ return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
727
744
  };
728
745
  const unwrapJsonRpcResult = responseMessage => {
729
746
  if ('error' in responseMessage) {
@@ -782,7 +799,7 @@ const getErrorProperty = (error, prettyError) => {
782
799
  data: {
783
800
  code: prettyError.code ?? error?.code,
784
801
  codeFrame: prettyError.codeFrame,
785
- name: prettyError.name,
802
+ name: prettyError.name ?? error?.name,
786
803
  stack: getStack(prettyError),
787
804
  type: getErrorType(prettyError)
788
805
  },
@@ -1410,6 +1427,13 @@ const filterItems = (items, filterValue) => {
1410
1427
  return items.filter(parts => getTextFromParts(parts).toLowerCase().includes(normalizedFilterValue));
1411
1428
  };
1412
1429
 
1430
+ const invokeExtensionCommand = (applicationId, command, ...args) => {
1431
+ if (applicationId !== undefined) {
1432
+ return invoke$4('Extensions.invokeForApplication', applicationId, command, ...args);
1433
+ }
1434
+ return invoke$4(command, ...args);
1435
+ };
1436
+
1413
1437
  const ExtensionOutputPrefix = 'extension-output://';
1414
1438
  const isExtensionOutputUri = uri => {
1415
1439
  return uri.startsWith(ExtensionOutputPrefix);
@@ -1598,15 +1622,15 @@ const parseLine = (line, parseLinks = true) => {
1598
1622
  return parts;
1599
1623
  };
1600
1624
 
1601
- const readOutput = async uri => {
1625
+ const readOutput = async (uri, applicationId) => {
1602
1626
  if (isExtensionOutputUri(uri)) {
1603
- return invoke$4('Extensions.readOutputChannel', uri);
1627
+ return invokeExtensionCommand(applicationId, 'Extensions.readOutputChannel', uri);
1604
1628
  }
1605
1629
  return readFile(uri);
1606
1630
  };
1607
- const loadLines = async (uri, parseLinks = true) => {
1631
+ const loadLines = async (uri, parseLinks = true, applicationId) => {
1608
1632
  try {
1609
- const content = await readOutput(uri);
1633
+ const content = await readOutput(uri, applicationId);
1610
1634
  const lines = aggregateLines(content.split('\n').map(line => parseLine(line, parseLinks)));
1611
1635
  return {
1612
1636
  code: 0,
@@ -1629,15 +1653,16 @@ const loadLines = async (uri, parseLinks = true) => {
1629
1653
  }
1630
1654
  };
1631
1655
 
1632
- const clearOutput$1 = async uri => {
1656
+ const clearOutput$1 = async (uri, applicationId) => {
1633
1657
  if (isExtensionOutputUri(uri)) {
1634
- await invoke$4('Extensions.clearOutputChannel', uri);
1658
+ await invokeExtensionCommand(applicationId, 'Extensions.clearOutputChannel', uri);
1635
1659
  return;
1636
1660
  }
1637
1661
  await writeFile(uri, '');
1638
1662
  };
1639
1663
  const clear = async state => {
1640
1664
  const {
1665
+ applicationId,
1641
1666
  filterValue,
1642
1667
  options,
1643
1668
  selectedOption
@@ -1650,12 +1675,12 @@ const clear = async state => {
1650
1675
  const {
1651
1676
  uri
1652
1677
  } = option;
1653
- await clearOutput$1(uri);
1678
+ await clearOutput$1(uri, applicationId);
1654
1679
  const {
1655
1680
  code,
1656
1681
  error,
1657
1682
  lines
1658
- } = await loadLines(uri, option.parseLinks);
1683
+ } = await loadLines(uri, option.parseLinks, applicationId);
1659
1684
  const filteredItems = filterItems(lines, filterValue);
1660
1685
  return {
1661
1686
  ...state,
@@ -1686,9 +1711,12 @@ const {
1686
1711
  wrapGetter
1687
1712
  } = create$1();
1688
1713
 
1689
- const create = (id, uri, x, y, width, height, platform, parentId) => {
1714
+ const create = (id, uri, x, y, width, height, platform, parentId, applicationId) => {
1690
1715
  number(parentId);
1691
1716
  const state = {
1717
+ ...(applicationId !== undefined && {
1718
+ applicationId
1719
+ }),
1692
1720
  buttons: [],
1693
1721
  collapsedUris: [],
1694
1722
  deltaY: 0,
@@ -2279,6 +2307,7 @@ const handleScrollBarClick = (state, eventY) => {
2279
2307
  scrollBarActive: true
2280
2308
  };
2281
2309
  };
2310
+ const handleScrollBarPointerDown = (state, eventY) => handleScrollBarClick(state, eventY);
2282
2311
 
2283
2312
  const handleScrollBarMove = (state, eventY) => {
2284
2313
  const {
@@ -2346,6 +2375,7 @@ const setupChangeListener = async (oldWatchId, newWatchId, uri) => {
2346
2375
 
2347
2376
  const selectChannel = async (state, id) => {
2348
2377
  const {
2378
+ applicationId,
2349
2379
  filterValue,
2350
2380
  options,
2351
2381
  watchId
@@ -2359,7 +2389,7 @@ const selectChannel = async (state, id) => {
2359
2389
  code,
2360
2390
  error,
2361
2391
  lines
2362
- } = await loadLines(matchingOption.uri, matchingOption.parseLinks);
2392
+ } = await loadLines(matchingOption.uri, matchingOption.parseLinks, applicationId);
2363
2393
 
2364
2394
  // TODO memory leak and race condition, need to dispose file watcher of previous uri
2365
2395
  const newWatchId = isExtensionOutputUri(matchingOption.uri) ? 0 : createWatchId();
@@ -2498,9 +2528,9 @@ const error = error => {
2498
2528
  console.error(error);
2499
2529
  };
2500
2530
 
2501
- const getExtensionOptions = async () => {
2531
+ const getExtensionOptions = async applicationId => {
2502
2532
  try {
2503
- const channels = await invoke$4('Extensions.getOutputChannelProviders');
2533
+ const channels = await invokeExtensionCommand(applicationId, 'Extensions.getOutputChannelProviders');
2504
2534
  return channels;
2505
2535
  } catch (error$1) {
2506
2536
  error(error$1);
@@ -2561,8 +2591,8 @@ const {
2561
2591
  setActive
2562
2592
  } = createState();
2563
2593
 
2564
- const loadOptions = async platform => {
2565
- const extensionOptions = await getExtensionOptions();
2594
+ const loadOptions = async (platform, applicationId) => {
2595
+ const extensionOptions = await getExtensionOptions(applicationId);
2566
2596
  const detailOptions = await getExtensionDetailOptions();
2567
2597
  if (platform === Web) {
2568
2598
  return [...detailOptions, ...extensionOptions];
@@ -2642,6 +2672,7 @@ const getMatchingOpen = (options, id) => {
2642
2672
  };
2643
2673
  const loadContent = async (state, savedState) => {
2644
2674
  const {
2675
+ applicationId,
2645
2676
  platform,
2646
2677
  uri: requestedChannel,
2647
2678
  watchId
@@ -2653,7 +2684,7 @@ const loadContent = async (state, savedState) => {
2653
2684
  selectedOption
2654
2685
  } = restoreState(savedState);
2655
2686
  const selectedId = getSelectedItem(requestedChannel || selectedOption, platform);
2656
- const options = await loadOptions(platform);
2687
+ const options = await loadOptions(platform, applicationId);
2657
2688
  const option = getMatchingOpen(options, selectedId);
2658
2689
  if (!option) {
2659
2690
  await setupChangeListener(watchId, 0, '');
@@ -2680,7 +2711,7 @@ const loadContent = async (state, savedState) => {
2680
2711
  code,
2681
2712
  error,
2682
2713
  lines
2683
- } = await loadLines(uri, option.parseLinks);
2714
+ } = await loadLines(uri, option.parseLinks, applicationId);
2684
2715
  const filteredItems = filterItems(lines, filterValue);
2685
2716
  const newWatchId = isExtensionOutputUri(uri) ? 0 : createWatchId();
2686
2717
  await setupChangeListener(watchId, newWatchId, uri);
@@ -2715,6 +2746,7 @@ const getActions = state => {
2715
2746
 
2716
2747
  const refresh = async state => {
2717
2748
  const {
2749
+ applicationId,
2718
2750
  filterValue,
2719
2751
  options,
2720
2752
  selectedOption
@@ -2727,7 +2759,7 @@ const refresh = async state => {
2727
2759
  code,
2728
2760
  error,
2729
2761
  lines
2730
- } = await loadLines(matchingOption.uri, matchingOption.parseLinks);
2762
+ } = await loadLines(matchingOption.uri, matchingOption.parseLinks, applicationId);
2731
2763
  const filteredItems = filterItems(lines, filterValue);
2732
2764
  return {
2733
2765
  ...state,
@@ -2740,12 +2772,13 @@ const refresh = async state => {
2740
2772
 
2741
2773
  const refreshOptions = async state => {
2742
2774
  const {
2775
+ applicationId,
2743
2776
  filterValue,
2744
2777
  platform,
2745
2778
  selectedOption,
2746
2779
  watchId
2747
2780
  } = state;
2748
- const options = await loadOptions(platform);
2781
+ const options = await loadOptions(platform, applicationId);
2749
2782
  const option = options.find(option => option.id === selectedOption) || options[0];
2750
2783
  if (!option) {
2751
2784
  await setupChangeListener(watchId, 0, '');
@@ -2770,7 +2803,7 @@ const refreshOptions = async state => {
2770
2803
  code,
2771
2804
  error,
2772
2805
  lines
2773
- } = await loadLines(option.uri, option.parseLinks);
2806
+ } = await loadLines(option.uri, option.parseLinks, applicationId);
2774
2807
  const filteredItems = filterItems(lines, filterValue);
2775
2808
  const newWatchId = isExtensionOutputUri(option.uri) ? 0 : createWatchId();
2776
2809
  await setupChangeListener(watchId, newWatchId, option.uri);
@@ -2981,7 +3014,7 @@ const renderEventListeners = () => {
2981
3014
  params: ['handleKeyDown', 'event.key']
2982
3015
  }, {
2983
3016
  name: HandleScrollBarPointerDown,
2984
- params: ['handleScrollBarClick', 'event.clientY'],
3017
+ params: ['handleScrollBarPointerDown', 'event.clientY'],
2985
3018
  preventDefault: true,
2986
3019
  stopPropagation: true,
2987
3020
  trackPointerEvents: [HandleScrollBarMove, HandleScrollBarPointerCaptureLost]
@@ -3151,6 +3184,7 @@ const commandMap = {
3151
3184
  'Output.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
3152
3185
  'Output.handleScrollBarClick': wrapCommand(handleScrollBarClick),
3153
3186
  'Output.handleScrollBarMove': wrapCommand(handleScrollBarMove),
3187
+ 'Output.handleScrollBarPointerDown': wrapCommand(handleScrollBarPointerDown),
3154
3188
  'Output.handleSelect': wrapCommand(handleSelect),
3155
3189
  'Output.handleSourceLinkClick': wrapCommand(handleSourceLinkClick),
3156
3190
  'Output.handleWheel': wrapCommand(handleWheel),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.24.6",
3
+ "version": "2.24.8",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",