@lvce-editor/extension-detail-view 3.24.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,31 +1225,91 @@ 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
  };
1218
- const getAllExtensions$2 = async key => {
1235
+ const getAllExtensions$2 = async () => {
1219
1236
  return invoke$3('ExtensionManagement.getAllExtensions');
1220
1237
  };
1238
+ const getFolderSize$2 = async uri => {
1239
+ // @ts-ignore
1240
+ return await invoke$3('FileSystem.getFolderSize', uri);
1241
+ };
1242
+ const getExtension$3 = async id => {
1243
+ // @ts-ignore
1244
+ return invoke$3('ExtensionManagement.getExtension', id);
1245
+ };
1246
+ const getMarkdownDom$1 = async html => {
1247
+ // @ts-ignore
1248
+ return invoke$3('Markdown.getVirtualDom', html);
1249
+ };
1250
+ const renderMarkdown$2 = async (markdown, options) => {
1251
+ // @ts-ignore
1252
+ return invoke$3('Markdown.renderMarkdown', markdown, options);
1253
+ };
1254
+ const openNativeFolder$1 = async uri => {
1255
+ // @ts-ignore
1256
+ await invoke$3('OpenNativeFolder.openNativeFolder', uri);
1257
+ };
1221
1258
  const RendererWorker = {
1222
1259
  __proto__: null,
1223
1260
  getAllExtensions: getAllExtensions$2,
1224
- invoke: invoke$3,
1261
+ getExtension: getExtension$3,
1262
+ getFolderSize: getFolderSize$2,
1263
+ getMarkdownDom: getMarkdownDom$1,
1264
+ openNativeFolder: openNativeFolder$1,
1225
1265
  readFile: readFile$2,
1226
- set: set$3};
1266
+ renderMarkdown: renderMarkdown$2,
1267
+ set: set$3,
1268
+ setColorTheme: setColorTheme$2};
1227
1269
 
1228
1270
  const {
1229
- invoke,
1230
- set,
1271
+ getAllExtensions: getAllExtensions$1,
1272
+ getExtension: getExtension$2,
1273
+ getFolderSize: getFolderSize$1,
1274
+ getMarkdownDom,
1275
+ openNativeFolder,
1231
1276
  readFile: readFile$1,
1232
- getAllExtensions: getAllExtensions$1
1233
- } = RendererWorker;
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
+ };
1234
1307
 
1235
1308
  const handleClickSize = async state => {
1236
1309
  const {
1237
1310
  uri
1238
1311
  } = state.extension;
1239
- await invoke('OpenNativeFolder.openNativeFolder', uri);
1312
+ await openNativeFolder(uri);
1240
1313
  return state;
1241
1314
  };
1242
1315
 
@@ -1331,8 +1404,7 @@ const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
1331
1404
  };
1332
1405
 
1333
1406
  const renderMarkdown = async (markdown, options = {}) => {
1334
- // @ts-ignore todo
1335
- const html = await invoke('Markdown.renderMarkdown', markdown, options);
1407
+ const html = await renderMarkdown$1(markdown, options);
1336
1408
  return html;
1337
1409
  };
1338
1410
 
@@ -1450,8 +1522,7 @@ const getExtension$1 = async (id, platform) => {
1450
1522
  };
1451
1523
 
1452
1524
  const getExtensionNew = async id => {
1453
- // @ts-ignore todo
1454
- return invoke('ExtensionManagement.getExtension', id);
1525
+ return getExtension$2(id);
1455
1526
  };
