@lvce-editor/extension-detail-view 4.8.0 → 4.10.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.
@@ -27,6 +27,10 @@ const Enable$1 = 'Enable';
27
27
  const Features$2 = 'Features';
28
28
  const FileMatch = 'File Match';
29
29
  const Id = 'ID';
30
+ const Name = 'Name';
31
+ const FileExtensions = 'File Extensions';
32
+ const Grammar = 'Grammar';
33
+ const Snippets = 'Snippets';
30
34
  const Identifier = 'Identifier';
31
35
  const ImportTime = 'Import Time: ';
32
36
  const Installation = 'Installation';
@@ -151,6 +155,18 @@ const settings = () => {
151
155
  const id$1 = () => {
152
156
  return i18nString(Id);
153
157
  };
158
+ const name = () => {
159
+ return i18nString(Name);
160
+ };
161
+ const fileExtensions = () => {
162
+ return i18nString(FileExtensions);
163
+ };
164
+ const grammar = () => {
165
+ return i18nString(Grammar);
166
+ };
167
+ const snippets = () => {
168
+ return i18nString(Snippets);
169
+ };
154
170
  const selector = () => {
155
171
  return i18nString(Selector);
156
172
  };
@@ -258,8 +274,15 @@ const getActivationEventsDetails = async extension => {
258
274
  };
259
275
  };
260
276
 
