@lvce-editor/extension-detail-view 5.0.0 → 5.2.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.
@@ -19,7 +19,6 @@ const ContentSecurityPolicy = 'ContentSecurityPolicy';
19
19
  const Copy = 'Copy';
20
20
  const CopyImage = 'Copy Image';
21
21
  const CopyImageUrl = 'Copy Image Url';
22
- const CopyLink = 'Copy Link';
23
22
  const Details$1 = 'Details';
24
23
  const Disable$1 = 'Disable';
25
24
  const Elements = 'Elements';
@@ -78,9 +77,6 @@ const marketplace = () => {
78
77
  const categories = () => {
79
78
  return i18nString(Categories$1);
80
79
  };
81
- const copyLink = () => {
82
- return i18nString(CopyLink);
83
- };
84
80
  const resources = () => {
85
81
  return i18nString(Resources$1);
86
82
  };
@@ -327,6 +323,7 @@ const TargetHref = 'event.target.href';
327
323
  const TargetName = 'event.target.name';
328
324
 
329
325
  const ExtensionDetailReadme = 20;
326
+ const ExtensionDetailIconContextMenu$3 = 4091;
330
327
 
331
328
  const None$2 = 0;
332
329
 
@@ -2245,7 +2242,7 @@ const searchFileHtml = async uri => {
2245
2242
  const getFilePathElectron = async file => {
2246
2243
  return invoke$2('FileSystemHandle.getFilePathElectron', file);
2247
2244
  };
2248
- const showContextMenu$1 = async (x, y, id, ...args) => {
2245
+ const showContextMenu = async (x, y, id, ...args) => {
2249
2246
  return invoke$2('ContextMenu.show', x, y, id, ...args);
2250
2247
  };
2251
2248
  const getElectronVersion = async () => {
@@ -2578,7 +2575,7 @@ const RendererWorker = {
2578
2575
  setFocus,
2579
2576
  setWebViewPort,
2580
2577
  setWorkspacePath,
2581
- showContextMenu: showContextMenu$1,
2578
+ showContextMenu,
2582
2579
  showErrorDialog,
2583
2580
  showMessageBox,
2584
2581
  showSaveFilePicker,
@@ -2786,6 +2783,7 @@ const HandleReadmeScroll = 13;
2786
2783
  const HandleTabsClick = 14;
2787
2784
  const HandleAdditionalDetailContextMenu = 15;
2788
2785
  const HandleReadmeClick = 16;
2786
+ const HandleSelectionChange = 17;
2789
2787
 
2790
2788
  const ActivationEvents = 'ActivationEvents';
2791
2789
  const Changelog = 'Changelog';
@@ -2837,7 +2835,8 @@ const getMarkdownVirtualDom = async (html, options) => {
2837
2835
  ...firstNode,
2838
2836
  onScroll: HandleReadmeScroll,
2839
2837
  childCount: firstNode.childCount + 1,
2840
- onClick: HandleReadmeClick
2838
+ onClick: HandleReadmeClick,
2839
+ onSelectionChange: HandleSelectionChange
2841
2840
  }, ...extraDom, ...rest];
2842
2841
  }
2843
2842
  return dom;
@@ -3294,7 +3293,6 @@ const {
3294
3293
  set: set$2,
3295
3294
  setColorTheme: setColorTheme$1,
3296
3295
  setExtensionsSearchValue,
3297
- showContextMenu,
3298
3296
  uninstallExtension,
3299
3297
  writeClipBoardImage,
3300
3298
  writeClipBoardText} = RendererWorker;
@@ -3437,7 +3435,7 @@ const isEqual$2 = (oldState, newState) => {
3437
3435
  };
3438
3436
 
3439
3437
  const isEqual$1 = (oldState, newState) => {
3440
- 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.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;
3438
+ 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;
3441
3439
  };
3442
3440
 
3443
3441
  const User = 1;
@@ -3474,34 +3472,42 @@ const dispose = uid => {
3474
3472
  dispose$1(uid);
3475
3473
  };
3476
3474
 
3477
- const getMenuEntriesReadmeLink = props => {
3475
+ const executeCopy = async state => {
3476
+ // TODO
3477
+ // 1. get selection text
3478
+ // 2. copy it
3479
+ return state;
3480
+ };
3481
+
3482
+ const getMenuEntriesImage = (state, props) => {
3478
3483
  return [{
3479
- id: 'copyLink',
3480
- label: copyLink(),
3484
+ id: 'copyImage',
3485
+ label: copyImage$1(),
3481
3486
  flags: None$2,
3482
- command: 'ExtensionDetail.copyReadmeLink',
3483
- args: [props.href]
3487
+ command: 'ExtensionDetail.copyImage',
3488
+ args: []
3489
+ }, {
3490
+ id: 'copyImage',
3491
+ label: copyImageUrl$1(),
3492
+ flags: None$2,
3493
+ command: 'ExtensionDetail.copyImageUrl',
3494
+ args: []
3484
3495
  }];
3485
3496
  };
3486
- const getMenuEntriesReadme$1 = props => {
3487
- if (props.href) {
3488
- return getMenuEntriesReadmeLink(props);
3497
+
3498
+ const getMenuEntries2 = (state, props) => {
3499
+ if (props.menuId === ExtensionDetailIconContextMenu$3) {
3500
+ return getMenuEntriesImage();
3489
3501
  }
3490
3502
  return [{
3491
3503
  id: 'copy',
3492
3504
  label: copy$1(),
3493
3505
  flags: None$2,
3494
- command: 'ExtensionDetail.copyReadmeText',
3506
+ command: 'ExtensionDetail.executeCopy',
3495
3507
  args: []
3496
3508
  }];
3497
3509
  };
3498
3510
 
3499
- // TODO maybe add props object as second property with properties like imagesrc, linksrc, nodeName
3500
-
3501
- const getMenuEntries2 = (state, props) => {
3502
- return getMenuEntriesReadme$1(props);
3503
- };
3504
-
3505
3511
  const None = 0;
3506
3512
 
3507
3513
  const getCopyMenuEntry = () => ({
@@ -3828,9 +3834,6 @@ const handleIconError = state => {
3828
3834
  };
3829
3835
  };
3830
3836
 
3831
- const show = async (menuId, x, y) => {
3832
- await showContextMenu(x, y, menuId);
3833
- };
3834
3837
  const show2 = async (uid, menuId, x, y, args) => {
3835
3838
  // @ts-ignore
3836
3839
  await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
@@ -3839,7 +3842,12 @@ const show2 = async (uid, menuId, x, y, args) => {
3839
3842
  const ExtensionDetailIconContextMenu = 4091;
3840
3843
 
3841
3844
  const handleImageContextMenu = async (state, eventX, eventY) => {
3842
- await show(ExtensionDetailIconContextMenu, eventX, eventY);
3845
+ const {
3846
+ uid
3847
+ } = state;
3848
+ await show2(uid, ExtensionDetailIconContextMenu, eventX, eventY, {
3849
+ menuId: ExtensionDetailIconContextMenu
3850
+ });
3843
3851
  return state;
3844
3852
  };
3845
3853
 
@@ -3880,6 +3888,11 @@ const handleScroll = (state, scrollTop, scrollSource = Script) => {
3880
3888
  };
3881
3889
  };
3882
3890
 
3891
+ const handleSelectionChange = async (state, selection) => {
3892
+ // console.log('selection change')
3893
+ return state;
3894
+ };
3895
+
3883
3896
  const readFile = async uri => {
3884
3897
  return readFile$1(uri);
3885
3898
  };
@@ -4109,7 +4122,11 @@ const initialize = async () => {
4109
4122
  };
4110
4123
 
4111
4124
  const existsFile = async uri => {
4112
- return exists(uri);
4125
+ try {
4126
+ return await exists(uri);
4127
+ } catch {
4128
+ return false;
4129
+ }
4113
4130
  };
4114
4131
 
4115
4132
  class ExtensionNotFoundError extends Error {
@@ -4324,12 +4341,25 @@ const loadHeaderContent = (state, platform, extension) => {
4324
4341
  };
4325
4342
  };
4326
4343
 
4327
- const getCategories = () => {
4328
- // TODO
4329
- return [{
4330
- id: 'themes',
4331
- label: 'Themes'
4332
- }];
4344
+ const stringifyCategory = category => {
4345
+ if (typeof category === 'string') {
4346
+ return category;
4347
+ }
4348
+ return JSON.stringify(category);
4349
+ };
4350
+ const toCategory = categoryString => {
4351
+ return {
4352
+ id: categoryString.toLowerCase(),
4353
+ label: categoryString
4354
+ };
4355
+ };
4356
+ const getCategories = extension => {
4357
+ if (!hasProperty(extension, 'categories') || !Array.isArray(extension.categories)) {
4358
+ return [];
4359
+ }
4360
+ const categoryStrings = extension.categories.map(stringifyCategory);
4361
+ const categories = categoryStrings.map(toCategory);
4362
+ return categories;
4333
4363
  };
4334
4364
 
4335
4365
  const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
@@ -4512,17 +4542,24 @@ const getMarketplaceEntries = isBuiltin => {
4512
4542
  }];
4513
4543
  };
4514
4544
 
4515
- const getResources = isBuiltin => {
4545
+ const getRepositoryLink = extension => {
4546
+ if (extension && hasProperty(extension, 'repository') && typeof extension.repository === 'string') {
4547
+ return extension.repository; // TODO watch out for javascript: or other invalid links or path traversal
4548
+ }
4549
+ return '';
4550
+ };
4551
+ const getResources = (isBuiltin, extension) => {
4516
4552
  if (isBuiltin) {
4517
4553
  return [];
4518
4554
  }
4555
+ const repositoryLink = getRepositoryLink(extension);
4519
4556
  // TODO
4520
4557
  return [{
4521
4558
  label: marketplace(),
4522
4559
  url: '#'
4523
4560
  }, {
4524
4561
  label: issues(),
4525
- url: '#'
4562
+ url: repositoryLink
4526
4563
  }, {
4527
4564
  label: repository(),
4528
4565
  url: '#'
@@ -4532,13 +4569,13 @@ const getResources = isBuiltin => {
4532
4569
  }];
4533
4570
  };
4534
4571
 
4535
- const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, isBuiltin) => {
4572
+ const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, isBuiltin, extension) => {
4536
4573
  const folderSize = await getFolderSize(extensionUri);
4537
4574
  const displaySize = getDisplaySize(folderSize);
4538
4575
  const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri);
4539
4576
  const marketplaceEntries = getMarketplaceEntries(isBuiltin);
4540
- const categories = getCategories();
4541
- const resources = getResources(isBuiltin);
4577
+ const categories = getCategories(extension);
4578
+ const resources = getResources(isBuiltin, extension);
4542
4579
  return {
4543
4580
  installationEntries,
4544
4581
  marketplaceEntries,
@@ -4652,7 +4689,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4652
4689
  categories,
4653
4690
  resources,
4654
4691
  folderSize
4655
- } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin);
4692
+ } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin, extension);
4656
4693
  const padding = getPadding(width);
4657
4694
  const sideBarWidth = getSideBarWidth(width);
4658
4695
  const showSideBar = sideBarWidth > 0;
@@ -5303,6 +5340,9 @@ const renderEventListeners = () => {
5303
5340
  }, {
5304
5341
  name: HandleClickSetColorTheme,
5305
5342
  params: ['handleClickSetColorTheme']
5343
+ }, {
5344
+ name: HandleSelectionChange,
5345
+ params: ['handleSelectionChange']
5306
5346
  }];
5307
5347
  };
5308
5348
 
@@ -5342,14 +5382,14 @@ const commandMap = {
5342
5382
  'ExtensionDetail.create': create,
5343
5383
  'ExtensionDetail.diff2': diff2,
5344
5384
  'ExtensionDetail.dispose': dispose,
5385
+ 'ExtensionDetail.executeCopy': wrapCommand(executeCopy),
5345
5386
  'ExtensionDetail.getCommandIds': getCommandIds,
5346
5387
  'ExtensionDetail.getMenuEntries': getMenuEntries,
5347
5388
  'ExtensionDetail.getMenuEntries2': wrapGetter(getMenuEntries2),
5348
- 'ExtensionDetail.getMenus': getMenus,
5349
5389
  'ExtensionDetail.getMenuIds': getMenuIds,
5350
- 'ExtensionDetail.handleClickCategory': wrapCommand(handleClickCategory),
5351
- 'ExtensionDetail.handleReadmeContextMenu': wrapCommand(handleReadmeContextMenu),
5390
+ 'ExtensionDetail.getMenus': getMenus,
5352
5391
  'ExtensionDetail.handleAdditionalDetailsContextMenu': wrapCommand(handleAdditionalDetailContextMenu),
5392
+ 'ExtensionDetail.handleClickCategory': wrapCommand(handleClickCategory),
5353
5393
  'ExtensionDetail.handleClickDisable': wrapCommand(handleClickDisable),
5354
5394
  'ExtensionDetail.handleClickEnable': wrapCommand(handleClickEnable),
5355
5395
  'ExtensionDetail.handleClickScrollToTop': wrapCommand(handleClickScrollToTop),
@@ -5361,9 +5401,11 @@ const commandMap = {
5361
5401
  'ExtensionDetail.handleFeaturesClick': wrapCommand(handleClickFeatures),
5362
5402
  'ExtensionDetail.handleIconError': wrapCommand(handleIconError),
5363
5403
  'ExtensionDetail.handleImageContextMenu': wrapCommand(handleImageContextMenu),
5404
+ 'ExtensionDetail.handleReadmeClick': wrapCommand(handleReadmeClick),
5405
+ 'ExtensionDetail.handleReadmeContextMenu': wrapCommand(handleReadmeContextMenu),
5364
5406
  'ExtensionDetail.handleScroll': wrapCommand(handleScroll),
5407
+ 'ExtensionDetail.handleSelectionChange': wrapCommand(handleSelectionChange),
5365
5408
  'ExtensionDetail.handleTabsClick': wrapCommand(handleTabsClick),
5366
- 'ExtensionDetail.handleReadmeClick': wrapCommand(handleReadmeClick),
5367
5409
  'ExtensionDetail.handleWheel': wrapCommand(handleScroll),
5368
5410
  // deprecated
5369
5411
  'ExtensionDetail.initialize': initialize,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "5.0.0",
3
+ "version": "5.2.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": "^1.29.0"
14
+ "@lvce-editor/constants": "^1.30.0"
15
15
  }
16
16
  }