@lvce-editor/about-view 5.11.0 → 5.12.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.
@@ -477,7 +477,8 @@ const splitLines = lines => {
477
477
  return lines.split(NewLine$1);
478
478
  };
479
479
  const getCurrentStack = () => {
480
- const currentStack = joinLines$1(splitLines(new Error().stack || '').slice(2));
480
+ const stackLinesToSkip = 3;
481
+ const currentStack = joinLines$1(splitLines(new Error().stack || '').slice(stackLinesToSkip));
481
482
  return currentStack;
482
483
  };
483
484
  const getNewLineIndex = (string, startIndex = undefined) => {
@@ -748,6 +749,12 @@ const invokeAndTransfer = (ipc, method, ...params) => {
748
749
  return invokeHelper(ipc, method, params, true);
749
750
  };
750
751
 
752
+ class CommandNotFoundError extends Error {
753
+ constructor(command) {
754
+ super(`Command not found ${command}`);
755
+ this.name = 'CommandNotFoundError';
756
+ }
757
+ }
751
758
  const commands = Object.create(null);
752
759
  const register = commandMap => {
753
760
  Object.assign(commands, commandMap);
@@ -758,7 +765,7 @@ const getCommand = key => {
758
765
  const execute = (command, ...args) => {
759
766
  const fn = getCommand(command);
760
767
  if (!fn) {
761
- throw new Error(`command not found ${command}`);
768
+ throw new CommandNotFoundError(command);
762
769
  }
763
770
  return fn(...args);
764
771
  };
@@ -830,8 +837,13 @@ const WebWorkerRpcClient = {
830
837
  create: create$3
831
838
  };
832
839
 
840
+ const toCommandId = key => {
841
+ const dotIndex = key.indexOf('.');
842
+ return key.slice(dotIndex + 1);
843
+ };
833
844
  const create$2 = () => {
834
845
  const states = Object.create(null);
846
+ const commandMapRef = {};
835
847
  return {
836
848
  get(uid) {
837
849
  return states[uid];
@@ -872,6 +884,15 @@ const create$2 = () => {
872
884
  };
873
885
  return wrapped;
874
886
  },
887
+ wrapGetter(fn) {
888
+ const wrapped = (uid, ...args) => {
889
+ const {
890
+ newState
891
+ } = states[uid];
892
+ return fn(newState, ...args);
893
+ };
894
+ return wrapped;
895
+ },
875
896
  diff(uid, modules, numbers) {
876
897
  const {
877
898
  oldState,
@@ -885,6 +906,14 @@ const create$2 = () => {
885
906
  }
886
907
  }
887
908
  return diffResult;
909
+ },
910
+ getCommandIds() {
911
+ const keys = Object.keys(commandMapRef);
912
+ const ids = keys.map(toCommandId);
913
+ return ids;
914
+ },
915
+ registerCommands(commandMap) {
916
+ Object.assign(commandMapRef, commandMap);
888
917
  }
889
918
  };
890
919
  };
@@ -1087,37 +1116,37 @@ const create = rpcId => {
1087
1116
  };
1088
1117
  const RendererWorker$1 = 1;
1089
1118
  const {
1090
- invoke: invoke$4,
1119
+ invoke: invoke$3,
1091
1120
  set: set$3} = create(RendererWorker$1);
1092
1121
  const getElectronVersion$2 = async () => {
1093
- return invoke$4('Process.getElectronVersion');
1122
+ return invoke$3('Process.getElectronVersion');
1094
1123
  };
1095
1124
  const getNodeVersion$2 = async () => {
1096
- return invoke$4('Process.getNodeVersion');
1125
+ return invoke$3('Process.getNodeVersion');
1097
1126
  };
1098
1127
  const getChromeVersion$2 = async () => {
1099
- return invoke$4('Process.getChromeVersion');
1128
+ return invoke$3('Process.getChromeVersion');
1100
1129
  };
1101
1130
  const getV8Version$2 = async () => {
1102
- return invoke$4('Process.getV8Version');
1131
+ return invoke$3('Process.getV8Version');
1103
1132
  };
1104
1133
  const setFocus$1 = key => {
1105
- return invoke$4('Focus.setFocus', key);
1134
+ return invoke$3('Focus.setFocus', key);
1106
1135
  };
1107
1136
  const closeWidget$2 = async widgetId => {
1108
- return invoke$4('Viewlet.closeWidget', widgetId);
1137
+ return invoke$3('Viewlet.closeWidget', widgetId);
1109
1138
  };
1110
1139
  const writeClipBoardText$1 = async text => {
1111
- await invoke$4('ClipBoard.writeText', /* text */text);
1140
+ await invoke$3('ClipBoard.writeText', /* text */text);
1112
1141
  };
1113
1142
  const showMessageBox$2 = async options => {
1114
- return invoke$4('ElectronDialog.showMessageBox', options);
1143
+ return invoke$3('ElectronDialog.showMessageBox', options);
1115
1144
  };
1116
1145
  const openWidget$1 = async name => {
1117
- await invoke$4('Viewlet.openWidget', name);
1146
+ await invoke$3('Viewlet.openWidget', name);
1118
1147
  };
1119
1148
  const getWindowId$2 = async () => {
1120
- return invoke$4('GetWindowId.getWindowId');
1149
+ return invoke$3('GetWindowId.getWindowId');
1121
1150
  };
1122
1151
  const RendererWorker$2 = {
1123
1152
  __proto__: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "5.11.0",
3
+ "version": "5.12.0",
4
4
  "description": "About View Worker",
5
5
  "keywords": [
6
6
  "about-view"