277
+ const hasProperty = (object, key) => {
278
+ if (!object || typeof object !== 'object' || !(key in object)) {
279
+ return false;
280
+ }
281
+ return true;
282
+ };
283
+
261
284
  const featureActivationEventsEnabled = extension => {
262
- if (!extension || typeof extension !== 'object' || !('activation' in extension)) {
285
+ if (!hasProperty(extension, 'activation')) {
263
286
  return false;
264
287
  }
265
288
  return Array.isArray(extension.activation);
@@ -446,7 +469,7 @@ const getCommandsDetails = async extension => {
446
469
  };
447
470
 
448
471
  const featureCommandsEnabled = extension => {
449
- if (!extension || typeof extension !== 'object' || !('commands' in extension)) {
472
+ if (!hasProperty(extension, 'commands')) {
450
473
  return false;
451
474
  }
452
475
  return Array.isArray(extension.commands);
@@ -782,7 +805,7 @@ const getJsonValidationDetails = async extension => {
782
805
  };
783
806
 
784
807
  const featureJsonValidationEnabled = extension => {
785
- if (!extension || typeof extension !== 'object' || !('jsonValidation' in extension)) {
808
+ if (!hasProperty(extension, 'jsonValidation')) {
786
809
  return false;
787
810
  }
788
811
  return Array.isArray(extension.jsonValidation);
@@ -810,33 +833,56 @@ const getJsonValidationVirtualDom = state => {
810
833
  return getFeatureJsonValidationVirtualDom(state.jsonValidation);
811
834
  };
812
835
 
813
- const getProgrammingLanguagesDetails = async extension => {
814
- // Programming languages feature doesn't need to store additional state
815
- return {};
836
+ const getProgrammingLanguageTableEntry = programmingLanguage => {
837
+ return [];
838
+ };
839
+
840
+ const getFeatureDetailsProgrammingLanguages = async extension => {
841
+ // TODO validate them also, to create better types
842
+ const programmingLanguages = extension.languages || [];
843
+ const rows = programmingLanguages.map(getProgrammingLanguageTableEntry);
844
+ return {
845
+ programmingLanguages: rows
846
+ };
816
847
  };
817
848
 
818
849
  const featureProgrammingLanguagesEnabled = extension => {
819
- if (!extension || typeof extension !== 'object' || !('programmingLanguages' in extension)) {
850
+ if (!hasProperty(extension, 'languages')) {
820
851
  return false;
821
852
  }
822
853
  const {
823
- programmingLanguages
854
+ languages
824
855
  } = extension;
825
- return Array.isArray(programmingLanguages);
856
+ return Array.isArray(languages);
826
857
  };
827
858
 
828
- const getFeatureProgrammingLanguagesVirtualDom = () => {
859
+ const getProgrammingLanguagesTableEntries = rows => {
860
+ const id = id$1();
861
+ const name$1 = name();
862
+ const fileExtensions$1 = fileExtensions();
863
+ const grammar$1 = grammar();
864
+ const snippets$1 = snippets();
865
+ return {
866
+ headings: [id, name$1, fileExtensions$1, grammar$1, snippets$1],
867
+ rows
868
+ };
869
+ };
870
+
871
+ const getFeatureProgrammingLanguagesVirtualDom = programmingLanguages$1 => {
829
872
  const heading = programmingLanguages();
830
- // TODO
873
+ const tableInfo = getProgrammingLanguagesTableEntries(programmingLanguages$1);
831
874
  return [{
832
875
  type: Div,
833
876
  className: FeatureContent,
834
- childCount: 1
835
- }, ...getFeatureContentHeadingVirtualDom(heading)];
877
+ childCount: 2
878
+ }, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
836
879
  };
837
880
 
838
881
  const getProgrammingLanguagesVirtualDom = state => {
839
- return getFeatureProgrammingLanguagesVirtualDom();
882
+ const {
883
+ programmingLanguages
884
+ } = state;
885
+ return getFeatureProgrammingLanguagesVirtualDom(programmingLanguages);
840
886
  };
841
887
 
842
888
  class FeatureNotFoundError extends Error {
@@ -2602,7 +2648,7 @@ const getSettingsDetails = async extension => {
2602
2648
  };
2603
2649
 
2604
2650
  const featureSettingsEnabled = extension => {
2605
- if (!extension || typeof extension !== 'object' || !('settings' in extension)) {
2651
+ if (!hasProperty(extension, 'settings')) {
2606
2652
  return false;
2607
2653
  }
2608
2654
  return Array.isArray(extension.settings);
@@ -2846,21 +2892,21 @@ const getThemeDetails = async (extension, baseUrl, locationProtocol) => {
2846
2892
  };
2847
2893
 
2848
2894
  const featureColorThemeEnabled = extension => {
2849
- if (!extension || typeof extension !== 'object' || !('colorThemes' in extension)) {
2895
+ if (!hasProperty(extension, 'colorThemes')) {
2850
2896
  return false;
2851
2897
  }
2852
2898
  return Array.isArray(extension.colorThemes);
2853
2899
  };
2854
2900
 
2855
2901
  const featureIconThemeEnabled = extension => {
2856
- if (!extension || typeof extension !== 'object' || !('iconThemes' in extension)) {
2902
+ if (!hasProperty(extension, 'iconThemes')) {
2857
2903
  return false;
2858
2904
  }
2859
2905
  return Array.isArray(extension.iconThemes);
2860
2906
  };
2861
2907
 
2862
2908
  const featureProductIconThemeEnabled = extension => {
2863
- if (!extension || typeof extension !== 'object' || !('productIconThemes' in extension)) {
2909
+ if (!hasProperty(extension, 'productIconThemes')) {
2864
2910
  return false;
2865
2911
  }
2866
2912
  return Array.isArray(extension.productIconThemes);
@@ -2929,7 +2975,7 @@ const getWebViewsDetails = async extension => {
2929
2975
  };
2930
2976
 
2931
2977
  const featureWebViewsEnabled = extension => {
2932
- if (!extension || typeof extension !== 'object' || !('webViews' in extension)) {
2978
+ if (!hasProperty(extension, 'webViews')) {
2933
2979
  return false;
2934
2980
  }
2935
2981
  return Array.isArray(extension.webViews);
@@ -3017,7 +3063,7 @@ const registerAllFeatures = () => {
3017
3063
  id: ProgrammingLanguages,
3018
3064
  getLabel: programmingLanguages,
3019
3065
  isEnabled: featureProgrammingLanguagesEnabled,
3020
- getDetails: getProgrammingLanguagesDetails,
3066
+ getDetails: getFeatureDetailsProgrammingLanguages,
3021
3067
  getVirtualDom: getProgrammingLanguagesVirtualDom
3022
3068
  });
3023
3069
  register$1({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "4.8.0",
3
+ "version": "4.10.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",