@lvce-editor/extension-detail-view 5.0.0 → 5.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.
@@ -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;
@@ -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
  };
@@ -4324,12 +4337,25 @@ const loadHeaderContent = (state, platform, extension) => {
4324
4337
  };
4325
4338
  };
4326
4339
 
4327
- const getCategories = () => {
4328
- // TODO
4329
- return [{
4330
- id: 'themes',
4331
- label: 'Themes'
4332
- }];
4340
+ const stringifyCategory = category => {
4341
+ if (typeof category === 'string') {
4342
+ return category;
4343
+ }
4344
+ return JSON.stringify(category);
4345
+ };
4346
+ const toCategory = categoryString => {
4347
+ return {
4348
+ id: categoryString.toLowerCase(),
4349
+ label: categoryString
4350
+ };
4351
+ };
4352
+ const getCategories = extension => {
4353
+ if (!hasProperty(extension, 'categories') || !Array.isArray(extension.categories)) {
4354
+ return [];
4355
+ }
4356
+ const categoryStrings = extension.categories.map(stringifyCategory);
4357
+ const categories = categoryStrings.map(toCategory);
4358
+ return categories;
4333
4359
  };
4334
4360
 
4335
4361
  const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
@@ -4532,12 +4558,12 @@ const getResources = isBuiltin => {
4532
4558
  }];
4533
4559
  };
4534
4560
 
4535
- const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, isBuiltin) => {
4561
+ const loadSideBarContent = async (extensionId, extensionVersion, extensionUri, isBuiltin, extension) => {
4536
4562
  const folderSize = await getFolderSize(extensionUri);
4537
4563
  const displaySize = getDisplaySize(folderSize);
4538
4564
  const installationEntries = getInstallationEntries(displaySize, extensionId, extensionVersion, extensionUri);
4539
4565
  const marketplaceEntries = getMarketplaceEntries(isBuiltin);
4540
- const categories = getCategories();
4566
+ const categories = getCategories(extension);
4541
4567
  const resources = getResources(isBuiltin);
4542
4568
  return {
4543
4569
  installationEntries,
@@ -4652,7 +4678,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4652
4678
  categories,
4653
4679
  resources,
4654
4680
  folderSize
4655
- } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin);
4681
+ } = await loadSideBarContent(extensionId, extensionVersion, extensionUri, isBuiltin, extension);
4656
4682
  const padding = getPadding(width);
4657
4683
  const sideBarWidth = getSideBarWidth(width);
4658
4684
  const showSideBar = sideBarWidth > 0;
@@ -5303,6 +5329,9 @@ const renderEventListeners = () => {
5303
5329
  }, {
5304
5330
  name: HandleClickSetColorTheme,
5305
5331
  params: ['handleClickSetColorTheme']
5332
+ }, {
5333
+ name: HandleSelectionChange,
5334
+ params: ['handleSelectionChange']
5306
5335
  }];
5307
5336
  };
5308
5337
 
@@ -5342,14 +5371,14 @@ const commandMap = {
5342
5371
  'ExtensionDetail.create': create,
5343
5372
  'ExtensionDetail.diff2': diff2,
5344
5373
  'ExtensionDetail.dispose': dispose,
5374
+ 'ExtensionDetail.executeCopy': wrapCommand(executeCopy),
5345
5375
  'ExtensionDetail.getCommandIds': getCommandIds,
5346
5376
  'ExtensionDetail.getMenuEntries': getMenuEntries,
5347
5377
  'ExtensionDetail.getMenuEntries2': wrapGetter(getMenuEntries2),
5348
- 'ExtensionDetail.getMenus': getMenus,
5349
5378
  'ExtensionDetail.getMenuIds': getMenuIds,
5350
- 'ExtensionDetail.handleClickCategory': wrapCommand(handleClickCategory),
5351
- 'ExtensionDetail.handleReadmeContextMenu': wrapCommand(handleReadmeContextMenu),
5379
+ 'ExtensionDetail.getMenus': getMenus,
5352
5380
  'ExtensionDetail.handleAdditionalDetailsContextMenu': wrapCommand(handleAdditionalDetailContextMenu),
5381
+ 'ExtensionDetail.handleClickCategory': wrapCommand(handleClickCategory),
5353
5382
  'ExtensionDetail.handleClickDisable': wrapCommand(handleClickDisable),
5354
5383
  'ExtensionDetail.handleClickEnable': wrapCommand(handleClickEnable),
5355
5384
  'ExtensionDetail.handleClickScrollToTop': wrapCommand(handleClickScrollToTop),
@@ -5361,9 +5390,11 @@ const commandMap = {
5361
5390
  'ExtensionDetail.handleFeaturesClick': wrapCommand(handleClickFeatures),
5362
5391
  'ExtensionDetail.handleIconError': wrapCommand(handleIconError),
5363
5392
  'ExtensionDetail.handleImageContextMenu': wrapCommand(handleImageContextMenu),
5393
+ 'ExtensionDetail.handleReadmeClick': wrapCommand(handleReadmeClick),
5394
+ 'ExtensionDetail.handleReadmeContextMenu': wrapCommand(handleReadmeContextMenu),
5364
5395
  'ExtensionDetail.handleScroll': wrapCommand(handleScroll),
5396
+ 'ExtensionDetail.handleSelectionChange': wrapCommand(handleSelectionChange),
5365
5397
  'ExtensionDetail.handleTabsClick': wrapCommand(handleTabsClick),
5366
- 'ExtensionDetail.handleReadmeClick': wrapCommand(handleReadmeClick),
5367
5398
  'ExtensionDetail.handleWheel': wrapCommand(handleScroll),
5368
5399
  // deprecated
5369
5400
  '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.1.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
  }