@lvce-editor/extension-detail-view 3.53.0 → 3.55.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.
@@ -41,6 +41,7 @@ const Schema = 'Schema';
41
41
  const ScrollToTop$1 = 'Scroll to top';
42
42
  const Selector = 'Selector';
43
43
  const SetColorTheme$1 = 'Set Color Theme';
44
+ const Enable$1 = 'Enable';
44
45
  const Settings$1 = 'Settings';
45
46
  const Theme$1 = 'Theme';
46
47
  const Uninstall$1 = 'Uninstall';
@@ -103,6 +104,9 @@ const schema = () => {
103
104
  const setColorTheme$3 = () => {
104
105
  return i18nString(SetColorTheme$1);
105
106
  };
107
+ const enable = () => {
108
+ return i18nString(Enable$1);
109
+ };
106
110
  const theme = () => {
107
111
  return i18nString(Theme$1);
108
112
  };
@@ -697,6 +701,9 @@ const sendMessagePortToFileSystemWorker$2 = async (port, rpcId) => {
697
701
  // @ts-ignore
698
702
  await invokeAndTransfer$3('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
699
703
  };
704
+ const disableExtension$2 = async id => {
705
+ return invoke$3('ExtensionManagement.disable', id);
706
+ };
700
707
  const sendMessagePortToExtensionHostWorker$2 = async (port, rpcId = 0) => {
701
708
  const command = 'HandleMessagePort.handleMessagePort2';
702
709
  await invokeAndTransfer$3('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
@@ -736,6 +743,7 @@ const openUrl$2 = async uri => {
736
743
  };
737
744
  const RendererWorker = {
738
745
  __proto__: null,
746
+ disableExtension: disableExtension$2,
739
747
  getAllExtensions: getAllExtensions$2,
740
748
  getExtension: getExtension$3,
741
749
  openExtensionSearch: openExtensionSearch$2,
@@ -770,12 +778,14 @@ const getRuntimeStatusDetails = async extension => {
770
778
  const {
771
779
  activationEvent,
772
780
  status,
773
- activationTime
781
+ activationTime,
782
+ importTime
774
783
  } = await getRuntimeStatus(extension.id);
775
784
  return {
776
785
  wasActivatedByEvent: activationEvent,
777
786
  activationTime,
778
- status
787
+ status,
788
+ importTime
779
789
  };
780
790
  };
781
791
 
@@ -789,6 +799,35 @@ const featureRuntimeStatusEnabled = extension => {
789
799
  return false;
790
800
  };
791
801
 
802
+ const formatTime = time => {
803
+ return time.toFixed(2) + 'ms';
804
+ };
805
+
806
+ const getActivationTimeVirtualDom = (importTime, activationTime) => {
807
+ if (!activationTime && !importTime) {
808
+ return [];
809
+ }
810
+ const formattedImportTime = formatTime(importTime);
811
+ const formattedTime = formatTime(activationTime);
812
+ return [{
813
+ type: VirtualDomElements.Dt,
814
+ childCount: 1
815
+ }, text('Import Time: '),
816
+ // i18n
817
+ {
818
+ type: VirtualDomElements.Dd,
819
+ childCount: 1
820
+ }, text(formattedImportTime), {
821
+ type: VirtualDomElements.Dt,
822
+ childCount: 1
823
+ }, text('Activation Time: '),
824
+ // i18n
825
+ {
826
+ type: VirtualDomElements.Dd,
827
+ childCount: 1
828
+ }, text(formattedTime)];
829
+ };
830
+
792
831
  const None$1 = 0;
793
832
  const Importing = 1;
794
833
  const Activating = 2;
@@ -812,50 +851,43 @@ const getStatusMessage = statusType => {
812
851
  }
813
852
  };
814
853
 
815
- const formatTime = time => {
816
- return time.toFixed(2) + 'ms';
817
- };
818
- const getActivationTimeVirtualDom = activationTime => {
819
- if (!activationTime) {
820
- return [];
821
- }
822
- const formattedTime = formatTime(activationTime);
823
- return [{
824
- type: VirtualDomElements.P,
825
- childCount: 2
826
- }, text('Activation Time: '),
827
- // i18n
828
- text(formattedTime)];
829
- };
830
854
  const getStatusVirtualDom = status => {
831
855
  const statusString = getStatusMessage(status);
832
856
  return [{
833
- type: VirtualDomElements.P,
834
- childCount: 2
857
+ type: VirtualDomElements.Dt,
858
+ childCount: 1
835
859
  }, text(`Status: `),
836
860
  // i18n
837
- text(`${statusString}`)];
861
+ {
862
+ type: VirtualDomElements.Dd,
863
+ childCount: 1
864
+ }, text(`${statusString}`)];
838
865
  };
839
- const getChildCount$1 = (status, activationTime) => {
840
- let childCount = 1; // heading
841
- childCount++; // status
842
- if (activationTime) {
843
- childCount++; // activation time
866
+
867
+ const getChildCount$1 = (status, activationTime, importTime) => {
868
+ let childCount = 0;
869
+ childCount += 2; // status
870
+ if (importTime || activationTime) {
871
+ childCount += 4;
844
872
  }
845
873
  return childCount;
846
874
  };
847
875
  const getRuntimeStatusVirtualDom = state => {
848
876
  const {
849
877
  status,
850
- activationTime
878
+ activationTime,
879
+ importTime
851
880
  } = state;
852
881
  const heading = runtimeStatus();
853
- const childCount = getChildCount$1(status, activationTime);
882
+ const childCount = getChildCount$1(status, activationTime, importTime);
854
883
  return [{
855
884
  type: VirtualDomElements.Div,
856
885
  className: FeatureContent,
857
- childCount: childCount
858
- }, ...getFeatureContentHeadingVirtualDom(heading), ...getStatusVirtualDom(status), ...getActivationTimeVirtualDom(activationTime)];
886
+ childCount: 2
887
+ }, ...getFeatureContentHeadingVirtualDom(heading), {
888
+ type: VirtualDomElements.Dl,
889
+ childCount
890
+ }, ...getStatusVirtualDom(status), ...getActivationTimeVirtualDom(activationTime, importTime)];
859
891
  };
860
892
 
861
893
  const getSettingsTableEntry = setting => {
@@ -956,6 +988,7 @@ const string = value => {
956
988
 
957
989
  const HandleClickCategory = 'handleClickCategory';
958
990
  const HandleClickDisable = 'handleClickDisable';
991
+ const HandleClickEnable = 'handleClickEnable';
959
992
  const HandleClickScrollToTop = 'handleClickScrollToTop';
960
993
  const HandleClickSetColorTheme = 'handleClickSetColorTheme';
961
994
  const HandleClickSettings = 'handleClickSettings';
@@ -972,6 +1005,7 @@ const ActivationEvents = 'ActivationEvents';
972
1005
  const Changelog = 'Changelog';
973
1006
  const Commands = 'Commands';
974
1007
  const Details = 'Details';
1008
+ const Enable = 'Enable';
975
1009
  const Disable = 'Disable';
976
1010
  const Features = 'Features';
977
1011
  const JsonValidation = 'JsonValidation';
@@ -2316,12 +2350,13 @@ const terminate = () => {
2316
2350
  };
2317
2351
 
2318
2352
  const {
2353
+ disableExtension: disableExtension$1,
2319
2354
  getAllExtensions: getAllExtensions$1,
2320
2355
  getExtension: getExtension$2,
2321
2356
  openExtensionSearch: openExtensionSearch$1,
2322
- sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
2323
2357
  openNativeFolder,
2324
- writeClipBoardText,
2358
+ openUrl: openUrl$1,
2359
+ sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
2325
2360
  sendMessagePortToFileSystemWorker: sendMessagePortToFileSystemWorker$1,
2326
2361
  sendMessagePortToMarkdownWorker: sendMessagePortToMarkdownWorker$1,
2327
2362
  set: set$2,
@@ -2330,7 +2365,7 @@ const {
2330
2365
  showContextMenu,
2331
2366
  uninstallExtension,
2332
2367
  writeClipBoardImage,
2333
- openUrl: openUrl$1
2368
+ writeClipBoardText
2334
2369
  } = RendererWorker;
2335
2370
 
2336
2371
  const writeClipboardImage = async blob => {
@@ -2393,6 +2428,8 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
2393
2428
  const state = {
2394
2429
  wasActivatedByEvent: '',
2395
2430
  activationTime: 0,
2431
+ importTime: 0,
2432
+ disabled: false,
2396
2433
  status: 0,
2397
2434
  uid,
2398
2435
  activationEvents: [],
@@ -2571,7 +2608,16 @@ const handleClickCategory = async (state, categoryId) => {
2571
2608
  return state;
2572
2609
  };
2573
2610
 
2611
+ const disableExtension = id => {
2612
+ return disableExtension$1(id);
2613
+ };
2614
+
2574
2615
  const handleClickDisable = async state => {
2616
+ const {
2617
+ extensionId
2618
+ } = state;
2619
+ await disableExtension(extensionId);
2620
+ // TODO when it fails, show dialog / alert?
2575
2621
  return state;
2576
2622
  };
2577
2623
 
@@ -2666,6 +2712,14 @@ const handleClickUninstall = async state => {
2666
2712
  return state;
2667
2713
  };
2668
2714
 
2715
+ const handleExtensionsStatusUpdate = async state => {
2716
+ const details = await getRuntimeStatusDetails(state.extension);
2717
+ return {
2718
+ ...state,
2719
+ ...details
2720
+ };
2721
+ };
2722
+
2669
2723
  const extensionDefaultIcon = assetDir => {
2670
2724
  return `${assetDir}/icons/extensionDefaultIcon.png`;
2671
2725
  };
@@ -2984,16 +3038,21 @@ const getBaseUrl = (extensionPath, platform) => {
2984
3038
  }
2985
3039
  };
2986
3040
 
2987
- const getExtensionDetailButtons = (hasColorTheme, isBuiltin) => {
3041
+ const getExtensionDetailButtons = (hasColorTheme, isBuiltin, isDisabled) => {
2988
3042
  const allActions = [{
2989
3043
  label: setColorTheme$3(),
2990
3044
  onClick: HandleClickSetColorTheme,
2991
3045
  enabled: hasColorTheme,
2992
3046
  name: SetColorTheme
3047
+ }, {
3048
+ label: enable(),
3049
+ onClick: HandleClickEnable,
3050
+ enabled: isDisabled,
3051
+ name: Enable
2993
3052
  }, {
2994
3053
  label: disable(),
2995
3054
  onClick: HandleClickDisable,
2996
- enabled: true,
3055
+ enabled: !isDisabled,
2997
3056
  name: Disable
2998
3057
  }, {
2999
3058
  label: uninstall(),
@@ -3365,7 +3424,10 @@ const restoreState = savedState => {
3365
3424
  };
3366
3425
  };
3367
3426
 
3368
- const loadContent = async (state, platform, savedState) => {
3427
+ const loadContent = async (state, platform, savedState, isTest = false) => {
3428
+ if (isTest) {
3429
+ savedState = undefined;
3430
+ }
3369
3431
  const {
3370
3432
  width,
3371
3433
  uri
@@ -3398,7 +3460,8 @@ const loadContent = async (state, platform, savedState) => {
3398
3460
  scrollToTopEnabled: true
3399
3461
  });
3400
3462
  const isBuiltin = extension?.isBuiltin;
3401
- const buttons = getExtensionDetailButtons(hasColorTheme, isBuiltin);
3463
+ const disabled = extension?.disabled;
3464
+ const buttons = getExtensionDetailButtons(hasColorTheme, isBuiltin, disabled);
3402
3465
  const enabledButtons = buttons.filter(button => button.enabled);
3403
3466
  const size = getViewletSize(width);
3404
3467
  const {
@@ -3429,6 +3492,7 @@ const loadContent = async (state, platform, savedState) => {
3429
3492
  changelogScrollTop,
3430
3493
  description,
3431
3494
  detailsVirtualDom,
3495
+ disabled,
3432
3496
  displaySize,
3433
3497
  extension,
3434
3498
  extensionId,
@@ -3454,8 +3518,8 @@ const loadContent = async (state, platform, savedState) => {
3454
3518
  };
3455
3519
  };
3456
3520
 
3457
- const loadContent2 = async (state, savedState) => {
3458
- return loadContent(state, state.platform, savedState);
3521
+ const loadContent2 = async (state, savedState, isTest = false) => {
3522
+ return loadContent(state, state.platform, savedState, isTest);
3459
3523
  };
3460
3524
 
3461
3525
  const openUrl = async uri => {
@@ -4045,6 +4109,7 @@ const commandMap = {
4045
4109
  'ExtensionDetail.handleClickSettings': wrapCommand(handleClickSettings),
4046
4110
  'ExtensionDetail.handleClickSize': wrapCommand(handleClickSize),
4047
4111
  'ExtensionDetail.handleClickUninstall': wrapCommand(handleClickUninstall),
4112
+ 'ExtensionDetail.handleExtensionsStatusUpdate': wrapCommand(handleExtensionsStatusUpdate),
4048
4113
  'ExtensionDetail.handleFeaturesClick': wrapCommand(handleClickFeatures),
4049
4114
  'ExtensionDetail.handleIconError': wrapCommand(handleIconError),
4050
4115
  'ExtensionDetail.handleImageContextMenu': wrapCommand(handleImageContextMenu),
@@ -4052,16 +4117,15 @@ const commandMap = {
4052
4117
  'ExtensionDetail.handleTabsClick': wrapCommand(handleTabsClick),
4053
4118
  'ExtensionDetail.handleWheel': wrapCommand(handleScroll),
4054
4119
  // deprecated
4120
+ 'ExtensionDetail.initialize': initialize,
4055
4121
  'ExtensionDetail.loadContent2': wrapCommand(loadContent2),
4056
4122
  'ExtensionDetail.openImageInNewTab': wrapCommand(openImageInNewTab),
4057
4123
  'ExtensionDetail.render2': render2,
4058
4124
  'ExtensionDetail.renderEventListeners': renderEventListeners,
4059
4125
  'ExtensionDetail.resize': wrapCommand(resize),
4060
- // @ts-ignore
4061
4126
  'ExtensionDetail.saveState': wrapGetter(saveState),
4062
4127
  'ExtensionDetail.selectTab': wrapCommand(selectTab),
4063
- 'ExtensionDetail.terminate': terminate,
4064
- 'ExtensionDetail.initialize': initialize
4128
+ 'ExtensionDetail.terminate': terminate
4065
4129
  };
4066
4130
 
4067
4131
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "3.53.0",
3
+ "version": "3.55.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",