@lvce-editor/extension-detail-view 3.25.0 → 3.26.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.
@@ -784,7 +784,7 @@ const send = (transport, method, ...params) => {
784
784
  const message = create$4(method, params);
785
785
  transport.send(message);
786
786
  };
787
- const invoke$1 = (ipc, method, ...params) => {
787
+ const invoke = (ipc, method, ...params) => {
788
788
  return invokeHelper(ipc, method, params, false);
789
789
  };
790
790
  const invokeAndTransfer = (ipc, method, ...params) => {
@@ -817,7 +817,7 @@ const createRpc = ipc => {
817
817
  send(ipc, method, ...params);
818
818
  },
819
819
  invoke(method, ...params) {
820
- return invoke$1(ipc, method, ...params);
820
+ return invoke(ipc, method, ...params);
821
821
  },
822
822
  invokeAndTransfer(method, ...params) {
823
823
  return invokeAndTransfer(ipc, method, ...params);
@@ -962,7 +962,8 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir$1) => {
962
962
  features: [],
963
963
  folderSize: 0,
964
964
  assetDir: assetDir$1 || assetDir,
965
- platform
965
+ platform,
966
+ settingsButtonEnabled: false
966
967
  };
967
968
  set$1(uid, state, state);
968
969
  };
@@ -1002,7 +1003,7 @@ const dispose = uid => {
1002
1003
  dispose$1(uid);
1003
1004
  };
1004
1005
 
1005
- const commandIds = ['getMenuEntries', 'handleClickDisable', 'handleClickSize', 'handleClickUninstall', 'handleFeaturesClick', 'handleIconError', 'handleTabsClick', 'renderEventListeners', 'resize', 'saveState', 'selectTab', 'terminate'];
1006
+ const commandIds = ['getMenuEntries', 'handleClickDisable', 'handleClickSettings', 'handleClickSetColorTheme', 'handleClickSize', 'handleClickUninstall', 'handleFeaturesClick', 'handleIconError', 'handleTabsClick', 'renderEventListeners', 'resize', 'saveState', 'selectTab', 'terminate'];
1006
1007
 
1007
1008
  const getCommandIds = () => {
1008
1009
  return commandIds;
@@ -1023,6 +1024,7 @@ const i18nString = (key, placeholders = emptyObject) => {
1023
1024
  const Commands$1 = 'Commands';
1024
1025
  const ContentSecurityPolicy = 'ContentSecurityPolicy';
1025
1026
  const Copy = 'Copy';
1027
+ const Disable = 'Disable';
1026
1028
  const Elements = 'Elements';
1027
1029
  const FileMatch = 'File Match';
1028
1030
  const None$1 = 'None';
@@ -1036,13 +1038,18 @@ const SaveImageAs = 'Save Image as';
1036
1038
  const Schema = 'Schema';
1037
1039
  const Selector = 'Selector';
1038
1040
  const Settings$1 = 'Settings';
1041
+ const SetColorTheme = 'Set Color Theme';
1039
1042
  const Theme$1 = 'Theme';
1043
+ const Uninstall = 'Uninstall';
1040
1044
  const WebViews$1 = 'WebViews';
1041
1045
  const NotImplemented = 'Not Implemented';
1042
1046
 
1043
1047
  const copy = () => {
1044
1048
  return i18nString(Copy);
1045
1049
  };
1050
+ const disable = () => {
1051
+ return i18nString(Disable);
1052
+ };
1046
1053
  const none = () => {
1047
1054
  return i18nString(None$1);
1048
1055
  };
@@ -1064,6 +1071,9 @@ const fileMatch = () => {
1064
1071
  const schema = () => {
1065
1072
  return i18nString(Schema);
1066
1073
  };
1074
+ const setColorTheme$3 = () => {
1075
+ return i18nString(SetColorTheme);
1076
+ };
1067
1077
  const theme = () => {
1068
1078
  return i18nString(Theme$1);
1069
1079
  };
@@ -1097,6 +1107,9 @@ const elements = () => {
1097
1107
  const notImplemented = () => {
1098
1108
  return i18nString(NotImplemented);
1099
1109
  };
1110
+ const uninstall = () => {
1111
+ return i18nString(Uninstall);
1112
+ };
1100
1113
 
1101
1114
  const None = 0;
1102
1115
 
@@ -1212,6 +1225,10 @@ const RendererWorker$1 = 1;
1212
1225
  const {
1213
1226
  invoke: invoke$3,
1214
1227
  set: set$3} = create(RendererWorker$1);
1228
+ const setColorTheme$2 = async id => {
1229
+ // @ts-ignore
1230
+ return invoke$3(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1231
+ };
1215
1232
  const readFile$2 = async uri => {
1216
1233
  return invoke$3('FileSystem.readFile', uri);
1217
1234
  };
@@ -1230,6 +1247,10 @@ const getMarkdownDom$1 = async html => {
1230
1247
  // @ts-ignore
1231
1248
  return invoke$3('Markdown.getVirtualDom', html);
1232
1249
  };
1250
+ const renderMarkdown$2 = async (markdown, options) => {
1251
+ // @ts-ignore
1252
+ return invoke$3('Markdown.renderMarkdown', markdown, options);
1253
+ };
1233
1254
  const openNativeFolder$1 = async uri => {
1234
1255
  // @ts-ignore
1235
1256
  await invoke$3('OpenNativeFolder.openNativeFolder', uri);
@@ -1240,21 +1261,49 @@ const RendererWorker = {
1240
1261
  getExtension: getExtension$3,
1241
1262
  getFolderSize: getFolderSize$2,
1242
1263
  getMarkdownDom: getMarkdownDom$1,
1243
- invoke: invoke$3,
1244
1264
  openNativeFolder: openNativeFolder$1,
1245
1265
  readFile: readFile$2,
1246
- set: set$3};
1266
+ renderMarkdown: renderMarkdown$2,
1267
+ set: set$3,
1268
+ setColorTheme: setColorTheme$2};
1247
1269
 
1248
1270
  const {
1249
- invoke,
1250
- set,
1251
- readFile: readFile$1,
1252
1271
  getAllExtensions: getAllExtensions$1,
1272
+ getExtension: getExtension$2,
1253
1273
  getFolderSize: getFolderSize$1,
1254
- openNativeFolder,
1255
1274
  getMarkdownDom,
1256
- getExtension: getExtension$2
1257
- } = RendererWorker;
1275
+ openNativeFolder,
1276
+ readFile: readFile$1,
1277
+ renderMarkdown: renderMarkdown$1,
1278
+ set,
1279
+ setColorTheme: setColorTheme$1} = RendererWorker;
1280
+
1281
+ const setColorTheme = id => {
1282
+ return setColorTheme$1(id);
1283
+ };
1284
+
1285
+ const getColorThemeId = extension => {
1286
+ if (extension && Array.isArray(extension.colorThemes) && extension.colorThemes.length > 0) {
1287
+ const colorTheme = extension.colorThemes[0];
1288
+ return colorTheme.id || colorTheme.label;
1289
+ }
1290
+ return undefined;
1291
+ };
1292
+ const handleClickSetColorTheme = async state => {
1293
+ const {
1294
+ extension
1295
+ } = state;
1296
+ const colorThemeId = getColorThemeId(extension);
1297
+ if (colorThemeId) {
1298
+ await setColorTheme(colorThemeId);
1299
+ }
1300
+ return state;
1301
+ };
1302
+
1303
+ const handleClickSettings = state => {
1304
+ // TODO: Implement settings functionality
1305
+ return state;
1306
+ };
1258
1307
 
1259
1308
  const handleClickSize = async state => {
1260
1309
  const {
@@ -1355,8 +1404,7 @@ const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
1355
1404
  };
1356
1405
 
1357
1406
  const renderMarkdown = async (markdown, options = {}) => {
1358
- // @ts-ignore todo
1359
- const html = await invoke('Markdown.renderMarkdown', markdown, options);
1407
+ const html = await renderMarkdown$1(markdown, options);
1360
1408
  return html;
1361
1409
  };
1362
1410
 
@@ -1719,6 +1767,7 @@ const mergeClassNames = (...classNames) => {
1719
1767
  const Button$1 = 1;
1720
1768
  const Div = 4;
1721
1769
  const H1 = 5;
1770
+ const Span = 8;
1722
1771
  const Table$1 = 9;
1723
1772
  const TBody = 10;
1724
1773
  const Td = 11;
@@ -1739,6 +1788,7 @@ const VirtualDomElements = {
1739
1788
  H2,
1740
1789
  Img,
1741
1790
  Pre,
1791
+ Span,
1742
1792
  TBody,
1743
1793
  THead,
1744
1794
  Table: Table$1,
@@ -1774,6 +1824,8 @@ const ExtensionDetailHeaderDetails = 'ExtensionDetailHeaderDetails';
1774
1824
  const ExtensionDetailIcon = 'ExtensionDetailIcon';
1775
1825
  const ExtensionDetailName = 'ExtensionDetailName';
1776
1826
  const ExtensionDetailPanel = 'ExtensionDetailPanel';
1827
+ const SettingsButton = 'SettingsButton';
1828
+ const SettingsIcon = 'SettingsIcon';
1777
1829
  const ExtensionDetailTab = 'ExtensionDetailTab';
1778
1830
  const ExtensionDetailTabs = 'ExtensionDetailTabs';
1779
1831
  const ExtensionDetailTabSelected = 'ExtensionDetailTabSelected';
@@ -1892,6 +1944,37 @@ const getDisplaySize = size => {
1892
1944
  });
1893
1945
  };
1894
1946
 
1947
+ const HandleClickDisable = 'handleClickDisable';
1948
+ const HandleClickSetColorTheme = 'handleClickSetColorTheme';
1949
+ const HandleClickSettings = 'handleClickSettings';
1950
+ const HandleClickSize = 'handleClickSize';
1951
+ const HandleClickUninstall = 'handleClickUninstall';
1952
+ const HandleFeaturesClick = 'handleFeaturesClick';
1953
+ const HandleIconError = 'handleIconError';
1954
+ const HandleReadmeContextMenu = 'handleReadmeContextMenu';
1955
+ const HandleTabsClick = 'handleTabsClick';
1956
+
1957
+ const hasColorThemes = extension => {
1958
+ return Boolean(extension && extension.colorThemes && extension.colorThemes.length > 0);
1959
+ };
1960
+
1961
+ const getExtensionDetailButtons = extension => {
1962
+ const allActions = [{
1963
+ label: setColorTheme$3(),
1964
+ onClick: HandleClickSetColorTheme,
1965
+ enabled: hasColorThemes(extension)
1966
+ }, {
1967
+ label: disable(),
1968
+ onClick: HandleClickDisable,
1969
+ enabled: true
1970
+ }, {
1971
+ label: uninstall(),
1972
+ onClick: HandleClickUninstall,
1973
+ enabled: !extension?.builtin
1974
+ }];
1975
+ return allActions;
1976
+ };
1977
+
1895
1978
  const getChangelogVirtualDom = () => {
1896
1979
  const notImplemented$1 = notImplemented();
1897
1980
  // TODO set tabpanel role
@@ -2047,14 +2130,6 @@ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, ent
2047
2130
  }, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
2048
2131
  };
2049
2132
 
2050
- const HandleClickDisable = 'handleClickDisable';
2051
- const HandleClickSize = 'handleClickSize';
2052
- const HandleClickUninstall = 'handleClickUninstall';
2053
- const HandleFeaturesClick = 'handleFeaturesClick';
2054
- const HandleIconError = 'handleIconError';
2055
- const HandleReadmeContextMenu = 'handleReadmeContextMenu';
2056
- const HandleTabsClick = 'handleTabsClick';
2057
-
2058
2133
  const getInstallationEntries = (displaySize, extensionId, extensionVersion) => {
2059
2134
  const entries = [{
2060
2135
  key: 'Identifier',
@@ -2517,6 +2592,14 @@ const getExtensionDetailContentVirtualDom = async (sanitizedReadmeHtml, themesHt
2517
2592
  }
2518
2593
  };
2519
2594
 
2595
+ const getExtensionDetailDescriptionVirtualDom = description => {
2596
+ return [{
2597
+ type: VirtualDomElements.Div,
2598
+ className: ExtensionDetailDescription,
2599
+ childCount: 1
2600
+ }, text(description)];
2601
+ };
2602
+
2520
2603
  const getButtonVirtualDom = (message, onClick) => {
2521
2604
  return [{
2522
2605
  type: VirtualDomElements.Button,
@@ -2526,21 +2609,51 @@ const getButtonVirtualDom = (message, onClick) => {
2526
2609
  }, text(message)];
2527
2610
  };
2528
2611
 
2529
- const getExtensionDetailHeaderActionsVirtualDom = () => {
2612
+ const getSettingsButtonVirtualDom = enabled => {
2613
+ if (!enabled) {
2614
+ return [];
2615
+ }
2616
+ return [{
2617
+ type: VirtualDomElements.Button,
2618
+ className: SettingsButton,
2619
+ onClick: HandleClickSettings,
2620
+ childCount: 1,
2621
+ title: 'Settings'
2622
+ }, {
2623
+ type: VirtualDomElements.Span,
2624
+ className: SettingsIcon,
2625
+ childCount: 0,
2626
+ text: '⚙️'
2627
+ }];
2628
+ };
2629
+
2630
+ const getExtensionDetailHeaderActionsVirtualDom = (buttonDefs, settingsButtonEnabled) => {
2631
+ const enabledButtons = buttonDefs.filter(btn => btn.enabled);
2632
+ const buttons = enabledButtons.flatMap(btn => getButtonVirtualDom(btn.label, btn.onClick));
2633
+ const settingsButton = getSettingsButtonVirtualDom(settingsButtonEnabled);
2530
2634
  const dom = [{
2531
2635
  type: VirtualDomElements.Div,
2532
2636
  className: ExtensionDetailHeaderActions,
2533
- childCount: 2
2534
- }, ...getButtonVirtualDom('Disable', HandleClickDisable), ...getButtonVirtualDom('Uninstall', HandleClickUninstall)];
2637
+ childCount: enabledButtons.length + settingsButton.length
2638
+ }, ...buttons, ...settingsButton];
2535
2639
  return dom;
2536
2640
  };
2537
2641
 
2538
- const getExtensionDetailHeaderVirtualDom = extensionDetail => {
2539
- const {
2540
- name,
2541
- iconSrc,
2542
- description
2543
- } = extensionDetail;
2642
+ const getNameBadgeVirtualDom = badge => {
2643
+ {
2644
+ return [];
2645
+ }
2646
+ };
2647
+
2648
+ const getExtensionDetailNameVirtualDom = (name, badge) => {
2649
+ return [{
2650
+ type: VirtualDomElements.Div,
2651
+ className: ExtensionDetailName,
2652
+ childCount: badge ? 2 : 1
2653
+ }, text(name), ...getNameBadgeVirtualDom()];
2654
+ };
2655
+
2656
+ const getExtensionDetailHeaderVirtualDom = (name, iconSrc, description, badge, buttonDefs, settingsButtonEnabled) => {
2544
2657
  const dom = [{
2545
2658
  type: VirtualDomElements.Div,
2546
2659
  className: ExtensionDetailHeader,
@@ -2556,15 +2669,7 @@ const getExtensionDetailHeaderVirtualDom = extensionDetail => {
2556
2669
  type: VirtualDomElements.Div,
2557
2670
  className: ExtensionDetailHeaderDetails,
2558
2671
  childCount: 3
2559
- }, {
2560
- type: VirtualDomElements.Div,
2561
- className: ExtensionDetailName,
2562
- childCount: 1
2563
- }, text(name), {
2564
- type: VirtualDomElements.Div,
2565
- className: ExtensionDetailDescription,
2566
- childCount: 1
2567
- }, text(description), ...getExtensionDetailHeaderActionsVirtualDom()];
2672
+ }, ...getExtensionDetailNameVirtualDom(name, badge), ...getExtensionDetailDescriptionVirtualDom(description), ...getExtensionDetailHeaderActionsVirtualDom(buttonDefs, settingsButtonEnabled)];
2568
2673
  return dom;
2569
2674
  };
2570
2675
 
@@ -2648,11 +2753,21 @@ const getExtensionDetailVirtualDom = async (extensionDetail, sanitizedReadmeHtml
2648
2753
  const tabs = getTabs(selectedTab);
2649
2754
  const sizeValue = getViewletSize(newState?.width || 0);
2650
2755
  const sizeClass = getClassNames(sizeValue);
2756
+ const buttonDefs = getExtensionDetailButtons(extension);
2757
+ const {
2758
+ name,
2759
+ iconSrc,
2760
+ description
2761
+ } = extensionDetail;
2762
+ const badge = '';
2763
+ const {
2764
+ settingsButtonEnabled
2765
+ } = newState;
2651
2766
  const dom = [{
2652
2767
  type: VirtualDomElements.Div,
2653
2768
  className: mergeClassNames(Viewlet, ExtensionDetail, sizeClass),
2654
2769
  childCount: 3
2655
- }, ...getExtensionDetailHeaderVirtualDom(extensionDetail), ...getTabsVirtualDom(tabs), ...(await getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension, width))];
2770
+ }, ...getExtensionDetailHeaderVirtualDom(name, iconSrc, description, badge, buttonDefs, settingsButtonEnabled), ...getTabsVirtualDom(tabs), ...(await getExtensionDetailContentVirtualDom(sanitizedReadmeHtml, themesHtml, selectedTab, features, displaySize, extensionId, extensionVersion, selectedFeature, extension, width))];
2656
2771
  return dom;
2657
2772
  };
2658
2773
 
@@ -2714,9 +2829,15 @@ const renderEventListeners = () => {
2714
2829
  }, {
2715
2830
  name: HandleClickDisable,
2716
2831
  params: ['handleClickDisable']
2832
+ }, {
2833
+ name: HandleClickSettings,
2834
+ params: ['handleClickSettings']
2717
2835
  }, {
2718
2836
  name: HandleClickUninstall,
2719
2837
  params: ['handleClickUninstall']
2838
+ }, {
2839
+ name: HandleClickSetColorTheme,
2840
+ params: ['handleClickSetColorTheme']
2720
2841
  }];
2721
2842
  };
2722
2843
 
@@ -2752,6 +2873,8 @@ const commandMap = {
2752
2873
  'ExtensionDetail.getCommandIds': getCommandIds,
2753
2874
  'ExtensionDetail.getMenuEntries': getMenuEntries,
2754
2875
  'ExtensionDetail.handleClickDisable': wrapCommand(handleClickDisable),
2876
+ 'ExtensionDetail.handleClickSettings': wrapCommand(handleClickSettings),
2877
+ 'ExtensionDetail.handleClickSetColorTheme': wrapCommand(handleClickSetColorTheme),
2755
2878
  'ExtensionDetail.handleClickSize': wrapCommand(handleClickSize),
2756
2879
  'ExtensionDetail.handleClickUninstall': wrapCommand(handleClickUninstall),
2757
2880
  'ExtensionDetail.handleFeaturesClick': wrapCommand(handleClickFeatures),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "3.25.0",
3
+ "version": "3.26.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",