@lvce-editor/extension-detail-view 4.5.0 → 4.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.
@@ -305,7 +305,7 @@ const Features$1 = 'Features';
305
305
  const FeaturesList = 'FeaturesList';
306
306
  const FeatureWebView = 'FeatureWebView';
307
307
  const Large$1 = 'Large';
308
- const Link = 'Link';
308
+ const Link$1 = 'Link';
309
309
  const Markdown = 'Markdown';
310
310
  const MoreInfo = 'MoreInfo';
311
311
  const MoreInfoEntry = 'MoreInfoEntry';
@@ -323,6 +323,7 @@ const SettingsIcon = 'SettingsIcon';
323
323
  const Small$1 = 'Small';
324
324
  const Table = 'Table';
325
325
  const TableCell = 'TableCell';
326
+ const TableCellInvalid = 'TableCellInvalid';
326
327
  const TableHeading = 'TableHeading';
327
328
  const Viewlet = 'Viewlet';
328
329
 
@@ -363,6 +364,7 @@ const getActivationEventsVirtualDom = state => {
363
364
 
364
365
  const Text = 1;
365
366
  const Code = 2;
367
+ const Link = 7;
366
368
 
367
369
  const getCommandTableEntry = command => {
368
370
  // TODO watch out for command being null/undefined/number/string/array
@@ -424,22 +426,44 @@ const getTableHeadingVirtualDom = heading => {
424
426
  }, text(heading)];
425
427
  };
426
428
 
