@lvce-editor/extension-detail-view 3.46.0 → 3.48.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.
package/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  Webworker for the extension detail view in Lvce Editor.
4
4
 
5
+ ## Contributing
6
+
7
+ ```sh
8
+ git clone git@github.com:lvce-editor/extension-detail-view.git &&
9
+ cd extension-detail-view &&
10
+ npm ci &&
11
+ npm test
12
+ ```
13
+
5
14
  ## Gitpod
6
15
 
7
16
  [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/extension-detail-view)
@@ -807,15 +807,25 @@ const openNativeFolder$1 = async uri => {
807
807
  const uninstallExtension$1 = async id => {
808
808
  return invoke$3('ExtensionManagement.uninstall', id);
809
809
  };
810
+ const openExtensionSearch$2 = async () => {
811
+ // @ts-ignore
812
+ return invoke$3('SideBar.openViewlet', 'Extensions');
813
+ };
814
+ const setExtensionsSearchValue$1 = async value => {
815
+ // @ts-ignore
816
+ return invoke$3('Extensions.handleInput', searchValue);
817
+ };
810
818
  const RendererWorker = {
811
819
  __proto__: null,
812
820
  getAllExtensions: getAllExtensions$2,
813
821
  getExtension: getExtension$3,
822
+ openExtensionSearch: openExtensionSearch$2,
814
823
  openNativeFolder: openNativeFolder$1,
815
824
  sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$2,
816
825
  sendMessagePortToMarkdownWorker: sendMessagePortToMarkdownWorker$2,
817
826
  set: set$3$1,
818
827
  setColorTheme: setColorTheme$2,
828
+ setExtensionsSearchValue: setExtensionsSearchValue$1,
819
829
  uninstallExtension: uninstallExtension$1};
820
830
 
821
831
  const {
@@ -2042,8 +2052,13 @@ const WebWorkerRpcClient = {
2042
2052
  create: create$2
2043
2053
  };
2044
2054
 
2055
+ const toCommandId = key => {
2056
+ const dotIndex = key.indexOf('.');
2057
+ return key.slice(dotIndex + 1);
2058
+ };
2045
2059
  const create$1 = () => {
2046
2060
  const states = Object.create(null);
2061
+ const commandMapRef = {};
2047
2062
  return {
2048
2063
  get(uid) {
2049
2064
  return states[uid];
@@ -2084,6 +2099,15 @@ const create$1 = () => {
2084
2099
  };
2085
2100
  return wrapped;
2086
2101
  },
2102
+ wrapGetter(fn) {
2103
+ const wrapped = (uid, ...args) => {
2104
+ const {
2105
+ newState
2106
+ } = states[uid];
2107
+ return fn(newState, ...args);
2108
+ };
2109
+ return wrapped;
2110
+ },
2087
2111
  diff(uid, modules, numbers) {
2088
2112
  const {
2089
2113
  oldState,
@@ -2097,6 +2121,14 @@ const create$1 = () => {
2097
2121
  }
2098
2122
  }
2099
2123
  return diffResult;
2124
+ },
2125
+ getCommandIds() {
2126
+ const keys = Object.keys(commandMapRef);
2127
+ const ids = keys.map(toCommandId);
2128
+ return ids;
2129
+ },
2130
+ registerCommands(commandMap) {
2131
+ Object.assign(commandMapRef, commandMap);
2100
2132
  }
2101
2133
  };
2102
2134
  };
@@ -2112,7 +2144,8 @@ const {
2112
2144
  get,
2113
2145
  set: set$2,
2114
2146
  dispose: dispose$1,
2115
- wrapCommand
2147
+ wrapCommand,
2148
+ wrapGetter
2116
2149
  } = create$1();
2117
2150
 
2118
2151
  const create = (uid, uri, x, y, width, height, platform, assetDir) => {
@@ -2128,6 +2161,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
2128
2161
  changelogScrollTop: 0,
2129
2162
  changelogVirtualDom: [],
2130
2163
  commands: [],
2164
+ hasReadme: false,
2131
2165
  description: '',
2132
2166
  detailsVirtualDom: [],
2133
2167
  displaySize: '',
@@ -2172,7 +2206,7 @@ const isEqual$2 = (oldState, newState) => {
2172
2206
  };
2173
2207
 
2174
2208
  const isEqual$1 = (oldState, newState) => {
2175
- return oldState.activationEvents === newState.activationEvents && oldState.badge === newState.badge && oldState.categories === newState.categories && oldState.changelogVirtualDom === newState.changelogVirtualDom && oldState.commands === newState.commands && oldState.description === newState.description && oldState.detailsVirtualDom === newState.detailsVirtualDom && oldState.displaySize === newState.displaySize && oldState.extensionId === newState.extensionId && oldState.extensionVersion === newState.extensionVersion && oldState.jsonValidation === newState.jsonValidation && oldState.selectedFeature === newState.selectedFeature && oldState.selectedTab === newState.selectedTab && oldState.settings === newState.settings && oldState.themesMarkdownDom === newState.themesMarkdownDom && oldState.webViews === newState.webViews;
2209
+ return oldState.activationEvents === newState.activationEvents && oldState.badge === newState.badge && oldState.categories === newState.categories && oldState.changelogVirtualDom === newState.changelogVirtualDom && oldState.commands === newState.commands && oldState.description === newState.description && oldState.detailsVirtualDom === newState.detailsVirtualDom && oldState.displaySize === newState.displaySize && oldState.extensionId === newState.extensionId && oldState.extensionVersion === newState.extensionVersion && oldState.jsonValidation === newState.jsonValidation && oldState.selectedFeature === newState.selectedFeature && oldState.selectedTab === newState.selectedTab && oldState.settings === newState.settings && oldState.themesMarkdownDom === newState.themesMarkdownDom && oldState.webViews === newState.webViews && oldState.sizeValue === newState.sizeValue;
2176
2210
  };
2177
2211
 
2178
2212
  const User = 1;
@@ -2257,8 +2291,30 @@ const getLinkMenuEntries = props => {
2257
2291
 
2258
2292
  const getMenuEntries = props => [...getLinkMenuEntries(props), ...getImageMenuEntries(props), getCopyMenuEntry()];
2259
2293
 
2294
+ const {
2295
+ getAllExtensions: getAllExtensions$1,
2296
+ getExtension: getExtension$2,
2297
+ openExtensionSearch: openExtensionSearch$1,
2298
+ openNativeFolder,
2299
+ sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1,
2300
+ sendMessagePortToMarkdownWorker: sendMessagePortToMarkdownWorker$1,
2301
+ set: set$1,
2302
+ setColorTheme: setColorTheme$1,
2303
+ setExtensionsSearchValue,
2304
+ uninstallExtension
2305
+ } = RendererWorker;
2306
+
2307
+ const openExtensionSearch = async searchValue => {
2308
+ await openExtensionSearch$1();
2309
+ await setExtensionsSearchValue(searchValue);
2310
+ };
2311
+
2260
2312
  const handleClickCategory = async (state, categoryId) => {
2261
- // TODO: Implement category click functionality
2313
+ if (!categoryId) {
2314
+ return state;
2315
+ }
2316
+ const searchValue = `@category:"${categoryId}"`;
2317
+ await openExtensionSearch(searchValue);
2262
2318
  return state;
2263
2319
  };
2264
2320
 
@@ -2314,17 +2370,6 @@ const handleClickScrollToTop = state => {
2314
2370
  };
2315
2371
  };
2316
2372
 
2317
- const {
2318
- getAllExtensions: getAllExtensions$1,
2319
- getExtension: getExtension$2,
2320
- openNativeFolder,
2321
- set: set$1,
2322
- setColorTheme: setColorTheme$1,
2323
- uninstallExtension,
2324
- sendMessagePortToMarkdownWorker: sendMessagePortToMarkdownWorker$1,
2325
- sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1
2326
- } = RendererWorker;
2327
-
2328
2373
  const setColorTheme = id => {
2329
2374
  return setColorTheme$1(id);
2330
2375
  };
@@ -3109,21 +3154,22 @@ const loadContent = async (state, platform, savedState) => {
3109
3154
  description,
3110
3155
  detailsVirtualDom,
3111
3156
  displaySize,
3112
- installationEntries,
3113
3157
  extension,
3114
3158
  extensionId,
3115
3159
  extensionVersion,
3116
3160
  features,
3117
3161
  folderSize,
3118
3162
  hasColorTheme,
3163
+ hasReadme,
3119
3164
  iconSrc,
3165
+ installationEntries,
3166
+ marketplaceEntries,
3120
3167
  name,
3121
3168
  readmeScrollTop,
3122
3169
  readmeUrl,
3123
3170
  resources,
3124
3171
  scrollSource: Script,
3125
3172
  scrollToTopButtonEnabled: true,
3126
- marketplaceEntries,
3127
3173
  selectedTab,
3128
3174
  sizeOnDisk: size,
3129
3175
  sizeValue,
@@ -3299,19 +3345,24 @@ const getChildCount = (additionalDetails, scrollToTopEnabled) => {
3299
3345
  }
3300
3346
  return count;
3301
3347
  };
3302
- const getDetailsVirtualDom = (sanitizedReadmeHtml, width, scrollToTopButtonEnabled, categories$1, resources$1, showAdditionalDetailsBreakpoint, installationEntries, marketplaceEntries) => {
3348
+ const getDetailsVirtualDom = (sanitizedReadmeHtml, width, scrollToTopButtonEnabled, categories$1, resources$1, showAdditionalDetailsBreakpoint, installationEntries, marketplaceEntries, hasReadme) => {
3303
3349
  const firstHeading = installation();
3304
3350
  const secondHeading = marketplace();
3305
3351
  const thirdHeading = categories();
3306
3352
  const fourthHeading = resources();
3307
3353
  const showAdditionalDetails = width > showAdditionalDetailsBreakpoint;
3308
3354
  const childCount = getChildCount(showAdditionalDetails);
3355
+ const contentDom = hasReadme ? sanitizedReadmeHtml : [{
3356
+ type: VirtualDomElements.Div,
3357
+ childCount: 1,
3358
+ className: 'Markdown'
3359
+ }, text(noReadmeFound())];
3309
3360
  const dom = [{
3310
3361
  type: VirtualDomElements.Div,
3311
3362
  className: ExtensionDetailPanel,
3312
3363
  childCount: childCount,
3313
3364
  role: AriaRoles.Panel
3314
- }, ...sanitizedReadmeHtml, ...getAdditionalDetailsVirtualDom(showAdditionalDetails, firstHeading, installationEntries, secondHeading, marketplaceEntries, thirdHeading, categories$1, fourthHeading, resources$1)];
3365
+ }, ...contentDom, ...getAdditionalDetailsVirtualDom(showAdditionalDetails, firstHeading, installationEntries, secondHeading, marketplaceEntries, thirdHeading, categories$1, fourthHeading, resources$1)];
3315
3366
  return dom;
3316
3367
  };
3317
3368
 
@@ -3366,7 +3417,7 @@ const getFeaturesVirtualDom = (features, selectedFeature, state) => {
3366
3417
  const getExtensionDetailContentVirtualDom = (sanitizedReadmeHtml, selectedTab, width, scrollToTopButtonEnabled, categories, resources, breakpoint, changelogDom, state) => {
3367
3418
  switch (selectedTab) {
3368
3419
  case Details:
3369
- return getDetailsVirtualDom(sanitizedReadmeHtml, width, scrollToTopButtonEnabled, categories, resources, breakpoint, state.installationEntries, state.marketplaceEntries);
3420
+ return getDetailsVirtualDom(sanitizedReadmeHtml, width, scrollToTopButtonEnabled, categories, resources, breakpoint, state.installationEntries, state.marketplaceEntries, state.hasReadme);
3370
3421
  case Features:
3371
3422
  return getFeaturesVirtualDom(state.features, state.selectedFeature, state);
3372
3423
  case Changelog:
@@ -3630,7 +3681,6 @@ const renderEventListeners = () => {
3630
3681
  params: ['handleReadmeContextMenu', 'event.clientX', 'event.clientY', 'event.target.href', 'event.target.src']
3631
3682
  }, {
3632
3683
  name: HandleReadmeScroll,
3633
- // @ts-ignore
3634
3684
  params: ['handleScroll', 'event.target.scrollTop', User],
3635
3685
  passive: true
3636
3686
  }, {
@@ -3668,16 +3718,13 @@ const resize = (state, dimensions) => {
3668
3718
  };
3669
3719
  };
3670
3720
 
3671
- const saveState = uid => {
3672
- const {
3673
- newState
3674
- } = get(uid);
3721
+ const saveState = state => {
3675
3722
  const {
3676
3723
  selectedTab,
3677
3724
  selectedFeature,
3678
3725
  readmeScrollTop,
3679
3726
  changelogScrollTop
3680
- } = newState;
3727
+ } = state;
3681
3728
  return {
3682
3729
  selectedTab,
3683
3730
  selectedFeature,
@@ -3709,8 +3756,9 @@ const commandMap = {
3709
3756
  'ExtensionDetail.loadContent2': wrapCommand(loadContent2),
3710
3757
  'ExtensionDetail.render2': render2,
3711
3758
  'ExtensionDetail.renderEventListeners': renderEventListeners,
3712
- 'ExtensionDetail.resize': resize,
3713
- 'ExtensionDetail.saveState': saveState,
3759
+ 'ExtensionDetail.resize': wrapCommand(resize),
3760
+ // @ts-ignore
3761
+ 'ExtensionDetail.saveState': wrapGetter(saveState),
3714
3762
  'ExtensionDetail.selectTab': wrapCommand(selectTab),
3715
3763
  'ExtensionDetail.terminate': terminate,
3716
3764
  'ExtensionDetail.initialize': initialize
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "3.46.0",
3
+ "version": "3.48.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",