1456
1527
  const getExtension = async (id, platform) => {
1457
1528
  try {
@@ -1528,8 +1599,7 @@ const getFolderSize = async uri => {
1528
1599
  throw new VError(`uri is required`);
1529
1600
  }
1530
1601
  try {
1531
- // @ts-ignore todo
1532
- return await invoke('FileSystem.getFolderSize', uri);
1602
+ return await getFolderSize$1(uri);
1533
1603
  } catch {
1534
1604
  return 0;
1535
1605
  }
@@ -1697,6 +1767,7 @@ const mergeClassNames = (...classNames) => {
1697
1767
  const Button$1 = 1;
1698
1768
  const Div = 4;
1699
1769
  const H1 = 5;
1770
+ const Span = 8;
1700
1771
  const Table$1 = 9;
1701
1772
  const TBody = 10;
1702
1773
  const Td = 11;
@@ -1717,6 +1788,7 @@ const VirtualDomElements = {
1717
1788
  H2,
1718
1789
  Img,
1719
1790
  Pre,
1791
+ Span,
1720
1792
  TBody,
1721
1793
  THead,
1722
1794
  Table: Table$1,
@@ -1752,6 +1824,8 @@ const ExtensionDetailHeaderDetails = 'ExtensionDetailHeaderDetails';
1752
1824
  const ExtensionDetailIcon = 'ExtensionDetailIcon';
1753
1825
  const ExtensionDetailName = 'ExtensionDetailName';
1754
1826
  const ExtensionDetailPanel = 'ExtensionDetailPanel';
1827
+ const SettingsButton = 'SettingsButton';
1828
+ const SettingsIcon = 'SettingsIcon';
1755
1829
  const ExtensionDetailTab = 'ExtensionDetailTab';
1756
1830
  const ExtensionDetailTabs = 'ExtensionDetailTabs';
1757
1831
  const ExtensionDetailTabSelected = 'ExtensionDetailTabSelected';
@@ -1870,6 +1944,37 @@ const getDisplaySize = size => {
1870
1944
  });
1871
1945
  };
1872
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
+
1873
1978
  const getChangelogVirtualDom = () => {
1874
1979
  const notImplemented$1 = notImplemented();
1875
1980
  // TODO set tabpanel role
@@ -2025,14 +2130,6 @@ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, ent
2025
2130
  }, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
2026
2131
  };
2027
2132
 
2028
- const HandleClickDisable = 'handleClickDisable';
2029
- const HandleClickSize = 'handleClickSize';
2030
- const HandleClickUninstall = 'handleClickUninstall';
2031
- const HandleFeaturesClick = 'handleFeaturesClick';
2032
- const HandleIconError = 'handleIconError';
2033
- const HandleReadmeContextMenu = 'handleReadmeContextMenu';
2034
- const HandleTabsClick = 'handleTabsClick';
2035
-
2036
2133
  const getInstallationEntries = (displaySize, extensionId, extensionVersion) => {
2037
2134
  const entries = [{
2038
2135
  key: 'Identifier',
@@ -2057,8 +2154,7 @@ const getInstallationEntries = (displaySize, extensionId, extensionVersion) => {
2057
2154
 
2058
2155
  const getMarkdownVirtualDom = async html => {
2059
2156
  string(html);
2060
- // @ts-ignore todo
2061
- const dom = await invoke('Markdown.getVirtualDom', html);
2157
+ const dom = await getMarkdownDom(html);
2062
2158
  return dom;
2063
2159
  };
2064
2160
 
@@ -2496,6 +2592,14 @@ const getExtensionDetailContentVirtualDom = async (sanitizedReadmeHtml, themesHt
2496
2592
  }
2497
2593
  };
2498
2594
 
2595
+ const getExtensionDetailDescriptionVirtualDom = description => {
2596
+ return [{
2597
+ type: VirtualDomElements.Div,
2598
+ className: ExtensionDetailDescription,
2599
+ childCount: 1
2600
+ }, text(description)];
2601
+ };
2602
+
2499
2603
  const getButtonVirtualDom = (message, onClick) => {
2500
2604
  return [{
2501
2605
  type: VirtualDomElements.Button,
@@ -2505,21 +2609,51 @@ const getButtonVirtualDom = (message, onClick) => {
2505
2609
  }, text(message)];
2506
2610
  };
2507
2611
 
2508
- 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);
2509
2634
  const dom = [{
2510
2635
  type: VirtualDomElements.Div,
2511
2636
  className: ExtensionDetailHeaderActions,
2512
- childCount: 2
2513
- }, ...getButtonVirtualDom('Disable', HandleClickDisable), ...getButtonVirtualDom('Uninstall', HandleClickUninstall)];
2637
+ childCount: enabledButtons.length + settingsButton.length
2638
+ }, ...buttons, ...settingsButton];
2514
2639
  return dom;
2515
2640
  };
2516
2641
 
2517
- const getExtensionDetailHeaderVirtualDom = extensionDetail => {
2518
- const {
2519
- name,
2520
- iconSrc,
2521
- description
2522
- } = 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) => {
2523
2657
  const dom = [{
2524
2658
  type: VirtualDomElements.Div,
2525
2659
  className: ExtensionDetailHeader,
@@ -2535,15 +2669,7 @@ const getExtensionDetailHeaderVirtualDom = extensionDetail => {
2535
2669
  type: VirtualDomElements.Div,
2536
2670
  className: ExtensionDetailHeaderDetails,
2537
2671
  childCount: 3
2538
- }, {
2539
- type: VirtualDomElements.Div,
2540
- className: ExtensionDetailName,
2541
- childCount: 1
2542
- }, text(name), {
2543
- type: VirtualDomElements.Div,
2544
- className: ExtensionDetailDescription,
2545
- childCount: 1
2546
- }, text(description), ...getExtensionDetailHeaderActionsVirtualDom()];
2672
+ }, ...getExtensionDetailNameVirtualDom(name, badge), ...getExtensionDetailDescriptionVirtualDom(description), ...getExtensionDetailHeaderActionsVirtualDom(buttonDefs, settingsButtonEnabled)];
2547
2673
  return dom;
2548
2674
  };
