@ic-reactor/react 1.1.3 → 1.1.4

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.
@@ -49,6 +49,9 @@ const DEFAULT_STATE = {
49
49
  const actorHooks = (actorManager) => {
50
50
  const { actorStore, canisterId, visitFunction, callMethod, initialize } = actorManager;
51
51
  const useActorState = () => (Object.assign(Object.assign({}, (0, zustand_1.useStore)(actorStore)), { canisterId }));
52
+ const useVisitService = () => {
53
+ return visitFunction;
54
+ };
52
55
  const useVisitMethod = (functionName) => {
53
56
  return react_1.default.useMemo(() => visitFunction[functionName], [functionName]);
54
57
  };
@@ -102,6 +105,7 @@ const actorHooks = (actorManager) => {
102
105
  useUpdateCall,
103
106
  useActorState,
104
107
  useVisitMethod,
108
+ useVisitService,
105
109
  };
106
110
  };
107
111
  exports.actorHooks = actorHooks;
@@ -43,11 +43,13 @@ function extractActorContext(actorContext) {
43
43
  const useQueryCall = (args) => useActorContext().useQueryCall(args);
44
44
  const useUpdateCall = (args) => useActorContext().useUpdateCall(args);
45
45
  const useVisitMethod = (functionName) => useActorContext().useVisitMethod(functionName);
46
+ const useVisitService = () => useActorContext().useVisitService();
46
47
  return {
47
48
  useActorState,
48
49
  useQueryCall,
49
50
  useUpdateCall,
50
51
  useVisitMethod,
52
+ useVisitService,
51
53
  initialize,
52
54
  };
53
55
  }
@@ -67,10 +67,12 @@ export type UseMethodCall<A> = <M extends FunctionName<A>>(args: UseMethodCallPa
67
67
  export type UseQueryCall<A> = <M extends FunctionName<A>>(args: UseQueryCallParameters<A, M>) => UseMethodCallReturnType<A, M>;
68
68
  export type UseUpdateCall<A> = <M extends FunctionName<A>>(args: UseUpdateCallParameters<A, M>) => UseMethodCallReturnType<A, M>;
69
69
  export type UseVisitMethod<A> = <M extends FunctionName<A>>(functionName: M) => VisitService<A>[M];
70
+ export type UseVisitService<A> = () => VisitService<A>;
70
71
  export interface ActorHooksReturnType<A = BaseActor> {
71
72
  initialize: () => Promise<void>;
72
73
  useActorState: () => UseActorState;
73
74
  useQueryCall: UseQueryCall<A>;
74
75
  useUpdateCall: UseUpdateCall<A>;
75
76
  useVisitMethod: UseVisitMethod<A>;
77
+ useVisitService: UseVisitService<A>;
76
78
  }
@@ -2,3 +2,4 @@ export * from "./useActorState";
2
2
  export * from "./useQueryCall";
3
3
  export * from "./useUpdateCall";
4
4
  export * from "./useVisitMethod";
5
+ export * from "./useVisitService";
@@ -18,3 +18,4 @@ __exportStar(require("./useActorState"), exports);
18
18
  __exportStar(require("./useQueryCall"), exports);
19
19
  __exportStar(require("./useUpdateCall"), exports);
20
20
  __exportStar(require("./useVisitMethod"), exports);
21
+ __exportStar(require("./useVisitService"), exports);
@@ -0,0 +1,8 @@
1
+ import { BaseActor } from "../../types";
2
+ /**
3
+ * Memoizes and returns a visit service function for a specific actor method.
4
+ *
5
+ * @param functionName The name of the actor method to visit.
6
+ * @returns The visit service function for the specified method.
7
+ */
8
+ export declare function useVisitService<A = BaseActor>(): import("@ic-reactor/core/dist/classes/actor/types").VisitService<A>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useVisitService = void 0;
4
+ const hooks_1 = require("./hooks");
5
+ /**
6
+ * Memoizes and returns a visit service function for a specific actor method.
7
+ *
8
+ * @param functionName The name of the actor method to visit.
9
+ * @returns The visit service function for the specified method.
10
+ */
11
+ function useVisitService() {
12
+ return hooks_1.ActorHooks.useVisitService();
13
+ }
14
+ exports.useVisitService = useVisitService;
package/dist/index.d.ts CHANGED
@@ -7,4 +7,4 @@ export * from "./hooks";
7
7
  export * as helpers from "./helpers";
8
8
  export * as types from "./types";
9
9
  export * as core from "./core";
10
- export * as utils from "@ic-reactor/core/dist/utils";
10
+ export * as utils from "./utils";
package/dist/index.js CHANGED
@@ -36,4 +36,4 @@ __exportStar(require("./hooks"), exports);
36
36
  exports.helpers = __importStar(require("./helpers"));
37
37
  exports.types = __importStar(require("./types"));
38
38
  exports.core = __importStar(require("./core"));
39
- exports.utils = __importStar(require("@ic-reactor/core/dist/utils"));
39
+ exports.utils = __importStar(require("./utils"));
@@ -0,0 +1 @@
1
+ export * from "@ic-reactor/core/dist/utils";
package/dist/utils.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@ic-reactor/core/dist/utils"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/react",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "A React library for interacting with Internet Computer canisters",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "react": ">=16.8",
48
48
  "zustand": "4.5"
49
49
  },
50
- "gitHead": "5420fba37e2721dd9c4a41ba885151eb420c5332"
50
+ "gitHead": "0055703885730f86a837f2e2f3f6b6f49bb3cc68"
51
51
  }