@lvce-editor/extension-detail-view 6.5.0 → 6.7.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.
@@ -15,7 +15,7 @@ const ActivationTime = 'Activation Time: ';
15
15
  const Categories$1 = 'Categories';
16
16
  const Changelog$2 = 'Changelog';
17
17
  const Commands$1 = 'Commands';
18
- const ContentSecurityPolicy = 'ContentSecurityPolicy';
18
+ const ContentSecurityPolicy = 'Content Security Policy';
19
19
  const Copy = 'Copy';
20
20
  const CopyImage = 'Copy Image';
21
21
  const CopyImageUrl = 'Copy Image Url';
@@ -948,12 +948,19 @@ const getProgrammingLanguagesTableEntries = rows => {
948
948
 
949
949
  const getFeatureProgrammingLanguagesVirtualDom = programmingLanguages$1 => {
950
950
  const heading = programmingLanguages();
951
- const tableInfo = getProgrammingLanguagesTableEntries(programmingLanguages$1);
952
- return [{
951
+ const top = [{
953
952
  childCount: 2,
954
953
  className: FeatureContent,
955
954
  type: Div
956
- }, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
955
+ }, ...getFeatureContentHeadingVirtualDom(heading)];
956
+ if (programmingLanguages$1.length === 0) {
957
+ return [...top, {
958
+ childCount: 1,
959
+ type: P
960
+ }, text('Empty Array.')];
961
+ }
962
+ const tableInfo = getProgrammingLanguagesTableEntries(programmingLanguages$1);
963
+ return [...top, ...getTableVirtualDom(tableInfo)];
957
964
  };
958
965
 
959
966
  const getProgrammingLanguagesVirtualDom = state => {
@@ -1038,6 +1045,8 @@ const RendererWorker = 1;
1038
1045
  const FocusElementByName = 'Viewlet.focusElementByName';
1039
1046
  const SetFocusContext = 'Viewlet.setFocusContext';
1040
1047
 
1048
+ const FocusExtensioNDetailTabs = 451;
1049
+
1041
1050
  const rpcs = Object.create(null);
1042
1051
  const set$b = (id, rpc) => {
1043
1052
  rpcs[id] = rpc;
@@ -2147,6 +2156,12 @@ const {
2147
2156
  invoke: invoke$4,
2148
2157
  set: set$8
2149
2158
  } = create$7(ExtensionManagementWorker);
2159
+ const enable2 = (id, platform) => {
2160
+ return invoke$4(`Extensions.enable2`, id, platform);
2161
+ };
2162
+ const disable2 = (id, platform) => {
2163
+ return invoke$4(`Extensions.disable2`, id, platform);
2164
+ };
2150
2165
 
2151
2166
  const {
2152
2167
  dispose: dispose$3,
@@ -3152,6 +3167,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
3152
3167
  importTime: 0,
3153
3168
  installationEntries: [],
3154
3169
  jsonValidation: [],
3170
+ lastUpdated: null,
3155
3171
  linkProtectionEnabled: false,
3156
3172
  locationHost: '',
3157
3173
  locationProtocol: '',
@@ -3265,16 +3281,15 @@ const focusPreviousTab = state => {
3265
3281
  };
3266
3282
  };
3267
3283
 
3268
- const focusId$1 = 451;
3269
3284
  const getKeyBindings = () => {
3270
3285
  return [{
3271
3286
  command: 'ExtensionDetail.focusNextTab',
3272
3287
  key: RightArrow,
3273
- when: focusId$1
3288
+ when: FocusExtensioNDetailTabs
3274
3289
  }, {
3275
3290
  command: 'ExtensionDetail.focusPreviousTab',
3276
3291
  key: LeftArrow,
3277
- when: focusId$1
3292
+ when: FocusExtensioNDetailTabs
3278
3293
  }];
3279
3294
  };
3280
3295
 
@@ -3441,7 +3456,7 @@ const handleClickCategory = async (state, categoryId) => {
3441
3456
  };
3442
3457
 
3443
3458
  const disableExtension = (id, platform) => {
3444
- return invoke$4('Extensions.disable2', id, platform);
3459
+ return disable2(id, platform);
3445
3460
  };
3446
3461
 
3447
3462
  const Web = 1;
@@ -3537,7 +3552,7 @@ const handleClickDisable = async state => {
3537
3552
  };
3538
3553
 
3539
3554
  const enableExtension = (id, platform) => {
3540
- return invoke$4('Extensions.enable2', id, platform);
3555
+ return enable2(id, platform);
3541
3556
  };
3542
3557
 
3543
3558
  const handleClickEnable = async state => {
@@ -4077,6 +4092,25 @@ const getFolderSize = async uri => {
4077
4092
  }
4078
4093
  };
4079
4094
 
4095
+ const formatLastUpdated = lastUpdated => {
4096
+ if (lastUpdated === null) {
4097
+ return 'n/a';
4098
+ }
4099
+ try {
4100
+ const date = new Date(lastUpdated);
4101
+ if (Number.isNaN(date.getTime())) {
4102
+ return 'n/a';
4103
+ }
4104
+ return date.toLocaleDateString(undefined, {
4105
+ day: 'numeric',
4106
+ month: 'short',
4107
+ year: 'numeric'
4108
+ });
4109
+ } catch {
4110
+ return 'n/a';
4111
+ }
4112
+ };
4113
+
4080
4114
  const getSizeEntries = (showSizeLink, displaySize, extensionUri) => {
4081
4115
  if (!showSizeLink) {
4082
4116
  return [];
@@ -4089,7 +4123,7 @@ const getSizeEntries = (showSizeLink, displaySize, extensionUri) => {
4089
4123
  }];
4090
4124
  };
4091
4125
 
4092
- const getInstallationEntries = (displaySize, extensionId, extensionVersion, extensionUri, showSizeLink) => {
4126
+ const getInstallationEntries = (displaySize, extensionId, extensionVersion, extensionUri, showSizeLink, lastUpdated$1) => {
4093
4127
  const entries = [{
4094
4128
  code: true,
4095
4129
  key: identifier(),
@@ -4102,7 +4136,7 @@ const getInstallationEntries = (displaySize, extensionId, extensionVersion, exte
4102
4136
  }, {
4103
4137
  key: lastUpdated(),
4104
4138
  odd: true,
4105
- value: 'n/a' // TODO get this from somewhere
4139
+ value: formatLastUpdated(lastUpdated$1)
4106
4140
  }, ...getSizeEntries(showSizeLink, displaySize, extensionUri)];
4107
4141
  return entries;
4108
4142
  };
@@ -4172,7 +4206,7 @@ const getLicenseLink = extension => {
4172
4206
  }
4173
4207
  if (isGitHubRepository(repositoryLink)) {
4174
4208
  const normalizedLink = repositoryLink.replace(/\/+$/, '');
4175
- return `${normalizedLink}/blob/main/license.md`;
4209
+ return `${normalizedLink}/blob/main/LICENSE`;
4176
4210
  }
4177
4211
  return '#';
4178
4212
  };
@@ -4205,10 +4239,10 @@ const getResources = (isBuiltin, extension) => {
4205
4239
  return rawResources.filter(resource => resource.enabled);
4206
4240
  };
4207
4241
 
4208
- const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, isBuiltin, extension, showSizeLink) => {
4242
+ const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, isBuiltin, extension, showSizeLink, lastUpdated) => {
4209
4243
  const folderSize = await getFolderSize(extensionUri);
4210
4244
  const displaySize = getDisplaySize(folderSize);
4211
- const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri, showSizeLink);
4245
+ const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri, showSizeLink, lastUpdated);
4212
4246
  const marketplaceEntries = getMarketplaceEntries(isBuiltin);
4213
4247
  const categories = getCategories(extension);
4214
4248
  const resources = getResources(isBuiltin, extension);
@@ -4222,6 +4256,31 @@ const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, i
4222
4256
  };
4223
4257
  };
4224
4258
 
4259
+ const parseLastUpdated = extension => {
4260
+ if (!extension || typeof extension !== 'object') {
4261
+ return null;
4262
+ }
4263
+ const {
4264
+ lastUpdated
4265
+ } = extension;
4266
+ if (lastUpdated === undefined || lastUpdated === null) {
4267
+ return null;
4268
+ }
4269
+ if (typeof lastUpdated === 'number') {
4270
+ if (Number.isFinite(lastUpdated) && lastUpdated > 0) {
4271
+ return lastUpdated;
4272
+ }
4273
+ return null;
4274
+ }
4275
+ if (typeof lastUpdated === 'string') {
4276
+ const parsed = Number.parseFloat(lastUpdated);
4277
+ if (Number.isFinite(parsed) && parsed > 0) {
4278
+ return parsed;
4279
+ }
4280
+ }
4281
+ return null;
4282
+ };
4283
+
4225
4284
  const join = (...parts) => {
4226
4285
  return parts.join('/');
4227
4286
  };
@@ -4330,6 +4389,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4330
4389
  const enabledTabs = tabs.filter(isEnabled);
4331
4390
  const sizeValue = getViewletSize(width || 0);
4332
4391
  const showSizeLink = platform !== Web$1;
4392
+ const lastUpdated = parseLastUpdated(extension);
4333
4393
  const {
4334
4394
  categories,
4335
4395
  displaySize,
@@ -4337,7 +4397,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4337
4397
  installationEntries,
4338
4398
  marketplaceEntries,
4339
4399
  resources
4340
- } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin, extension, showSizeLink);
4400
+ } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin, extension, showSizeLink, lastUpdated);
4341
4401
  const padding = getPadding(width);