2549
2675
 
@@ -2573,7 +2699,7 @@ const getTabVirtualDom = tab => {
2573
2699
  name
2574
2700
  } = tab;
2575
2701
  const className = selected ? selectedClassName : defaultClassName;
2576
- const ariaSelected = selected ? 'true' : 'false';
2702
+ const ariaSelected = selected;
2577
2703
  return [{
2578
2704
  type: VirtualDomElements.Button,
2579
2705
  role: Tab,
@@ -2627,11 +2753,21 @@ const getExtensionDetailVirtualDom = async (extensionDetail, sanitizedReadmeHtml
2627
2753
  const tabs = getTabs(selectedTab);
2628
2754
  const sizeValue = getViewletSize(newState?.width || 0);
2629
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;
2630
2766
  const dom = [{
2631
2767
  type: VirtualDomElements.Div,
2632
2768
  className: mergeClassNames(Viewlet, ExtensionDetail, sizeClass),
2633
2769
  childCount: 3
2634
- }, ...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))];
2635
2771
  return dom;
2636
2772
  };
2637
2773
 
@@ -2693,9 +2829,15 @@ const renderEventListeners = () => {
2693
2829
  }, {
2694
2830
  name: HandleClickDisable,
2695
2831
  params: ['handleClickDisable']
2832
+ }, {
2833
+ name: HandleClickSettings,
2834
+ params: ['handleClickSettings']
2696
2835
  }, {
2697
2836
  name: HandleClickUninstall,
2698
2837
  params: ['handleClickUninstall']
2838
+ }, {
2839
+ name: HandleClickSetColorTheme,
2840
+ params: ['handleClickSetColorTheme']
2699
2841
  }];
2700
2842
  };
2701
2843
 
@@ -2731,6 +2873,8 @@ const commandMap = {
2731
2873
  'ExtensionDetail.getCommandIds': getCommandIds,
2732
2874
  'ExtensionDetail.getMenuEntries': getMenuEntries,
2733
2875
  'ExtensionDetail.handleClickDisable': wrapCommand(handleClickDisable),
2876
+ 'ExtensionDetail.handleClickSettings': wrapCommand(handleClickSettings),
2877
+ 'ExtensionDetail.handleClickSetColorTheme': wrapCommand(handleClickSetColorTheme),
2734
2878
  'ExtensionDetail.handleClickSize': wrapCommand(handleClickSize),
2735
2879
  'ExtensionDetail.handleClickUninstall': wrapCommand(handleClickUninstall),
2736
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.24.0",
3
+ "version": "3.26.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",