427
- const getCellCodeVirtualDom = value => {
429
+ const getCellCodeVirtualDom = (value, props) => {
430
+ const tdClassName = props?.className ? `${TableCell} ${props.className}` : TableCell;
428
431
  return [{
429
432
  type: Td,
430
- className: TableCell,
431
- childCount: 1
433
+ className: tdClassName,
434
+ childCount: 1,
435
+ ...(props?.title ? {
436
+ title: props.title
437
+ } : {})
432
438
  }, {
433
439
  type: Code$2,
434
440
  childCount: 1
435
441
  }, text(value)];
436
442
  };
437
443
 
438
- const getCellTextVirtualDom = value => {
444
+ const getCellLinkVirtualDom = (value, {
445
+ href
446
+ }) => {
439
447
  return [{
440
448
  type: Td,
441
449
  className: TableCell,
442
450
  childCount: 1
451
+ }, {
452
+ type: A,
453
+ href,
454
+ childCount: 1
455
+ }, text(value)];
456
+ };
457
+
458
+ const getCellTextVirtualDom = (value, props) => {
459
+ const tdClassName = props?.className ? `${TableCell} ${props.className}` : TableCell;
460
+ return [{
461
+ type: Td,
462
+ className: tdClassName,
463
+ childCount: 1,
464
+ ...(props?.title ? {
465
+ title: props.title
466
+ } : {})
443
467
  }, text(value)];
444
468
  };
445
469
 
@@ -449,6 +473,8 @@ const getCellRenderer = type => {
449
473
  return getCellCodeVirtualDom;
450
474
  case Text:
451
475
  return getCellTextVirtualDom;
476
+ case Link:
477
+ return getCellLinkVirtualDom;
452
478
  default:
453
479
  throw new Error(`unexpected cell type ${type}`);
454
480
  }
@@ -457,10 +483,11 @@ const getCellRenderer = type => {
457
483
  const getCellVirtualDom = entry => {
458
484
  const {
459
485
  value,
460
- type
486
+ type,
487
+ ...props
461
488
  } = entry;
462
489
  const fn = getCellRenderer(type);
463
- return fn(value);
490
+ return fn(value, props);
464
491
  };
465
492
 
466
493
  const getTableRowVirtualDom = entries => {
@@ -509,24 +536,94 @@ const getCommandsVirtualDom = state => {
509
536
  return getFeatureCommandsVirtualDom(state.commands);
510
537
  };
511
538
 
512
- const getJsonValidationTableEntry = validation => {
513
- // TODO handle case when validation is invalid like null
539
+ const stringifyValue = value => {
540
+ return JSON.stringify(value);
541
+ };
542
+ const getLinkOrTextEntry = (schema, schemaLinkUrl) => {
543
+ if (typeof schema !== 'string') {
544
+ return {
545
+ type: Text,
546
+ value: stringifyValue(schema)
547
+ };
548
+ }
549
+ if (schemaLinkUrl) {
550
+ return {
551
+ type: Link,
552
+ value: schema,
553
+ href: schemaLinkUrl
554
+ };
555
+ }
556
+ return {
557
+ type: Text,
558
+ value: schema
559
+ };
560
+ };
561
+
562
+ const isExternalLink = schema => {
563
+ return schema.startsWith('http://') || schema.startsWith('https://');
564
+ };
565
+ const getSchemaLinkUrl = (schema, extensionUri) => {
566
+ if (!schema) {
567
+ return '';
568
+ }
569
+ if (typeof schema !== 'string') {
570
+ return '';
571
+ }
572
+ if (isExternalLink(schema)) {
573
+ return schema;
574
+ }
575
+ return new URL(schema, extensionUri).toString();
576
+ };
577
+
578
+ const stringify = value => {
579
+ try {
580
+ return JSON.stringify(value);
581
+ } catch {
582
+ return String(value);
583
+ }
584
+ };
585
+ const getJsonValidationTableEntry = (validation, extensionUri) => {
586
+ const invalidProps = {
587
+ className: TableCellInvalid,
588
+ title: 'property must be a string'
589
+ };
590
+ if (!validation || typeof validation !== 'object' || Array.isArray(validation)) {
591
+ const shown = stringify(validation);
592
+ return [{
593
+ type: Text,
594
+ value: shown,
595
+ ...invalidProps
596
+ }, {
597
+ type: Text,
598
+ value: shown,
599
+ ...invalidProps
600
+ }];
601
+ }
514
602
  const {
515
603
  fileMatch
516
604
  } = validation;
517
605
  const schema = validation.schema ?? validation.url;
518
- return [{
606
+ const schemaLinkUrl = getSchemaLinkUrl(schema, extensionUri);
607
+ const leftCell = typeof fileMatch === 'string' || Array.isArray(fileMatch) ? {
519
608
  type: Code,
520
609
  value: fileMatch
521
- }, {
522
- type: Code,
523
- value: schema
524
- }];
610
+ } : {
611
+ type: Text,
612
+ value: stringify(fileMatch),
613
+ ...invalidProps
614
+ };
615
+ const rightEntry = typeof schema === 'string' ? getLinkOrTextEntry(schema, schemaLinkUrl) : {
616
+ type: Text,
617
+ value: stringify(schema),
618
+ ...invalidProps
619
+ };
620
+ return [leftCell, rightEntry];
525
621
  };
526
622
 
527
623
  const getJsonValidationDetails = async extension => {
528
624
  const validations = extension.jsonValidation || [];
529
- const rows = validations.map(getJsonValidationTableEntry);
625
+ const extensionUri = extension.uri || '';
626
+ const rows = validations.map(validation => getJsonValidationTableEntry(validation, extensionUri));
530
627
  return {
531
628
  jsonValidation: rows
532
629
  };
@@ -738,7 +835,7 @@ class AssertionError extends Error {
738
835
  const Object$1 = 1;
739
836
  const Number$1 = 2;
740
837
  const Array$1 = 3;
741
- const String = 4;
838
+ const String$1 = 4;
742
839
  const Boolean$1 = 5;
743
840
  const Function = 6;
744
841
  const Null = 7;
@@ -750,7 +847,7 @@ const getType = value => {
750
847
  case 'function':
751
848
  return Function;
752
849
  case 'string':
753
- return String;
850
+ return String$1;
754
851
  case 'object':
755
852
  if (value === null) {
756
853
  return Null;
@@ -767,7 +864,7 @@ const getType = value => {
767
864
  };
768
865
  const string = value => {
769
866
  const type = getType(value);
770
- if (type !== String) {
867
+ if (type !== String$1) {
771
868
  throw new AssertionError('expected value to be of type string');
772
869
  }
773
870
  };
@@ -2396,6 +2493,7 @@ const HandleImageContextMenu = 11;
2396
2493
  const HandleReadmeContextMenu = 12;
2397
2494
  const HandleReadmeScroll = 13;
2398
2495
  const HandleTabsClick = 14;
2496
+ const HandleAdditionalDetailContextMenu = 15;
2399
2497
 
2400
2498
  const ActivationEvents = 'ActivationEvents';
2401
2499
  const Changelog = 'Changelog';
@@ -2487,12 +2585,13 @@ const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
2487
2585
  const supportsNormalCacheKey = locationProtocol => {
2488
2586
  return locationProtocol === 'http:' || locationProtocol === 'https:';
2489
2587
  };
2588
+
2490
2589
  const getMarkdownCacheKey = (hash, locationProtocol) => {
2491
2590
  if (supportsNormalCacheKey(locationProtocol)) {
2492
2591
  return `/markdown/${hash}`;
2493
2592
  }
2494
2593
  // workaround for electron bug
2495
- return `https://markdown/${hash}`;
2594
+ return `https://-/markdown/${hash}`;
2496
2595
  };
2497
2596
 
2498
2597
  const hash = async content => {
@@ -3134,6 +3233,10 @@ const getMenus = () => {
3134
3233
  }];
3135
3234
  };
3136
3235
 
3236
+ const handleAdditionalDetailContextMenu = state => {
3237
+ return state;
3238
+ };
3239
+
3137
3240
  const openExtensionSearch = async searchValue => {
3138
3241
  await openExtensionSearch$1();
3139
3242
  await setExtensionsSearchValue(searchValue);
@@ -4302,7 +4405,7 @@ const getMoreInfoEntryKeyVirtualDom = item => {
4302
4405
  return [parentNode, text(key)];
4303
4406
  };
4304
4407
 
4305
- const classLink = mergeClassNames(MoreInfoEntryValue, Link);
4408
+ const classLink = mergeClassNames(MoreInfoEntryValue, Link$1);
4306
4409
  const classCode = mergeClassNames(MoreInfoEntryValue, Code$1);
4307
4410
  const getMoreInfoEntryValueClassName = (onClick, code) => {
4308
4411
  if (onClick) {
@@ -4324,13 +4427,15 @@ const getMoreInfoEntryValueTag = (onClick, code) => {
4324
4427
  return Dd;
4325
4428
  };
4326
4429
 
4327
- const getExtraProps = title => {
4430
+ const getExtraProps = (title, onClick) => {
4431
+ const props = Object.create(null);
4328
4432
  if (title) {
4329
- return {
4330
- title
4331
- };
4433
+ props.title = title;
4332
4434
  }
4333
- return {};
4435
+ if (onClick) {
4436
+ props.tabIndex = 0;
4437
+ }
4438
+ return props;
4334
4439
  };
4335
4440
  const getMoreInfoEntryValueVirtualDom = item => {
4336
4441
  const {
@@ -4341,7 +4446,7 @@ const getMoreInfoEntryValueVirtualDom = item => {
4341
4446
  } = item;
4342
4447
  const type = getMoreInfoEntryValueTag(onClick, code);
4343
4448
  const className = getMoreInfoEntryValueClassName(onClick, code);
4344
- const extraProps = getExtraProps(title);
4449
+ const extraProps = getExtraProps(title, onClick);
4345
4450
  return [{
4346
4451
  type,
4347
4452
  className,
@@ -4410,7 +4515,8 @@ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, ent
4410
4515
  type: Div,
4411
4516
  className: AdditionalDetails,
4412
4517
  tabIndex: 0,
4413
- childCount: 4
4518
+ childCount: 4,
4519
+ onClick: HandleAdditionalDetailContextMenu
4414
4520
  }, ...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
4415
4521
  };
4416
4522
 
@@ -4756,6 +4862,10 @@ const render2 = (uid, diffResult) => {
4756
4862
  // @ts-nocheck
4757
4863
  const renderEventListeners = () => {
4758
4864
  return [{
4865
+ name: HandleAdditionalDetailContextMenu,
4866
+ params: ['handleAdditionalDetailsContextMenu'],
4867
+ preventDefault: true
4868
+ }, {
4759
4869
  name: HandleClickCategory,
4760
4870
  params: ['handleClickCategory', TargetName]
4761
4871
  }, {
@@ -4839,6 +4949,7 @@ const commandMap = {
4839
4949
  'ExtensionDetail.getMenuEntries': getMenuEntries,
4840
4950
  'ExtensionDetail.getMenus': getMenus,
4841
4951
  'ExtensionDetail.handleClickCategory': wrapCommand(handleClickCategory),
4952
+ 'ExtensionDetail.handleAdditionalDetailsContextMenu': wrapCommand(handleAdditionalDetailContextMenu),
4842
4953
  'ExtensionDetail.handleClickDisable': wrapCommand(handleClickDisable),
4843
4954
  'ExtensionDetail.handleClickEnable': wrapCommand(handleClickEnable),
4844
4955
  'ExtensionDetail.handleClickScrollToTop': wrapCommand(handleClickScrollToTop),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",