@lvce-editor/extension-detail-view 7.7.0 → 7.9.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.
@@ -1911,8 +1911,10 @@ const getCurrentStack = () => {
1911
1911
  const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
1912
1912
  return currentStack;
1913
1913
  };
1914
- const getNewLineIndex = (string, startIndex = undefined) => {
1915
- return string.indexOf(NewLine, startIndex);
1914
+ const getNewLineIndex = (string, startIndex) => {
1915
+ {
1916
+ return string.indexOf(NewLine);
1917
+ }
1916
1918
  };
1917
1919
  const getParentStack = error => {
1918
1920
  let parentStack = error.stack || error.data || error.message || '';
@@ -1923,55 +1925,77 @@ const getParentStack = error => {
1923
1925
  };
1924
1926
  const MethodNotFound = -32601;
1925
1927
  const Custom = -32001;
1928
+ const restoreExistingError = (error, currentStack) => {
1929
+ if (typeof error.stack === 'string') {
1930
+ error.stack = error.stack + NewLine + currentStack;
1931
+ }
1932
+ return error;
1933
+ };
1934
+ const restoreMethodNotFoundError = (error, currentStack) => {
1935
+ const restoredError = new JsonRpcError(error.message);
1936
+ const parentStack = getParentStack(error);
1937
+ restoredError.stack = parentStack + NewLine + currentStack;
1938
+ return restoredError;
1939
+ };
1940
+ const restoreStackFromData = (restoredError, error, currentStack) => {
1941
+ if (error.data.stack && error.data.type && error.message) {
1942
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1943
+ return;
1944
+ }
1945
+ if (error.data.stack) {
1946
+ restoredError.stack = error.data.stack;
1947
+ }
1948
+ };
1949
+ const applyDataProperties = (restoredError, error) => {
1950
+ if (!error.data) {
1951
+ return;
1952
+ }
1953
+ restoreStackFromData(restoredError, error, getCurrentStack());
1954
+ if (error.data.codeFrame) {
1955
+ // @ts-ignore
1956
+ restoredError.codeFrame = error.data.codeFrame;
1957
+ }
1958
+ if (error.data.code) {
1959
+ // @ts-ignore
1960
+ restoredError.code = error.data.code;
1961
+ }
1962
+ if (error.data.type) {
1963
+ // @ts-ignore
1964
+ restoredError.name = error.data.type;
1965
+ }
1966
+ };
1967
+ const applyDirectProperties = (restoredError, error) => {
1968
+ if (error.stack) {
1969
+ const lowerStack = restoredError.stack || '';
1970
+ const indexNewLine = getNewLineIndex(lowerStack);
1971
+ const parentStack = getParentStack(error);
1972
+ // @ts-ignore
1973
+ restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1974
+ }
1975
+ if (error.codeFrame) {
1976
+ // @ts-ignore
1977
+ restoredError.codeFrame = error.codeFrame;
1978
+ }
1979
+ };
1980
+ const restoreMessageError = (error, _currentStack) => {
1981
+ const restoredError = constructError(error.message, error.type, error.name);
1982
+ if (error.data) {
1983
+ applyDataProperties(restoredError, error);
1984
+ } else {
1985
+ applyDirectProperties(restoredError, error);
1986
+ }
1987
+ return restoredError;
1988
+ };
1926
1989
  const restoreJsonRpcError = error => {
1927
1990
  const currentStack = getCurrentStack();
1928
1991
  if (error && error instanceof Error) {
1929
- if (typeof error.stack === 'string') {
1930
- error.stack = error.stack + NewLine + currentStack;
1931
- }
1932
- return error;
1992
+ return restoreExistingError(error, currentStack);
1933
1993
  }
1934
1994
  if (error && error.code && error.code === MethodNotFound) {
1935
- const restoredError = new JsonRpcError(error.message);
1936
- const parentStack = getParentStack(error);
1937
- restoredError.stack = parentStack + NewLine + currentStack;
1938
- return restoredError;
1995
+ return restoreMethodNotFoundError(error, currentStack);
1939
1996
  }
1940
1997
  if (error && error.message) {
1941
- const restoredError = constructError(error.message, error.type, error.name);
1942
- if (error.data) {
1943
- if (error.data.stack && error.data.type && error.message) {
1944
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1945
- } else if (error.data.stack) {
1946
- restoredError.stack = error.data.stack;
1947
- }
1948
- if (error.data.codeFrame) {
1949
- // @ts-ignore
1950
- restoredError.codeFrame = error.data.codeFrame;
1951
- }
1952
- if (error.data.code) {
1953
- // @ts-ignore
1954
- restoredError.code = error.data.code;
1955
- }
1956
- if (error.data.type) {
1957
- // @ts-ignore
1958
- restoredError.name = error.data.type;
1959
- }
1960
- } else {
1961
- if (error.stack) {
1962
- const lowerStack = restoredError.stack || '';
1963
- // @ts-ignore
1964
- const indexNewLine = getNewLineIndex(lowerStack);
1965
- const parentStack = getParentStack(error);
1966
- // @ts-ignore
1967
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1968
- }
1969
- if (error.codeFrame) {
1970
- // @ts-ignore
1971
- restoredError.codeFrame = error.codeFrame;
1972
- }
1973
- }
1974
- return restoredError;
1998
+ return restoreMessageError(error);
1975
1999
  }
1976
2000
  if (typeof error === 'string') {
1977
2001
  return new Error(`JsonRpc Error: ${error}`);
@@ -2777,6 +2801,8 @@ const HandleReadmeClick = 16;
2777
2801
  const HandleSelectionChange = 17;
2778
2802
  const HandleTabFocus = 18;
2779
2803
  const HandleResourceLinkClick = 19;
2804
+ const HandleMouseEnterEnable = 20;
2805
+ const HandleMouseLeaveEnable = 21;
2780
2806
 
2781
2807
  const ActivationEvents = 'ActivationEvents';
2782
2808
  const Changelog = 'Changelog';
@@ -3774,7 +3800,9 @@ const getExtensionDetailButtons = (hasColorTheme, isBuiltin, isDisabled, extensi
3774
3800
  enabled: isDisabled,
3775
3801
  label: enable(),
3776
3802
  name: Enable,
3777
- onClick: HandleClickEnable
3803
+ onClick: HandleClickEnable,
3804
+ onMouseEnter: HandleMouseEnterEnable,
3805
+ onMouseLeave: HandleMouseLeaveEnable
3778
3806
  }, {
3779
3807
  enabled: !isDisabled,
3780
3808
  label: disable(),
@@ -4798,6 +4826,35 @@ const handleImageContextMenu = async (state, eventX, eventY) => {
4798
4826
  return state;
4799
4827
  };
4800
4828
 
4829
+ const previewColorTheme = async colorThemeId => {
4830
+ await invoke$1('ColorTheme.previewColorTheme', colorThemeId);
4831
+ };
4832
+ const disablePreviewColorTheme = async () => {
4833
+ await invoke$1('ColorTheme.disablePreviewColorTheme');
4834
+ };
4835
+
4836
+ const handleMouseEnterEnable = async state => {
4837
+ const colorThemeId = getColorThemeId(state.extension);
4838
+ if (!colorThemeId) {
4839
+ return state;
4840
+ }
4841
+ try {
4842
+ await previewColorTheme(colorThemeId);
4843
+ } catch (error) {
4844
+ console.warn(error);
4845
+ }
4846
+ return state;
4847
+ };
4848
+
4849
+ const handleMouseLeaveEnable = async state => {
4850
+ try {
4851
+ await disablePreviewColorTheme();
4852
+ } catch (error) {
4853
+ console.warn(error);
4854
+ }
4855
+ return state;
4856
+ };
4857
+
4801
4858
  const openExternalElectron = async uri => {
4802
4859
  await openExternal$1(uri);
4803
4860
  };
@@ -5515,14 +5572,21 @@ const getExtensionDetailDescriptionVirtualDom = description => {
5515
5572
  };
5516
5573
 
5517
5574
  const className = mergeClassNames(Button, ButtonPrimary);
5518
- const getButtonVirtualDom = (message, onClick, name) => {
5519
- return [{
5575
+ const getButtonVirtualDom = (message, onClick, name, onMouseEnter, onMouseLeave) => {
5576
+ const button = {
5520
5577
  childCount: 1,
5521
5578
  className,
5522
5579
  name,
5523
5580
  onClick,
5581
+ ...(onMouseEnter ? {
5582
+ onMouseEnter
5583
+ } : {}),
5584
+ ...(onMouseLeave ? {
5585
+ onMouseLeave
5586
+ } : {}),
5524
5587
  type: Button$1
5525
- }, text(message)];
5588
+ };
5589
+ return [button, text(message)];
5526
5590
  };
5527
5591
 
5528
5592
  const getSettingsButtonVirtualDom = enabled => {
@@ -5546,7 +5610,7 @@ const getSettingsButtonVirtualDom = enabled => {
5546
5610
 
5547
5611
  const getExtensionDetailHeaderActionsVirtualDom = (buttonDefs, settingsButtonEnabled) => {
5548
5612
  const enabledButtons = buttonDefs.filter(btn => btn.enabled);
5549
- const buttons = enabledButtons.flatMap(btn => getButtonVirtualDom(btn.label, btn.onClick, btn.name));
5613
+ const buttons = enabledButtons.flatMap(btn => getButtonVirtualDom(btn.label, btn.onClick, btn.name, btn.onMouseEnter, btn.onMouseLeave));
5550
5614
  const settingsButton = getSettingsButtonVirtualDom(settingsButtonEnabled);
5551
5615
  const dom = [{
5552
5616
  childCount: enabledButtons.length + settingsButton.length,
@@ -5852,6 +5916,12 @@ const renderEventListeners = () => {
5852
5916
  }, {
5853
5917
  name: HandleClickEnable,
5854
5918
  params: ['handleClickEnable']
5919
+ }, {
5920
+ name: HandleMouseEnterEnable,
5921
+ params: ['handleMouseEnterEnable']
5922
+ }, {
5923
+ name: HandleMouseLeaveEnable,
5924
+ params: ['handleMouseLeaveEnable']
5855
5925
  }, {
5856
5926
  name: HandleClickScrollToTop,
5857
5927
  params: ['handleClickScrollToTop'],
@@ -5941,6 +6011,8 @@ const commandMap = {
5941
6011
  'ExtensionDetail.handleFeaturesClick': wrapCommand(handleClickFeatures),
5942
6012
  'ExtensionDetail.handleIconError': wrapCommand(handleIconError),
5943
6013
  'ExtensionDetail.handleImageContextMenu': wrapCommand(handleImageContextMenu),
6014
+ 'ExtensionDetail.handleMouseEnterEnable': wrapCommand(handleMouseEnterEnable),
6015
+ 'ExtensionDetail.handleMouseLeaveEnable': wrapCommand(handleMouseLeaveEnable),
5944
6016
  'ExtensionDetail.handleReadmeClick': wrapCommand(handleReadmeClick),
5945
6017
  'ExtensionDetail.handleReadmeContextMenu': wrapCommand(handleReadmeContextMenu),
5946
6018
  'ExtensionDetail.handleResourceLinkClick': wrapCommand(handleResourceLinkClick),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "7.7.0",
3
+ "version": "7.9.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",