@lvce-editor/extension-detail-view 3.10.0 → 3.12.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.
@@ -923,12 +923,15 @@ const Markdown = 'Markdown';
923
923
  const MoreInfo = 'MoreInfo';
924
924
  const MoreInfoEntry = 'MoreInfoEntry';
925
925
  const MoreInfoEntryKey = 'MoreInfoEntryKey';
926
+ const MoreInfoEntryOdd = 'MoreInfoEntryOdd';
926
927
  const MoreInfoEntryValue = 'MoreInfoEntryValue';
927
928
  const Normal$1 = 'Normal';
928
929
  const Resource = 'Resource';
929
930
  const Resources = 'Resources';
930
931
  const Small$1 = 'Small';
931
932
  const Table$1 = 'Table';
933
+ const TableCell = 'TableCell';
934
+ const TableHeading = 'TableHeading';
932
935
  const Viewlet = 'Viewlet';
933
936
 
934
937
  const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
@@ -1149,7 +1152,7 @@ const parentNodeEven = {
1149
1152
  };
1150
1153
  const parentNodeOdd = {
1151
1154
  type: Div$1,
1152
- className: MoreInfoEntry + ' ' + 'MoreInfoEntryOdd',
1155
+ className: MoreInfoEntry + ' ' + MoreInfoEntryOdd,
1153
1156
  childCount: 2
1154
1157
  };
1155
1158
  const getMoreInfoEntryVirtualDom = item => {
@@ -1168,16 +1171,17 @@ const getMoreInfoVirtualDom = items => {
1168
1171
  }, ...items.flatMap(getMoreInfoEntryVirtualDom)];
1169
1172
  };
1170
1173
 
1174
+ const resourceNode = {
1175
+ // TODO use link with url
1176
+ type: Div$1,
1177
+ className: Resource,
1178
+ childCount: 1
1179
+ };
1171
1180
  const getResourceVirtualDom = resource => {
1172
1181
  const {
1173
1182
  label
1174
1183
  } = resource;
1175
- return [{
1176
- // TODO use link with url
1177
- type: Div$1,
1178
- className: Resource,
1179
- childCount: 1
1180
- }, text(label)];
1184
+ return [resourceNode, text(label)];
1181
1185
  };
1182
1186
 
1183
1187
  const getResourcesVirtualDom = resources => {
@@ -1768,6 +1772,7 @@ const Elements = 'Elements';
1768
1772
  const FileMatch = 'File Match';
1769
1773
  const Id = 'ID';
1770
1774
  const JsonValidation$1 = 'Json Validation';
1775
+ const Label = 'Label';
1771
1776
  const OpenImageInNewTab = 'Open Image in New Tab';
1772
1777
  const OpenInNewTab = 'Open in New Tab';
1773
1778
  const ProgrammingLanguages$1 = 'Programming Languages';
@@ -1784,6 +1789,9 @@ const copy = () => {
1784
1789
  const openInNewTab = () => {
1785
1790
  return i18nString(OpenInNewTab);
1786
1791
  };
1792
+ const label = () => {
1793
+ return i18nString(Label);
1794
+ };
1787
1795
  const openImageInNewTab = () => {
1788
1796
  return i18nString(OpenImageInNewTab);
1789
1797
  };
@@ -1844,6 +1852,7 @@ const getCommandTableEntry = command => {
1844
1852
  value: label
1845
1853
  }];
1846
1854
  };
1855
+
1847
1856
  const getCommandTableEntries = extension => {
1848
1857
  const commands = extension.commands || [];
1849
1858
  const rows = commands.map(getCommandTableEntry);
@@ -1860,10 +1869,18 @@ const getFeatureContentHeadingVirtualDom = heading => {
1860
1869
  }, text(heading)];
1861
1870
  };
1862
1871
 