4342
4402
  const sideBarWidth = getSideBarWidth(width);
4343
4403
  const showSideBar = sideBarWidth > 0;
@@ -4365,6 +4425,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4365
4425
  hasReadme,
4366
4426
  iconSrc,
4367
4427
  installationEntries,
4428
+ lastUpdated,
4368
4429
  linkProtectionEnabled,
4369
4430
  locationHost,
4370
4431
  locationProtocol,
@@ -4521,13 +4582,16 @@ const handleSelectionChange = async (state, selection) => {
4521
4582
  return state;
4522
4583
  };
4523
4584
 
4524
- const focusId = 451;
4525
4585
  const handleTabFocus = (state, name) => {
4526
- const tabIndex = state.tabs.findIndex(tab => tab.name === name);
4527
- const newFocusedTabIndex = tabIndex === -1 ? state.focusedTabIndex : tabIndex;
4586
+ const {
4587
+ focusedTabIndex,
4588
+ tabs
4589
+ } = state;
4590
+ const tabIndex = tabs.findIndex(tab => tab.name === name);
4591
+ const newFocusedTabIndex = tabIndex === -1 ? focusedTabIndex : tabIndex;
4528
4592
  return {
4529
4593
  ...state,
4530
- focus: focusId,
4594
+ focus: FocusExtensioNDetailTabs,
4531
4595
  focusedTabIndex: newFocusedTabIndex
4532
4596
  };
4533
4597
  };
