@lvce-editor/extension-detail-view 6.0.0 → 6.1.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.
@@ -330,7 +330,8 @@ const ClientY = 'event.clientY';
330
330
  const TargetHref = 'event.target.href';
331
331
  const TargetName = 'event.target.name';
332
332
 
333
- const Script$1 = 2;
333
+ const LeftArrow = 13;
334
+ const RightArrow = 15;
334
335
 
335
336
  const ExtensionDetailReadme = 20;
336
337
  const ExtensionDetailIconContextMenu$3 = 4091;
@@ -339,11 +340,8 @@ const None$2 = 0;
339
340
 
340
341
  const Web$1 = 1;
341
342
 
342
- const ExtensionHostWorker = 44;
343
- const FileSystemWorker$1 = 209;
344
- const MarkdownWorker$1 = 300;
345
- const RendererWorker = 1;
346
- const ExtensionManagementWorker = 9006;
343
+ const FocusElementByName = 'Viewlet.focusElementByName';
344
+ const SetFocusContext = 'Viewlet.setFocusContext';
347
345
 
348
346
  const mergeClassNames = (...classNames) => {
349
347
  return classNames.filter(Boolean).join(' ');
@@ -1031,6 +1029,14 @@ const getFeatureVirtualDomHandler = featureName => {
1031
1029
  return feature.getVirtualDom;
1032
1030
  };
1033
1031
 
1032
+ const Script$1 = 2;
1033
+
1034
+ const ExtensionHostWorker = 44;
1035
+ const ExtensionManagementWorker = 9006;
1036
+ const FileSystemWorker$1 = 209;
1037
+ const MarkdownWorker$1 = 300;
1038
+ const RendererWorker = 1;
1039
+
1034
1040
  const rpcs = Object.create(null);
1035
1041
  const set$b = (id, rpc) => {
1036
1042
  rpcs[id] = rpc;
@@ -2542,6 +2548,7 @@ const HandleTabsClick = 14;
2542
2548
  const HandleAdditionalDetailContextMenu = 15;
2543
2549
  const HandleReadmeClick = 16;
2544
2550
  const HandleSelectionChange = 17;
2551
+ const HandleTabFocus = 18;
2545
2552
 
2546
2553
  const ActivationEvents = 'ActivationEvents';
2547
2554
  const Changelog = 'Changelog';
@@ -3128,6 +3135,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
3128
3135
  features: [],
3129
3136
  featuresVirtualDom: [],
3130
3137
  focus: 0,
3138
+ focusedTabIndex: 0,
3131
3139
  folderSize: 0,
3132
3140
  hasColorTheme: false,
3133
3141
  hasReadme: false,
@@ -3176,7 +3184,7 @@ const isEqual$3 = (oldState, newState) => {
3176
3184
  };
3177
3185
 
3178
3186
  const isEqual$2 = (oldState, newState) => {
3179
- return oldState.focus === newState.focus;
3187
+ return oldState.focus === newState.focus && oldState.focusedTabIndex === newState.focusedTabIndex;
3180
3188
  };
3181
3189
 
3182
3190
  const isEqual$1 = (oldState, newState) => {
@@ -3194,9 +3202,10 @@ const RenderFocus = 2;
3194
3202
  const RenderItems = 3;
3195
3203
  const RenderScrollTop = 4;
3196
3204
  const RenderCss = 5;
3205
+ const RenderFocusContext = 6;
3197
3206
 
3198
- const modules = [isEqual$1, isEqual$2, isEqual, isEqual$3];
3199
- const numbers = [RenderItems, RenderFocus, RenderScrollTop, RenderCss];
3207
+ const modules = [isEqual$1, isEqual$2, isEqual, isEqual$3, isEqual$2];
3208
+ const numbers = [RenderItems, RenderFocus, RenderScrollTop, RenderCss, RenderFocusContext];
3200
3209
 
3201
3210
  const diff2 = uid => {
3202
3211
  const {
@@ -3224,6 +3233,41 @@ const executeCopy = async state => {
3224
3233
  return state;
3225
3234
  };
3226
3235
 
3236
+ const focusNextTab = state => {
3237
+ const {
3238
+ focusedTabIndex
3239
+ } = state;
3240
+ const newFocusedTabIndex = focusedTabIndex >= 1 ? 1 : focusedTabIndex + 1;
3241
+ return {
3242
+ ...state,
3243
+ focusedTabIndex: newFocusedTabIndex
3244
+ };
3245
+ };
3246
+
3247
+ const focusPreviousTab = state => {
3248
+ const {
3249
+ focusedTabIndex
3250
+ } = state;
3251
+ const newFocusedTabIndex = focusedTabIndex <= 0 ? 0 : focusedTabIndex - 1;
3252
+ return {
3253
+ ...state,
3254
+ focusedTabIndex: newFocusedTabIndex
3255
+ };
3256
+ };
3257
+
3258
+ const focusId$1 = 451;
3259
+ const getKeyBindings = () => {
3260
+ return [{
3261
+ command: 'ExtensionDetail.focusNextTab',
3262
+ key: RightArrow,
3263
+ when: focusId$1
3264
+ }, {
3265
+ command: 'ExtensionDetail.focusPreviousTab',
3266
+ key: LeftArrow,
3267
+ when: focusId$1
3268
+ }];
3269
+ };
3270
+
3227
3271
  const getMenuEntriesImage = (state, props) => {
3228
3272
  return [{
3229
3273
  args: [],
@@ -4098,13 +4142,10 @@ const getIssuesLink = extension => {
4098
4142
  };
4099
4143
 
4100
4144
  const getResources = (isBuiltin, extension) => {
4101
- if (isBuiltin) {
4102
- return [];
4103
- }
4104
4145
  const repositoryLink = getRepositoryLink(extension);
4105
4146
  const issueLink = getIssuesLink(extension);
4106
4147
  const licenseLink = getLicenseLink();
4107
- // TODO
4148
+ // TODO hide marketplace link for builtin extensions
4108
4149
  return [{
4109
4150
  icon: 'LinkExternal',
4110
4151
  label: marketplace(),
@@ -4390,6 +4431,17 @@ const handleSelectionChange = async (state, selection) => {
4390
4431
  return state;
4391
4432
  };
4392
4433
 
4434
+ const focusId = 451;
4435
+ const handleTabFocus = (state, name) => {
4436
+ const tabIndex = state.tabs.findIndex(tab => tab.name === name);
4437
+ const newFocusedTabIndex = tabIndex === -1 ? state.focusedTabIndex : tabIndex;
4438
+ return {
4439
+ ...state,
4440
+ focus: focusId,
4441
+ focusedTabIndex: newFocusedTabIndex
4442
+ };
4443
+ };
4444
+
4393
4445
  const error = async error => {
4394
4446
  // TODO send message to error worker or log worker
4395
4447
  // @ts-ignore
@@ -4874,17 +4926,19 @@ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, ent
4874
4926
  if (!showAdditionalDetails) {
4875
4927
  return [];
4876
4928
  }
4929
+ const sections = [...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...(secondEntries.length > 0 ? getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom) : []), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
4930
+ const childCount = secondEntries.length > 0 ? 4 : 3;
4877
4931
  return [{
4878
4932
  childCount: 1,
4879
4933
  className: Aside,
4880
4934
  type: Aside$1
4881
4935
  }, {
4882
- childCount: 4,
4936
+ childCount: childCount,
4883
4937
  className: AdditionalDetails,
4884
4938
  onContextMenu: HandleAdditionalDetailContextMenu,
4885
4939
  tabIndex: 0,
4886
4940
  type: Div
4887
- }, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
4941
+ }, ...sections];
4888
4942
  };
4889
4943
 
4890
4944
  const getNoReadmeVirtualDom = () => {
@@ -5085,7 +5139,7 @@ const getTabClassName = isSelected => {
5085
5139
  return isSelected ? selectedClassName : defaultClassName;
5086
5140
  };
5087
5141
 
5088
- const getTabVirtualDom = tab => {
5142
+ const getTabVirtualDom = (tab, tabIndex, focusedTabIndex) => {
5089
5143
  const {
5090
5144
  label,
5091
5145
  name,
@@ -5093,26 +5147,27 @@ const getTabVirtualDom = tab => {
5093
5147
  } = tab;
5094
5148
  const className = getTabClassName(selected);
5095
5149
  const ariaSelected = selected;
5150
+ const tabIndexValue = tabIndex === focusedTabIndex ? 0 : -1;
5096
5151
  return [{
5097
5152
  ariaSelected,
5098
5153
  childCount: 1,
5099
5154
  className,
5100
5155
  name,
5156
+ onFocus: HandleTabFocus,
5101
5157
  role: Tab,
5102
- tabIndex: -1,
5158
+ tabIndex: tabIndexValue,
5103
5159
  type: Button$1
5104
5160
  }, text(label)];
5105
5161
  };
5106
5162
 
5107
- const getTabsVirtualDom = tabs => {
5163
+ const getTabsVirtualDom = (tabs, focusedTabIndex) => {
5108
5164
  return [{
5109
5165
  childCount: tabs.length,
5110
5166
  className: ExtensionDetailTabs,
5111
5167
  onClick: HandleTabsClick,
5112
5168
  role: TabList,
5113
- tabIndex: 0,
5114
5169
  type: Div
5115
- }, ...tabs.flatMap(getTabVirtualDom)];
5170
+ }, ...tabs.flatMap((tab, index) => getTabVirtualDom(tab, index, focusedTabIndex))];
5116
5171
  };
5117
5172
 
5118
5173
  const getClassNames = size => {
@@ -5141,6 +5196,7 @@ const getExtensionDetailVirtualDom = (newState, selectedTab) => {
5141
5196
  changelogVirtualDom,
5142
5197
  description,
5143
5198
  detailsVirtualDom,
5199
+ focusedTabIndex,
5144
5200
  iconSrc,
5145
5201
  name,
5146
5202
  resources,
@@ -5156,7 +5212,7 @@ const getExtensionDetailVirtualDom = (newState, selectedTab) => {
5156
5212
  childCount: 3,
5157
5213
  className: mergeClassNames(Viewlet, ExtensionDetail, sizeClass),
5158
5214
  type: Div
5159
- }, ...getExtensionDetailHeaderVirtualDom(name, iconSrc, description, badge, buttons, settingsButtonEnabled), ...getTabsVirtualDom(tabs), ...getExtensionDetailContentVirtualDom(detailsVirtualDom, selectedTab, width, scrollToTopButtonEnabled, categories, resources, showAdditionalDetailsBreakpoint, changelogVirtualDom, newState)];
5215
+ }, ...getExtensionDetailHeaderVirtualDom(name, iconSrc, description, badge, buttons, settingsButtonEnabled), ...getTabsVirtualDom(tabs, focusedTabIndex), ...getExtensionDetailContentVirtualDom(detailsVirtualDom, selectedTab, width, scrollToTopButtonEnabled, categories, resources, showAdditionalDetailsBreakpoint, changelogVirtualDom, newState)];
5160
5216
  return dom;
5161
5217
  };
5162
5218
 
@@ -5166,7 +5222,31 @@ const renderDom = (oldState, newState) => {
5166
5222
  };
5167
5223
 
5168
5224
  const renderFocus = (oldState, newState) => {
5169
- return ['Viewlet.focusElementByName', ''];
5225
+ const {
5226
+ focus,
5227
+ focusedTabIndex,
5228
+ tabs,
5229
+ uid
5230
+ } = newState;
5231
+ if (focus === 451) {
5232
+ const {
5233
+ name
5234
+ } = tabs[focusedTabIndex];
5235
+ return [FocusElementByName, uid, name];
5236
+ }
5237
+ return [FocusElementByName, ''];
5238
+ };
5239
+
5240
+ const renderFocusContext = (oldState, newState) => {
5241
+ const {
5242
+ focus,
5243
+ uid
5244
+ } = newState;
5245
+ if (focus === 451) {
5246
+ return [SetFocusContext, uid, focus];
5247
+ }
5248
+ // TODO set focus context
5249
+ return [FocusElementByName, ''];
5170
5250
  };
5171
5251
 
5172
5252
  const getScrollTop = (selectedTab, readmeScrollTop, changelogScrollTop) => {
@@ -5200,6 +5280,8 @@ const getRenderer = diffType => {
5200
5280
  return renderCss;
5201
5281
  case RenderFocus:
5202
5282
  return renderFocus;
5283
+ case RenderFocusContext:
5284
+ return renderFocusContext;
5203
5285
  case RenderItems:
5204
5286
  return renderDom;
5205
5287
  case RenderScrollTop:
@@ -5288,6 +5370,9 @@ const renderEventListeners = () => {
5288
5370
  }, {
5289
5371
  name: HandleSelectionChange,
5290
5372
  params: ['handleSelectionChange']
5373
+ }, {
5374
+ name: HandleTabFocus,
5375
+ params: ['handleTabFocus', TargetName]
5291
5376
  }];
5292
5377
  };
5293
5378
 
@@ -5328,7 +5413,10 @@ const commandMap = {
5328
5413
  'ExtensionDetail.diff2': diff2,
5329
5414
  'ExtensionDetail.dispose': dispose,
5330
5415
  'ExtensionDetail.executeCopy': wrapCommand(executeCopy),
5416
+ 'ExtensionDetail.focusNextTab': wrapCommand(focusNextTab),
5417
+ 'ExtensionDetail.focusPreviousTab': wrapCommand(focusPreviousTab),
5331
5418
  'ExtensionDetail.getCommandIds': getCommandIds,
5419
+ 'ExtensionDetail.getKeyBindings': getKeyBindings,
5332
5420
  'ExtensionDetail.getMenuEntries': getMenuEntries,
5333
5421
  'ExtensionDetail.getMenuEntries2': wrapGetter(getMenuEntries2),
5334
5422
  'ExtensionDetail.getMenuIds': getMenuIds,
@@ -5351,6 +5439,7 @@ const commandMap = {
5351
5439
  'ExtensionDetail.handleReadmeContextMenu': wrapCommand(handleReadmeContextMenu),
5352
5440
  'ExtensionDetail.handleScroll': wrapCommand(handleScroll),
5353
5441
  'ExtensionDetail.handleSelectionChange': wrapCommand(handleSelectionChange),
5442
+ 'ExtensionDetail.handleTabFocus': wrapCommand(handleTabFocus),
5354
5443
  'ExtensionDetail.handleTabsClick': wrapCommand(handleTabsClick),
5355
5444
  'ExtensionDetail.handleWheel': wrapCommand(handleScroll),
5356
5445
  // deprecated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",