@lvce-editor/completion-worker 1.22.0 → 1.23.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.
@@ -552,7 +552,7 @@ const registerPromise = () => {
552
552
  promise
553
553
  };
554
554
  };
555
- const create$2$2 = (method, params) => {
555
+ const create$2$1 = (method, params) => {
556
556
  const {
557
557
  id,
558
558
  promise
@@ -773,7 +773,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
773
773
  const errorProperty = getErrorProperty(error, prettyError);
774
774
  return create$1$1(id, errorProperty);
775
775
  };
776
- const create$5 = (message, result) => {
776
+ const create$6 = (message, result) => {
777
777
  return {
778
778
  jsonrpc: Two,
779
779
  id: message.id,
@@ -782,7 +782,7 @@ const create$5 = (message, result) => {
782
782
  };
783
783
  const getSuccessResponse = (message, result) => {
784
784
  const resultProperty = result ?? null;
785
- return create$5(message, resultProperty);
785
+ return create$6(message, resultProperty);
786
786
  };
787
787
  const getErrorResponseSimple = (id, error) => {
788
788
  return {
@@ -877,7 +877,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
877
877
  const {
878
878
  message,
879
879
  promise
880
- } = create$2$2(method, params);
880
+ } = create$2$1(method, params);
881
881
  if (useSendAndTransfer && ipc.sendAndTransfer) {
882
882
  ipc.sendAndTransfer(message);
883
883
  } else {
@@ -964,7 +964,7 @@ const listen$1 = async (module, options) => {
964
964
  const ipc = module.wrap(rawIpc);
965
965
  return ipc;
966
966
  };
967
- const create$4 = async ({
967
+ const create$5 = async ({
968
968
  commandMap,
969
969
  messagePort
970
970
  }) => {
@@ -980,7 +980,7 @@ const create$4 = async ({
980
980
  messagePort.start();
981
981
  return rpc;
982
982
  };
983
- const create$2$1 = async ({
983
+ const create$3 = async ({
984
984
  commandMap,
985
985
  send
986
986
  }) => {
@@ -989,16 +989,16 @@ const create$2$1 = async ({
989
989
  port2
990
990
  } = new MessageChannel();
991
991
  await send(port1);
992
- return create$4({
992
+ return create$5({
993
993
  commandMap,
994
994
  messagePort: port2
995
995
  });
996
996
  };
997
997
  const TransferMessagePortRpcParent = {
998
998
  __proto__: null,
999
- create: create$2$1
999
+ create: create$3
1000
1000
  };
1001
- const create$3 = async ({
1001
+ const create$4 = async ({
1002
1002
  commandMap
1003
1003
  }) => {
1004
1004
  // TODO create a commandMap per rpc instance
@@ -1010,11 +1010,16 @@ const create$3 = async ({
1010
1010
  };
1011
1011
  const WebWorkerRpcClient = {
1012
1012
  __proto__: null,
1013
- create: create$3
1013
+ create: create$4
1014
1014
  };
1015
1015
 
1016
+ const toCommandId = key => {
1017
+ const dotIndex = key.indexOf('.');
1018
+ return key.slice(dotIndex + 1);
1019
+ };
1016
1020
  const create$2 = () => {
1017
1021
  const states = Object.create(null);
1022
+ const commandMapRef = {};
1018
1023
  return {
1019
1024
  get(uid) {
1020
1025
  return states[uid];
@@ -1055,6 +1060,15 @@ const create$2 = () => {
1055
1060
  };
1056
1061
  return wrapped;
1057
1062
  },
1063
+ wrapGetter(fn) {
1064
+ const wrapped = (uid, ...args) => {
1065
+ const {
1066
+ newState
1067
+ } = states[uid];
1068
+ return fn(newState, ...args);
1069
+ };
1070
+ return wrapped;
1071
+ },
1058
1072
  diff(uid, modules, numbers) {
1059
1073
  const {
1060
1074
  oldState,
@@ -1068,6 +1082,14 @@ const create$2 = () => {
1068
1082
  }
1069
1083
  }
1070
1084
  return diffResult;
1085
+ },
1086
+ getCommandIds() {
1087
+ const keys = Object.keys(commandMapRef);
1088
+ const ids = keys.map(toCommandId);
1089
+ return ids;
1090
+ },
1091
+ registerCommands(commandMap) {
1092
+ Object.assign(commandMapRef, commandMap);
1071
1093
  }
1072
1094
  };
1073
1095
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/completion-worker",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",