@lvce-editor/extension-detail-view 5.3.0 → 5.6.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
@@ -11,10 +11,6 @@ npm ci &&
11
11
  npm test
12
12
  ```
13
13
 
14
- ## Gitpod
15
-
16
- [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/extension-detail-view)
17
-
18
14
  ## Credits
19
15
 
20
16
  The extension detail view is based on VSCode's extension detail view.
@@ -331,6 +331,8 @@ const ExtensionDetailIconContextMenu$3 = 4091;
331
331
 
332
332
  const None$2 = 0;
333
333
 
334
+ const Web$1 = 1;
335
+
334
336
  const DebugWorker = 55;
335
337
  const ExtensionHostWorker = 44;
336
338
  const FileSystemWorker$1 = 209;
@@ -358,6 +360,8 @@ const ButtonPrimary = 'ButtonPrimary';
358
360
  const Categories = 'Categories';
359
361
  const Category = 'Category';
360
362
  const Changelog$1 = 'Changelog';
363
+ const MaskIcon = 'MaskIcon';
364
+ const ResourceIcon = 'ResourceIcon';
361
365
  const Code$1 = 'Code';
362
366
  const DefaultMarkdown = 'DefaultMarkdown';
363
367
  const DefinitionListItem = 'DefinitionListItem';
@@ -567,15 +571,21 @@ const getCellCodeVirtualDom = (value, props) => {
567
571
  }, text(value)];
568
572
  };
569
573
 
574
+ const getTitleProps = title => {
575
+ if (title) {
576
+ return {
577
+ title
578
+ };
579
+ }
580
+ return {};
581
+ };
570
582
  const getCellLinkVirtualDom = (value, props) => {
571
583
  const tdClassName = props?.className ? `${TableCell} ${props.className}` : TableCell;
572
584
  return [{
573
585
  type: Td,
574
586
  className: tdClassName,
575
587
  childCount: 1,
576
- ...(props?.title ? {
577
- title: props.title
578
- } : {})
588
+ ...getTitleProps(props?.title)
579
589
  }, {
580
590
  type: A,
581
591
  className: Link$1,
@@ -3365,13 +3375,9 @@ const {
3365
3375
 
3366
3376
  const create = (uid, uri, x, y, width, height, platform, assetDir) => {
3367
3377
  const state = {
3368
- wasActivatedByEvent: '',
3369
- activationTime: 0,
3370
- importTime: 0,
3371
- disabled: false,
3372
- status: 0,
3373
- uid,
3378
+ activationEntries: [],
3374
3379
  activationEvents: [],
3380
+ activationTime: 0,
3375
3381
  assetDir: assetDir || '',
3376
3382
  badge: '',
3377
3383
  baseUrl: '',
@@ -3380,52 +3386,57 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
3380
3386
  categories: [],
3381
3387
  changelogScrollTop: 0,
3382
3388
  changelogVirtualDom: [],
3383
- extensionUri: '',
3384
3389
  commands: [],
3385
- hasReadme: false,
3386
3390
  description: '',
3387
3391
  detailsVirtualDom: [],
3392
+ disabled: false,
3388
3393
  displaySize: '',
3389
3394
  downloadCount: 'n/a',
3390
- installationEntries: [],
3391
3395
  extension: {},
3392
3396
  extensionId: '',
3397
+ extensionUri: '',
3393
3398
  extensionVersion: '',
3394
3399
  features: [],
3395
3400
  featuresVirtualDom: [],
3396
3401
  focus: 0,
3397
3402
  folderSize: 0,
3398
3403
  hasColorTheme: false,
3404
+ hasReadme: false,
3399
3405
  iconSrc: '',
3406
+ importTime: 0,
3407
+ installationEntries: [],
3400
3408
  jsonValidation: [],
3409
+ locationProtocol: '',
3410
+ marketplaceEntries: [],
3401
3411
  name: '',
3412
+ paddingLeft: 0,
3413
+ paddingRight: 0,
3402
3414
  platform,
3403
3415
  programmingLanguages: [],
3404
3416
  rating: 'n/a',
3405
3417
  readmeScrollTop: 0,
3418
+ readmeUrl: '',
3406
3419
  resources: [],
3407
3420
  scrollSource: 0,
3408
3421
  scrollToTopButtonEnabled: false,
3409
- marketplaceEntries: [],
3410
3422
  selectedFeature: '',
3411
3423
  selectedTab: '',
3412
3424
  settings: [],
3413
3425
  settingsButtonEnabled: false,
3414
3426
  showAdditionalDetailsBreakpoint: 700,
3427
+ showSideBar: true,
3428
+ sideBarWidth: 0,
3415
3429
  sizeOnDisk: 0,
3416
3430
  sizeValue: 0,
3431
+ status: 0,
3417
3432
  tabs: [],
3418
3433
  themesMarkdownDom: [],
3434
+ uid,
3419
3435
  uri,
3436
+ wasActivatedByEvent: '',
3420
3437
  webViews: [],
3421
3438
  width,
3422
- readmeUrl: '',
3423
- paddingLeft: 0,
3424
- paddingRight: 0,
3425
- showSideBar: true,
3426
- sideBarWidth: 0,
3427
- locationProtocol: '',
3428
- activationEntries: []
3439
+ showSizeLink: false
3429
3440
  };
3430
3441
  set(uid, state, state);
3431
3442
  };
@@ -3439,7 +3450,7 @@ const isEqual$2 = (oldState, newState) => {
3439
3450
  };
3440
3451
 
3441
3452
  const isEqual$1 = (oldState, newState) => {
3442
- return oldState.activationEvents === newState.activationEvents && oldState.badge === newState.badge && oldState.buttons === newState.buttons && oldState.categories === newState.categories && oldState.changelogVirtualDom === newState.changelogVirtualDom && oldState.commands === newState.commands && oldState.description === newState.description && oldState.detailsVirtualDom === newState.detailsVirtualDom && oldState.disabled === newState.disabled && oldState.displaySize === newState.displaySize && oldState.extensionId === newState.extensionId && oldState.extensionVersion === newState.extensionVersion && oldState.features === newState.features && oldState.jsonValidation === newState.jsonValidation && oldState.resources === newState.resources && oldState.selectedFeature === newState.selectedFeature && oldState.selectedTab === newState.selectedTab && oldState.settings === newState.settings && oldState.showSideBar === newState.showSideBar && oldState.sizeValue === newState.sizeValue && oldState.themesMarkdownDom === newState.themesMarkdownDom && oldState.webViews === newState.webViews;
3453
+ return oldState.activationEvents === newState.activationEvents && oldState.badge === newState.badge && oldState.buttons === newState.buttons && oldState.categories === newState.categories && oldState.changelogVirtualDom === newState.changelogVirtualDom && oldState.commands === newState.commands && oldState.description === newState.description && oldState.detailsVirtualDom === newState.detailsVirtualDom && oldState.disabled === newState.disabled && oldState.displaySize === newState.displaySize && oldState.extensionId === newState.extensionId && oldState.extensionVersion === newState.extensionVersion && oldState.features === newState.features && oldState.installationEntries === newState.installationEntries && oldState.jsonValidation === newState.jsonValidation && oldState.resources === newState.resources && oldState.selectedFeature === newState.selectedFeature && oldState.selectedTab === newState.selectedTab && oldState.settings === newState.settings && oldState.showSideBar === newState.showSideBar && oldState.sizeValue === newState.sizeValue && oldState.themesMarkdownDom === newState.themesMarkdownDom && oldState.webViews === newState.webViews;
3443
3454
  };
3444
3455
 
3445
3456
  const User = 1;
@@ -4057,6 +4068,53 @@ const handleTabsClick = (state, name) => {
4057
4068
  return selectTab(state, name);
4058
4069
  };
4059
4070
 
4071
+ const getSizeEntries = (showSizeLink, displaySize, extensionUri) => {
4072
+ if (!showSizeLink) {
4073
+ return [];
4074
+ }
4075
+ return [{
4076
+ key: size(),
4077
+ value: displaySize,
4078
+ onClick: HandleClickSize,
4079
+ title: extensionUri
4080
+ }];
4081
+ };
4082
+
4083
+ const getInstallationEntries = (displaySize, extensionId, extensionVersion, extensionUri, showSizeLink) => {
4084
+ const entries = [{
4085
+ key: identifier(),
4086
+ value: extensionId,
4087
+ odd: true,
4088
+ code: true
4089
+ }, {
4090
+ key: version(),
4091
+ value: extensionVersion,
4092
+ code: true
4093
+ }, {
4094
+ key: lastUpdated(),
4095
+ value: 'n/a',
4096
+ // TODO get this from somewhere
4097
+ odd: true
4098
+ }, ...getSizeEntries(showSizeLink, displaySize, extensionUri)];
4099
+ return entries;
4100
+ };
4101
+
4102
+ const hideSizeLink = state => {
4103
+ const {
4104
+ displaySize,
4105
+ extensionId,
4106
+ extensionVersion,
4107
+ extensionUri
4108
+ } = state;
4109
+ const newShowSizeLink = false;
4110
+ const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri, newShowSizeLink);
4111
+ return {
4112
+ ...state,
4113
+ installationEntries,
4114
+ showSizeLink: newShowSizeLink
4115
+ };
4116
+ };
4117
+
4060
4118
  const sendMessagePortToExtensionHostWorker = async port => {
4061
4119
  await sendMessagePortToExtensionHostWorker$1(port, 0);
4062
4120
  };
@@ -4508,30 +4566,6 @@ const getFolderSize = async uri => {
4508
4566
  }
4509
4567
  };
4510
4568
 
4511
- const getInstallationEntries = (displaySize, extensionId, extensionVersion, extensionUri) => {
4512
- const entries = [{
4513
- key: identifier(),
4514
- value: extensionId,
4515
- odd: true,
4516
- code: true
4517
- }, {
4518
- key: version(),
4519
- value: extensionVersion,
4520
- code: true
4521
- }, {
4522
- key: lastUpdated(),
4523
- value: 'n/a',
4524
- // TODO get this from somewhere
4525
- odd: true
4526
- }, {
4527
- key: size(),
4528
- value: displaySize,
4529
- onClick: HandleClickSize,
4530
- title: extensionUri
4531
- }];
4532
- return entries;
4533
- };
4534
-
4535
4569
  const getMarketplaceEntries = isBuiltin => {
4536
4570
  if (isBuiltin) {
4537
4571
  return [];
@@ -4546,47 +4580,73 @@ const getMarketplaceEntries = isBuiltin => {
4546
4580
  }];
4547
4581
  };
4548
4582
 
4549
- const getRepositoryLink = extension => {
4583
+ const getLicenseLink = extension => {
4584
+ // TODO
4585
+ return '#';
4586
+ };
4587
+
4588
+ const getRepositoryLinkRaw = extension => {
4550
4589
  if (extension && hasProperty(extension, 'repository') && typeof extension.repository === 'string') {
4551
4590
  return extension.repository; // TODO watch out for javascript: or other invalid links or path traversal
4552
4591
  }
4553
4592
  return '';
4554
4593
  };
4594
+ const ensureValidLink = link => {
4595
+ if (!link) {
4596
+ return '';
4597
+ }
4598
+ const parsed = new URL(link);
4599
+ if (parsed.protocol !== 'https:') {
4600
+ return '';
4601
+ }
4602
+ return link;
4603
+ };
4604
+ const getRepositoryLink = extension => {
4605
+ const raw = getRepositoryLinkRaw(extension);
4606
+ const validLink = ensureValidLink(raw);
4607
+ return validLink;
4608
+ };
4609
+
4555
4610
  const getResources = (isBuiltin, extension) => {
4556
4611
  if (isBuiltin) {
4557
4612
  return [];
4558
4613
  }
4559
4614
  const repositoryLink = getRepositoryLink(extension);
4615
+ const licenseLink = getLicenseLink();
4560
4616
  // TODO
4561
4617
  return [{
4562
4618
  label: marketplace(),
4563
- url: '#'
4619
+ url: '#',
4620
+ icon: 'LinkExternal'
4564
4621
  }, {
4565
4622
  label: issues(),
4566
- url: repositoryLink
4623
+ url: '#',
4624
+ icon: 'LinkExternal'
4567
4625
  }, {
4568
4626
  label: repository(),
4569
- url: '#'
4627
+ url: repositoryLink,
4628
+ icon: 'Repo'
4570
4629
  }, {
4571
4630
  label: license(),
4572
- url: '#'
4631
+ url: licenseLink,
4632
+ icon: 'LinkExternal'
4573
4633
  }];
4574
4634
  };
4575
4635
 
4576
- const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, isBuiltin, extension) => {
4636
+ const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, isBuiltin, extension, showSizeLink) => {
4577
4637
  const folderSize = await getFolderSize(extensionUri);
4578
4638
  const displaySize = getDisplaySize(folderSize);
4579
- const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri);
4639
+ const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri, showSizeLink);
4580
4640
  const marketplaceEntries = getMarketplaceEntries(isBuiltin);
4581
4641
  const categories = getCategories(extension);
4582
4642
  const resources = getResources(isBuiltin, extension);
4583
4643
  return {
4644
+ categories,
4645
+ displaySize,
4646
+ folderSize,
4584
4647
  installationEntries,
4585
4648
  marketplaceEntries,
4586
- displaySize,
4587
- categories,
4588
- resources,
4589
- folderSize
4649
+ resources
4590
4650
  };
4591
4651
  };
4592
4652
 
@@ -4686,6 +4746,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4686
4746
  const tabs = getTabs(selectedTab, hasReadme, hasFeatures, hasChangelog);
4687
4747
  const enabledTabs = tabs.filter(tab => tab.enabled);
4688
4748
  const sizeValue = getViewletSize(width || 0);
4749
+ const showSizeLink = platform !== Web$1;
4689
4750
  const {
4690
4751
  installationEntries,
4691
4752
  marketplaceEntries,
@@ -4693,7 +4754,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4693
4754
  categories,
4694
4755
  resources,
4695
4756
  folderSize
4696
- } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin, extension);
4757
+ } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin, extension, showSizeLink);
4697
4758
  const padding = getPadding(width);
4698
4759
  const sideBarWidth = getSideBarWidth(width);
4699
4760
  const showSideBar = sideBarWidth > 0;
@@ -4719,6 +4780,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4719
4780
  hasReadme,
4720
4781
  iconSrc,
4721
4782
  installationEntries,
4783
+ locationProtocol,
4722
4784
  marketplaceEntries,
4723
4785
  name,
4724
4786
  paddingLeft: padding,
@@ -4731,11 +4793,11 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4731
4793
  scrollToTopButtonEnabled: true,
4732
4794
  selectedTab,
4733
4795
  showSideBar,
4796
+ showSizeLink,
4734
4797
  sideBarWidth,
4735
4798
  sizeOnDisk: size,
4736
4799
  sizeValue,
4737
- tabs: enabledTabs,
4738
- locationProtocol
4800
+ tabs: enabledTabs
4739
4801
  };
4740
4802
  };
4741
4803
 
@@ -4911,6 +4973,38 @@ const getMoreInfoVirtualDom = items => {
4911
4973
  }, ...items.flatMap(getMoreInfoEntryVirtualDom)];
4912
4974
  };
4913
4975
 
4976
+ const getIconDom = icon => {
4977
+ if (!icon) {
4978
+ return [];
4979
+ }
4980
+ return [{
4981
+ type: Div,
4982
+ className: ResourceIcon,
4983
+ childCount: 1
4984
+ }, {
4985
+ type: Div,
4986
+ className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
4987
+ childCount: 0
4988
+ }];
4989
+ };
4990
+ const getResourceLinkVirtualDom = resource => {
4991
+ const {
4992
+ label,
4993
+ url,
4994
+ icon
4995
+ } = resource;
4996
+ const iconDom = getIconDom(icon);
4997
+ const iconDomCount = iconDom.length > 0 ? 1 : 0;
4998
+ return [{
4999
+ type: A,
5000
+ className: Resource,
5001
+ childCount: 1 + iconDomCount,
5002
+ target: '_blank',
5003
+ rel: 'noopener noreferrer',
5004
+ href: url
5005
+ }, ...iconDom, text(label)];
5006
+ };
5007
+
4914
5008
  const resourceNode = {
4915
5009
  // TODO use link with url
4916
5010
  type: Div,
@@ -4923,14 +5017,7 @@ const getResourceVirtualDom = resource => {
4923
5017
  url
4924
5018
  } = resource;
4925
5019
  if (url && url !== '#') {
4926
- return [{
4927
- type: A,
4928
- className: Resource,
4929
- childCount: 1,
4930
- target: '_blank',
4931
- rel: 'noopener noreferrer',
4932
- href: url
4933
- }, text(label)];
5020
+ return getResourceLinkVirtualDom(resource);
4934
5021
  }
4935
5022
  return [resourceNode, text(label)];
4936
5023
  };
@@ -5423,6 +5510,7 @@ const commandMap = {
5423
5510
  'ExtensionDetail.handleTabsClick': wrapCommand(handleTabsClick),
5424
5511
  'ExtensionDetail.handleWheel': wrapCommand(handleScroll),
5425
5512
  // deprecated
5513
+ 'ExtensionDetail.hideSizeLink': wrapCommand(hideSizeLink),
5426
5514
  'ExtensionDetail.initialize': initialize,
5427
5515
  'ExtensionDetail.loadContent2': wrapCommand(loadContent2),
5428
5516
  'ExtensionDetail.openImageInNewTab': wrapCommand(openImageInNewTab),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "5.3.0",
3
+ "version": "5.6.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",