@@ -4681,10 +4745,11 @@ const hideSizeLink = state => {
4681
4745
  displaySize,
4682
4746
  extensionId,
4683
4747
  extensionUri,
4684
- extensionVersion
4748
+ extensionVersion,
4749
+ lastUpdated
4685
4750
  } = state;
4686
4751
  const newShowSizeLink = false;
4687
- const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri, newShowSizeLink);
4752
+ const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri, newShowSizeLink, lastUpdated);
4688
4753
  return {
4689
4754
  ...state,
4690
4755
  installationEntries,
@@ -5014,8 +5079,8 @@ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, ent
5014
5079
  if (!showAdditionalDetails) {
5015
5080
  return [];
5016
5081
  }
5017
- const sections = [...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...(secondEntries.length > 0 ? getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom) : []), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
5018
- const childCount = secondEntries.length > 0 ? 4 : 3;
5082
+ const sections = [...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...(secondEntries.length > 0 ? getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom) : []), ...(categories.length > 0 ? getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom) : []), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
5083
+ const childCount = 1 + (secondEntries.length > 0 ? 1 : 0) + (categories.length > 0 ? 1 : 0) + 1;
5019
5084
  return [{
5020
5085
  childCount: 1,
5021
5086
  className: Aside,
@@ -5200,13 +5265,29 @@ const getNameBadgeVirtualDom = badge => {
5200
5265
  }, text(badge)];
5201
5266
  };
5202
5267
 
5203
- const getExtensionDetailNameVirtualDom = (name, badge) => {
5268
+ const getExtensionDetailNameWithBadgeVirtualDom = (name, badge) => {
5204
5269
  return [{
5205
- childCount: badge ? 2 : 1,
5270
+ childCount: 2,
5206
5271
  className: ExtensionDetailName,
5207
5272
  type: Div
5273
+ }, {
5274
+ childCount: 1,
5275
+ type: Span
5208
5276
  }, text(name), ...getNameBadgeVirtualDom(badge)];
5209
5277
  };
5278
+ const getExtensionDetailNameDefaultVirtualDom = name => {
5279
+ return [{
5280
+ childCount: 1,
5281
+ className: ExtensionDetailName,
5282
+ type: Div
5283
+ }, text(name)];
5284
+ };
5285
+ const getExtensionDetailNameVirtualDom = (name, badge) => {
5286
+ if (badge) {
5287
+ return getExtensionDetailNameWithBadgeVirtualDom(name, badge);
5288
+ }
5289
+ return getExtensionDetailNameDefaultVirtualDom(name);
5290
+ };
5210
5291
 
5211
5292
  const getExtensionDetailHeaderVirtualDom = (name, iconSrc, description, badge, buttonDefs, settingsButtonEnabled) => {
5212
5293
  const dom = [{
@@ -5330,7 +5411,7 @@ const renderFocusContext = (oldState, newState) => {
5330
5411
  focus,
5331
5412
  uid
5332
5413
  } = newState;
5333
- if (focus === 451) {
5414
+ if (focus === FocusExtensioNDetailTabs) {
5334
5415
  return [SetFocusContext, uid, focus];
5335
5416
  }
5336
5417
  // TODO set focus context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "6.5.0",
3
+ "version": "6.7.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,6 +11,6 @@
11
11
  "type": "module",
12
12
  "main": "dist/extensionDetailViewWorkerMain.js",
13
13
  "dependencies": {
14
- "@lvce-editor/constants": "^2.4.0"
14
+ "@lvce-editor/constants": "^2.5.0"
15
15
  }
16
16
  }