@lvce-editor/output-view 2.24.7 → 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,
@@ -2347,6 +2375,7 @@ const setupChangeListener = async (oldWatchId, newWatchId, uri) => {
2347
2375
 
2348
2376
  const selectChannel = async (state, id) => {
2349
2377
  const {
2378
+ applicationId,
2350
2379
  filterValue,
2351
2380
  options,
2352
2381
  watchId
@@ -2360,7 +2389,7 @@ const selectChannel = async (state, id) => {
2360
2389
  code,
2361
2390
  error,
2362
2391
  lines
2363
- } = await loadLines(matchingOption.uri, matchingOption.parseLinks);
2392
+ } = await loadLines(matchingOption.uri, matchingOption.parseLinks, applicationId);
2364
2393
 
2365
2394
  // TODO memory leak and race condition, need to dispose file watcher of previous uri
2366
2395
  const newWatchId = isExtensionOutputUri(matchingOption.uri) ? 0 : createWatchId();
@@ -2499,9 +2528,9 @@ const error = error => {
2499
2528
  console.error(error);
2500
2529
  };
2501
2530
 
2502
- const getExtensionOptions = async () => {
2531
+ const getExtensionOptions = async applicationId => {
2503
2532
  try {
2504
- const channels = await invoke$4('Extensions.getOutputChannelProviders');
2533
+ const channels = await invokeExtensionCommand(applicationId, 'Extensions.getOutputChannelProviders');
2505
2534
  return channels;
2506
2535
  } catch (error$1) {
2507
2536
  error(error$1);
@@ -2562,8 +2591,8 @@ const {
2562
2591
  setActive
2563
2592
  } = createState();
2564
2593
 
2565
- const loadOptions = async platform => {
2566
- const extensionOptions = await getExtensionOptions();
2594
+ const loadOptions = async (platform, applicationId) => {
2595
+ const extensionOptions = await getExtensionOptions(applicationId);
2567
2596
  const detailOptions = await getExtensionDetailOptions();
2568
2597
  if (platform === Web) {
2569
2598
  return [...detailOptions, ...extensionOptions];
@@ -2643,6 +2672,7 @@ const getMatchingOpen = (options, id) => {
2643
2672
  };
2644
2673
  const loadContent = async (state, savedState) => {
2645
2674
  const {
2675
+ applicationId,
2646
2676
  platform,
2647
2677
  uri: requestedChannel,
2648
2678
  watchId
@@ -2654,7 +2684,7 @@ const loadContent = async (state, savedState) => {
2654
2684
  selectedOption
2655
2685
  } = restoreState(savedState);
2656
2686
  const selectedId = getSelectedItem(requestedChannel || selectedOption, platform);
2657
- const options = await loadOptions(platform);
2687
+ const options = await loadOptions(platform, applicationId);
2658
2688
  const option = getMatchingOpen(options, selectedId);
2659
2689
  if (!option) {
2660
2690
  await setupChangeListener(watchId, 0, '');
@@ -2681,7 +2711,7 @@ const loadContent = async (state, savedState) => {
2681
2711
  code,
2682
2712
  error,
2683
2713
  lines
2684
- } = await loadLines(uri, option.parseLinks);
2714
+ } = await loadLines(uri, option.parseLinks, applicationId);
2685
2715
  const filteredItems = filterItems(lines, filterValue);
2686
2716
  const newWatchId = isExtensionOutputUri(uri) ? 0 : createWatchId();
2687
2717
  await setupChangeListener(watchId, newWatchId, uri);
@@ -2716,6 +2746,7 @@ const getActions = state => {
2716
2746
 
2717
2747
  const refresh = async state => {
2718
2748
  const {
2749
+ applicationId,
2719
2750
  filterValue,
2720
2751
  options,
2721
2752
  selectedOption
@@ -2728,7 +2759,7 @@ const refresh = async state => {
2728
2759
  code,
2729
2760
  error,
2730
2761
  lines
2731
- } = await loadLines(matchingOption.uri, matchingOption.parseLinks);
2762
+ } = await loadLines(matchingOption.uri, matchingOption.parseLinks, applicationId);
2732
2763
  const filteredItems = filterItems(lines, filterValue);
2733
2764
  return {
2734
2765
  ...state,
@@ -2741,12 +2772,13 @@ const refresh = async state => {
2741
2772
 
2742
2773
  const refreshOptions = async state => {
2743
2774
  const {
2775
+ applicationId,
2744
2776
  filterValue,
2745
2777
  platform,
2746
2778
  selectedOption,
2747
2779
  watchId
2748
2780
  } = state;
2749
- const options = await loadOptions(platform);
2781
+ const options = await loadOptions(platform, applicationId);
2750
2782
  const option = options.find(option => option.id === selectedOption) || options[0];
2751
2783
  if (!option) {
2752
2784
  await setupChangeListener(watchId, 0, '');
@@ -2771,7 +2803,7 @@ const refreshOptions = async state => {
2771
2803
  code,
2772
2804
  error,
2773
2805
  lines
2774
- } = await loadLines(option.uri, option.parseLinks);
2806
+ } = await loadLines(option.uri, option.parseLinks, applicationId);
2775
2807
  const filteredItems = filterItems(lines, filterValue);
2776
2808
  const newWatchId = isExtensionOutputUri(option.uri) ? 0 : createWatchId();
2777
2809
  await setupChangeListener(watchId, newWatchId, option.uri);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.24.7",
3
+ "version": "2.24.8",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",