1872
+ const getTableHeadingVirtualDom = heading => {
1873
+ return [{
1874
+ type: Th,
1875
+ className: TableHeading,
1876
+ childCount: 1
1877
+ }, text(heading)];
1878
+ };
1879
+
1863
1880
  const getCellCodeVirtualDom = value => {
1864
1881
  return [{
1865
1882
  type: Td,
1866
- className: 'TableCell',
1883
+ className: TableCell,
1867
1884
  childCount: 1
1868
1885
  }, {
1869
1886
  type: Div$1,
@@ -1875,7 +1892,7 @@ const getCellCodeVirtualDom = value => {
1875
1892
  const getCellTextVirtualDom = value => {
1876
1893
  return [{
1877
1894
  type: Td,
1878
- className: 'TableCell',
1895
+ className: TableCell,
1879
1896
  childCount: 1
1880
1897
  }, text(value)];
1881
1898
  };
@@ -1900,20 +1917,13 @@ const getCellVirtualDom = entry => {
1900
1917
  return fn(value);
1901
1918
  };
1902
1919
 
1903
- const getTableHeadingVirtualDom = heading => {
1904
- return [{
1905
- type: Th,
1906
- className: 'TableHeading',
1907
- childCount: 1
1908
- }, text(heading)];
1909
- };
1910
-
1911
1920
  const getTableRowVirtualDom = entries => {
1912
1921
  return [{
1913
1922
  type: Tr,
1914
1923
  childCount: entries.length
1915
1924
  }, ...entries.flatMap(getCellVirtualDom)];
1916
1925
  };
1926
+
1917
1927
  const getTableVirtualDom = tableInfo => {
1918
1928
  const {
1919
1929
  headings,
@@ -1935,6 +1945,7 @@ const getTableVirtualDom = tableInfo => {
1935
1945
  }, ...rows.flatMap(getTableRowVirtualDom)];
1936
1946
  };
1937
1947
 
1948
+ // TODO have typed view-model
1938
1949
  const getFeatureCommandsVirtualDom = extension => {
1939
1950
  const heading = commands();
1940
1951
  const tableInfo = getCommandTableEntries(extension);
@@ -2014,11 +2025,14 @@ const getSettingsTableEntry = setting => {
2014
2025
  value: label
2015
2026
  }];
2016
2027
  };
2028
+
2017
2029
  const getSettingsTableEntries = extension => {
2018
2030
  const settings = extension.settings || [];
2019
2031
  const rows = settings.map(getSettingsTableEntry);
2032
+ const textId = id();
2033
+ const textLabel = label();
2020
2034
  return {
2021
- headings: ['ID', 'Label'],
2035
+ headings: [textId, textLabel],
2022
2036
  rows
2023
2037
  };
2024
2038
  };
@@ -2063,6 +2077,8 @@ const item = {
2063
2077
  className: DefinitionListItem,
2064
2078
  childCount: 2
2065
2079
  };
2080
+
2081
+ // TODO move json stringify to view model
2066
2082
  const getWebViewVirtualDom = webView => {
2067
2083
  const {
2068
2084
  id: id$1,
@@ -2264,7 +2280,13 @@ const getFeatures = (selectedFeature, extension) => {
2264
2280
  if (!selectedFeature) {
2265
2281
  selectedFeature = Theme;
2266
2282
  }
2267
- const features = [...ifElseFeature(Theme, 'Theme', hasThemes, selectedFeature, extension), ...ifElseFeature(Commands, 'Commands', hasCommands, selectedFeature, extension), ...ifElseFeature(JsonValidation, 'Json Validation', hasJsonValidation, selectedFeature, extension), ...ifElseFeature(ProgrammingLanguages, 'Programming Languages', hasProgrammingLanguages, selectedFeature, extension), ...ifElseFeature(Settings, 'Settings', hasSettings, selectedFeature, extension), ...ifElseFeature(WebViews, 'WebViews', hasWebViews, selectedFeature, extension)];
2283
+ const textTheme = theme();
2284
+ const textCommands = commands();
2285
+ const textJsonValidation = jsonValidation();
2286
+ const programmingLanguages$1 = programmingLanguages();
2287
+ const settings$1 = settings();
2288
+ const webViews$1 = webViews();
2289
+ const features = [...ifElseFeature(Theme, textTheme, hasThemes, selectedFeature, extension), ...ifElseFeature(Commands, textCommands, hasCommands, selectedFeature, extension), ...ifElseFeature(JsonValidation, textJsonValidation, hasJsonValidation, selectedFeature, extension), ...ifElseFeature(ProgrammingLanguages, programmingLanguages$1, hasProgrammingLanguages, selectedFeature, extension), ...ifElseFeature(Settings, settings$1, hasSettings, selectedFeature, extension), ...ifElseFeature(WebViews, webViews$1, hasWebViews, selectedFeature, extension)];
2268
2290
  return features;
2269
2291
  };
2270
2292
 
@@ -2378,6 +2400,13 @@ const getExtensionDetailVirtualDom = (extensionDetail, sanitizedReadmeHtml, sele
2378
2400
  return dom;
2379
2401
  };
2380
2402
 
2403
+ const getExtensionDetailVirtualDom2 = uid => {
2404
+ const {
2405
+ newState
2406
+ } = get$1(uid);
2407
+ return getExtensionDetailVirtualDom(newState, newState.sanitizedReadmeHtml, newState.selectedTab, newState);
2408
+ };
2409
+
2381
2410
  const None = 0;
2382
2411
 
2383
2412
  const getCopyMenuEntry = () => ({
@@ -5305,11 +5334,21 @@ const loadContent = async (state, platform, savedState) => {
5305
5334
  };
5306
5335
  };
5307
5336
 
5308
- const saveState = state => {
5337
+ const resize = (state, dimensions) => {
5338
+ return {
5339
+ ...state,
5340
+ ...dimensions
5341
+ };
5342
+ };
5343
+
5344
+ const saveState = uid => {
5345
+ const {
5346
+ newState
5347
+ } = get$1(uid);
5309
5348
  const {
5310
5349
  selectedTab,
5311
5350
  selectedFeature
5312
- } = state;
5351
+ } = newState;
5313
5352
  return {
5314
5353
  selectedTab,
5315
5354
  selectedFeature
@@ -5320,21 +5359,40 @@ const terminate = () => {
5320
5359
  globalThis.close();
5321
5360
  };
5322
5361
 
5362
+ const wrapCommand = fn => {
5363
+ const wrapped = async (uid, ...args) => {
5364
+ if (typeof uid === 'number') {
5365
+ const {
5366
+ newState
5367
+ } = get$1(uid);
5368
+ const newerState = await fn(newState, ...args);
5369
+ set$1(uid, newState, newerState);
5370
+ } else {
5371
+ // deprecated
5372
+ const newerState = await fn(uid, ...args);
5373
+ return newerState;
5374
+ }
5375
+ };
5376
+ return wrapped;
5377
+ };
5378
+
5323
5379
  const commandMap = {
5324
5380
  'ExtensionDetail.create': create,
5325
5381
  'ExtensionDetail.getMenuEntries': getMenuEntries,
5326
- 'ExtensionDetail.getVirtualDom': getExtensionDetailVirtualDom,
5327
- 'ExtensionDetail.handleClickDisable': handleClickDisable,
5328
- 'ExtensionDetail.handleClickSize': handleClickSize,
5329
- 'ExtensionDetail.handleClickUninstall': handleClickUninstall,
5330
- 'ExtensionDetail.handleFeaturesClick': handleClickFeatures,
5331
- 'ExtensionDetail.handleIconError': handleIconError,
5332
- 'ExtensionDetail.handleTabsClick': handleTabsClick,
5333
- 'ExtensionDetail.loadContent': loadContent,
5382
+ 'ExtensionDetail.getVirtualDom2': getExtensionDetailVirtualDom2,
5383
+ 'ExtensionDetail.handleClickDisable': wrapCommand(handleClickDisable),
5384
+ 'ExtensionDetail.handleClickSize': wrapCommand(handleClickSize),
5385
+ 'ExtensionDetail.handleClickUninstall': wrapCommand(handleClickUninstall),
5386
+ 'ExtensionDetail.handleFeaturesClick': wrapCommand(handleClickFeatures),
5387
+ 'ExtensionDetail.handleIconError': wrapCommand(handleIconError),
5388
+ 'ExtensionDetail.handleTabsClick': wrapCommand(handleTabsClick),
5389
+ 'ExtensionDetail.loadContent': wrapCommand(loadContent),
5390
+ 'ExtensionDetail.resize': resize,
5334
5391
  'ExtensionDetail.saveState': saveState,
5335
- 'ExtensionDetail.selectTab': selectTab,
5392
+ 'ExtensionDetail.selectTab': wrapCommand(selectTab),
5336
5393
  'ExtensionDetail.terminate': terminate,
5337
5394
  // deprecated
5395
+ 'ExtensionDetail.getVirtualDom': wrapCommand(getExtensionDetailVirtualDom),
5338
5396
  'HandleIconError.handleIconError': handleIconError,
5339
5397
  'RenderMarkdown.renderMarkdown': renderMarkdown
5340
5398
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "3.10.0",
3
+ "version": "3.12.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "keywords": [],
6
6
  "license": "MIT",