@ic-reactor/react 2.0.1 → 3.0.0-beta.2

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.
Files changed (155) hide show
  1. package/README.md +283 -87
  2. package/dist/createActorHooks.d.ts +39 -0
  3. package/dist/createActorHooks.d.ts.map +1 -0
  4. package/dist/createActorHooks.js +30 -0
  5. package/dist/createActorHooks.js.map +1 -0
  6. package/dist/createAuthHooks.d.ts +37 -0
  7. package/dist/createAuthHooks.d.ts.map +1 -0
  8. package/dist/createAuthHooks.js +94 -0
  9. package/dist/createAuthHooks.js.map +1 -0
  10. package/dist/createInfiniteQuery.d.ts +129 -0
  11. package/dist/createInfiniteQuery.d.ts.map +1 -0
  12. package/dist/createInfiniteQuery.js +160 -0
  13. package/dist/createInfiniteQuery.js.map +1 -0
  14. package/dist/createMutation.d.ts +19 -0
  15. package/dist/createMutation.d.ts.map +1 -0
  16. package/dist/createMutation.js +98 -0
  17. package/dist/createMutation.js.map +1 -0
  18. package/dist/createQuery.d.ts +20 -0
  19. package/dist/createQuery.d.ts.map +1 -0
  20. package/dist/createQuery.js +111 -0
  21. package/dist/createQuery.js.map +1 -0
  22. package/dist/createSuspenseInfiniteQuery.d.ts +122 -0
  23. package/dist/createSuspenseInfiniteQuery.d.ts.map +1 -0
  24. package/dist/createSuspenseInfiniteQuery.js +160 -0
  25. package/dist/createSuspenseInfiniteQuery.js.map +1 -0
  26. package/dist/createSuspenseQuery.d.ts +25 -0
  27. package/dist/createSuspenseQuery.d.ts.map +1 -0
  28. package/dist/createSuspenseQuery.js +116 -0
  29. package/dist/createSuspenseQuery.js.map +1 -0
  30. package/dist/hooks/index.d.ts +6 -2
  31. package/dist/hooks/index.d.ts.map +1 -0
  32. package/dist/hooks/index.js +6 -18
  33. package/dist/hooks/index.js.map +1 -0
  34. package/dist/hooks/useActorInfiniteQuery.d.ts +37 -0
  35. package/dist/hooks/useActorInfiniteQuery.d.ts.map +1 -0
  36. package/dist/hooks/useActorInfiniteQuery.js +33 -0
  37. package/dist/hooks/useActorInfiniteQuery.js.map +1 -0
  38. package/dist/hooks/useActorMutation.d.ts +23 -0
  39. package/dist/hooks/useActorMutation.d.ts.map +1 -0
  40. package/dist/hooks/useActorMutation.js +39 -0
  41. package/dist/hooks/useActorMutation.js.map +1 -0
  42. package/dist/hooks/useActorQuery.d.ts +32 -0
  43. package/dist/hooks/useActorQuery.d.ts.map +1 -0
  44. package/dist/hooks/useActorQuery.js +35 -0
  45. package/dist/hooks/useActorQuery.js.map +1 -0
  46. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +36 -0
  47. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +1 -0
  48. package/dist/hooks/useActorSuspenseInfiniteQuery.js +33 -0
  49. package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +1 -0
  50. package/dist/hooks/useActorSuspenseQuery.d.ts +32 -0
  51. package/dist/hooks/useActorSuspenseQuery.d.ts.map +1 -0
  52. package/dist/hooks/useActorSuspenseQuery.js +36 -0
  53. package/dist/hooks/useActorSuspenseQuery.js.map +1 -0
  54. package/dist/index.d.ts +11 -8
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +17 -49
  57. package/dist/index.js.map +1 -0
  58. package/dist/types.d.ts +232 -13
  59. package/dist/types.d.ts.map +1 -0
  60. package/dist/types.js +5 -22
  61. package/dist/types.js.map +1 -0
  62. package/dist/validation.d.ts +131 -0
  63. package/dist/validation.d.ts.map +1 -0
  64. package/dist/validation.js +125 -0
  65. package/dist/validation.js.map +1 -0
  66. package/package.json +70 -35
  67. package/LICENSE.md +0 -8
  68. package/dist/context/actor/create.d.ts +0 -63
  69. package/dist/context/actor/create.js +0 -119
  70. package/dist/context/actor/hooks/useActorInterface.d.ts +0 -4
  71. package/dist/context/actor/hooks/useActorInterface.js +0 -10
  72. package/dist/context/actor/hooks/useActorState.d.ts +0 -21
  73. package/dist/context/actor/hooks/useActorState.js +0 -25
  74. package/dist/context/actor/hooks/useActorStore.d.ts +0 -32
  75. package/dist/context/actor/hooks/useActorStore.js +0 -36
  76. package/dist/context/actor/hooks/useInitializeActor.d.ts +0 -6
  77. package/dist/context/actor/hooks/useInitializeActor.js +0 -10
  78. package/dist/context/actor/hooks/useMethod.d.ts +0 -29
  79. package/dist/context/actor/hooks/useMethod.js +0 -34
  80. package/dist/context/actor/hooks/useMethodAttributes.d.ts +0 -7
  81. package/dist/context/actor/hooks/useMethodAttributes.js +0 -11
  82. package/dist/context/actor/hooks/useMethodNames.d.ts +0 -7
  83. package/dist/context/actor/hooks/useMethodNames.js +0 -11
  84. package/dist/context/actor/hooks/useQueryCall.d.ts +0 -28
  85. package/dist/context/actor/hooks/useQueryCall.js +0 -33
  86. package/dist/context/actor/hooks/useUpdateCall.d.ts +0 -29
  87. package/dist/context/actor/hooks/useUpdateCall.js +0 -34
  88. package/dist/context/actor/hooks/useVisitMethod.d.ts +0 -8
  89. package/dist/context/actor/hooks/useVisitMethod.js +0 -13
  90. package/dist/context/actor/hooks/useVisitService.d.ts +0 -8
  91. package/dist/context/actor/hooks/useVisitService.js +0 -13
  92. package/dist/context/actor/index.d.ts +0 -16
  93. package/dist/context/actor/index.js +0 -33
  94. package/dist/context/actor/provider.d.ts +0 -71
  95. package/dist/context/actor/provider.js +0 -75
  96. package/dist/context/actor/types.d.ts +0 -35
  97. package/dist/context/actor/types.js +0 -2
  98. package/dist/context/adapter/create.d.ts +0 -2
  99. package/dist/context/adapter/create.js +0 -102
  100. package/dist/context/adapter/hooks/useCandidAdapter.d.ts +0 -23
  101. package/dist/context/adapter/hooks/useCandidAdapter.js +0 -27
  102. package/dist/context/adapter/hooks/useCandidEvaluation.d.ts +0 -5
  103. package/dist/context/adapter/hooks/useCandidEvaluation.js +0 -9
  104. package/dist/context/adapter/index.d.ts +0 -6
  105. package/dist/context/adapter/index.js +0 -24
  106. package/dist/context/adapter/provider.d.ts +0 -23
  107. package/dist/context/adapter/provider.js +0 -27
  108. package/dist/context/adapter/types.d.ts +0 -52
  109. package/dist/context/adapter/types.js +0 -2
  110. package/dist/context/agent/create.d.ts +0 -74
  111. package/dist/context/agent/create.js +0 -104
  112. package/dist/context/agent/hooks/useAgent.d.ts +0 -14
  113. package/dist/context/agent/hooks/useAgent.js +0 -18
  114. package/dist/context/agent/hooks/useAgentManager.d.ts +0 -14
  115. package/dist/context/agent/hooks/useAgentManager.js +0 -18
  116. package/dist/context/agent/hooks/useAgentState.d.ts +0 -21
  117. package/dist/context/agent/hooks/useAgentState.js +0 -25
  118. package/dist/context/agent/hooks/useAuth.d.ts +0 -57
  119. package/dist/context/agent/hooks/useAuth.js +0 -61
  120. package/dist/context/agent/hooks/useAuthState.d.ts +0 -19
  121. package/dist/context/agent/hooks/useAuthState.js +0 -23
  122. package/dist/context/agent/hooks/useUserPrincipal.d.ts +0 -17
  123. package/dist/context/agent/hooks/useUserPrincipal.js +0 -21
  124. package/dist/context/agent/index.d.ts +0 -12
  125. package/dist/context/agent/index.js +0 -29
  126. package/dist/context/agent/provider.d.ts +0 -28
  127. package/dist/context/agent/provider.js +0 -32
  128. package/dist/context/agent/types.d.ts +0 -17
  129. package/dist/context/agent/types.js +0 -2
  130. package/dist/core.d.ts +0 -1
  131. package/dist/core.js +0 -9
  132. package/dist/createReactor.d.ts +0 -49
  133. package/dist/createReactor.js +0 -69
  134. package/dist/helpers/actorHooks.d.ts +0 -18
  135. package/dist/helpers/actorHooks.js +0 -283
  136. package/dist/helpers/agentHooks.d.ts +0 -3
  137. package/dist/helpers/agentHooks.js +0 -22
  138. package/dist/helpers/authHooks.d.ts +0 -2
  139. package/dist/helpers/authHooks.js +0 -120
  140. package/dist/helpers/extractActorContext.d.ts +0 -4
  141. package/dist/helpers/extractActorContext.js +0 -44
  142. package/dist/helpers/extractAgentContext.d.ts +0 -28
  143. package/dist/helpers/extractAgentContext.js +0 -59
  144. package/dist/helpers/index.d.ts +0 -5
  145. package/dist/helpers/index.js +0 -21
  146. package/dist/helpers/types.d.ts +0 -222
  147. package/dist/helpers/types.js +0 -2
  148. package/dist/hooks/types.d.ts +0 -22
  149. package/dist/hooks/types.js +0 -2
  150. package/dist/hooks/useActor.d.ts +0 -67
  151. package/dist/hooks/useActor.js +0 -197
  152. package/dist/hooks/useActorManager.d.ts +0 -68
  153. package/dist/hooks/useActorManager.js +0 -75
  154. package/dist/utils.d.ts +0 -1
  155. package/dist/utils.js +0 -17
@@ -1,21 +0,0 @@
1
- /**
2
- * Hook for accessing the current state of the actor, including the canister ID.
3
- *
4
- * @returns An object containing the current state of the actor from Zustand's store and the canister ID.
5
- * @example
6
- * ```tsx
7
- * function ActorStateComponent() {
8
- * const { canisterId, initializing, error, initialized } = useActorState();
9
- *
10
- * return (
11
- * <div>
12
- * <p>Canister ID: {canisterId}</p>
13
- * <p>Initializing: {initializing.toString()}</p>
14
- * <p>Initialized: {initialized.toString()}</p>
15
- * <p>Error: {error?.message}</p>
16
- * </div>
17
- * );
18
- * }
19
- *```
20
- */
21
- export declare const useActorState: () => import("../../../types").UseActorStateReturnType;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useActorState = void 0;
4
- const __1 = require("..");
5
- /**
6
- * Hook for accessing the current state of the actor, including the canister ID.
7
- *
8
- * @returns An object containing the current state of the actor from Zustand's store and the canister ID.
9
- * @example
10
- * ```tsx
11
- * function ActorStateComponent() {
12
- * const { canisterId, initializing, error, initialized } = useActorState();
13
- *
14
- * return (
15
- * <div>
16
- * <p>Canister ID: {canisterId}</p>
17
- * <p>Initializing: {initializing.toString()}</p>
18
- * <p>Initialized: {initialized.toString()}</p>
19
- * <p>Error: {error?.message}</p>
20
- * </div>
21
- * );
22
- * }
23
- *```
24
- */
25
- exports.useActorState = __1.ActorHooks.useActorState;
@@ -1,32 +0,0 @@
1
- /**
2
- * Provides a hook for accessing the state of an actor from the actor's store.
3
- * This hook is part of a set of utilities that facilitate interactions with
4
- * Internet Computer (IC) canisters by abstracting the complexities associated
5
- * with actor management and state retrieval.
6
- *
7
- * The `useActorStore` hook allows components to subscribe to and retrieve state
8
- * from the actor store in a reactive way. This enables components to re-render
9
- * when specific parts of the actor state change, which is managed by a selector function.
10
- *
11
- * @template A The type of the actor, extending from a base actor structure.
12
- * @template T The type of the data selected from the actor's state.
13
- * @param {Function} [selector=(s: ActorState<A>) => s as T] A function that
14
- * selects a part of the actor state. This function should accept the actor state
15
- * and return a portion of the state. If no selector is provided, the entire
16
- * state is returned.
17
- *
18
- * @returns {T} The selected state from the actor store. The nature of the returned
19
- * state depends on the selector function provided.
20
- *
21
- * @example
22
- * ```tsx
23
- * // Assuming a 'LedgerActor' has been setup and used to manage the actor store
24
- * const name = useActorStore(state => state.name);
25
- *
26
- * return <div>Canister Name: {name}</div>;
27
- * ```
28
- *
29
- * @see ActorManager for more details about the architecture and management of actor stores.
30
- * @see ActorState for the structure and possible states an actor can hold.
31
- */
32
- export declare const useActorStore: import("../../../types").UseActorStore<import("@ic-reactor/core/dist/types").BaseActor>;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useActorStore = void 0;
4
- const __1 = require("..");
5
- /**
6
- * Provides a hook for accessing the state of an actor from the actor's store.
7
- * This hook is part of a set of utilities that facilitate interactions with
8
- * Internet Computer (IC) canisters by abstracting the complexities associated
9
- * with actor management and state retrieval.
10
- *
11
- * The `useActorStore` hook allows components to subscribe to and retrieve state
12
- * from the actor store in a reactive way. This enables components to re-render
13
- * when specific parts of the actor state change, which is managed by a selector function.
14
- *
15
- * @template A The type of the actor, extending from a base actor structure.
16
- * @template T The type of the data selected from the actor's state.
17
- * @param {Function} [selector=(s: ActorState<A>) => s as T] A function that
18
- * selects a part of the actor state. This function should accept the actor state
19
- * and return a portion of the state. If no selector is provided, the entire
20
- * state is returned.
21
- *
22
- * @returns {T} The selected state from the actor store. The nature of the returned
23
- * state depends on the selector function provided.
24
- *
25
- * @example
26
- * ```tsx
27
- * // Assuming a 'LedgerActor' has been setup and used to manage the actor store
28
- * const name = useActorStore(state => state.name);
29
- *
30
- * return <div>Canister Name: {name}</div>;
31
- * ```
32
- *
33
- * @see ActorManager for more details about the architecture and management of actor stores.
34
- * @see ActorState for the structure and possible states an actor can hold.
35
- */
36
- exports.useActorStore = __1.ActorHooks.useActorStore;
@@ -1,6 +0,0 @@
1
- /**
2
- * Initializes an actor with the provided IDL factory and optional actor configuration.
3
- * This hook is used when the actor is not initialized by the `ActorProvider` component,
4
- * or when the actor needs to be initialized in a specific way.
5
- */
6
- export declare const useInitializeActor: () => import("../../../types").InitializeActor;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useInitializeActor = void 0;
4
- const __1 = require("..");
5
- /**
6
- * Initializes an actor with the provided IDL factory and optional actor configuration.
7
- * This hook is used when the actor is not initialized by the `ActorProvider` component,
8
- * or when the actor needs to be initialized in a specific way.
9
- */
10
- exports.useInitializeActor = __1.ActorHooks.useInitializeActor;
@@ -1,29 +0,0 @@
1
- import type { BaseActor, FunctionName, UseMethodParameters, UseMethodReturnType } from "../../../types";
2
- /**
3
- * Hook for making dynamically update or query calls to actors, handling loading states, and managing errors. It supports custom event handlers for loading, success, and error events.
4
- *
5
- * @param args {@link UseMethodParameters}.
6
- * @returns object {@link UseMethodReturnType}.
7
- * @example
8
- * ```tsx
9
- * function MethodCallComponent() {
10
- * const { call, data, isLoading } = useMethod({
11
- * functionName: 'updateUserProfile',
12
- * args: ['123', { name: 'John Doe' }],
13
- * onLoading: (isLoading) => console.log('Loading:', isLoading),
14
- * onError: (error) => console.error('Error:', error),
15
- * onSuccess: (data) => console.log('Success:', data),
16
- * });
17
- *
18
- * if (isLoading) return <p>Updating profile...</p>;
19
- *
20
- * return (
21
- * <div>
22
- * <p>Updated Profile: {JSON.stringify(data)}</p>
23
- * <button onClick={call}>Update</button>
24
- * </div>
25
- * );
26
- * }
27
- * ```
28
- */
29
- export declare function useMethod<A = BaseActor, M extends FunctionName<A> = FunctionName<A>>(args: UseMethodParameters<A, M>): UseMethodReturnType<A, M>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMethod = useMethod;
4
- const __1 = require("..");
5
- /**
6
- * Hook for making dynamically update or query calls to actors, handling loading states, and managing errors. It supports custom event handlers for loading, success, and error events.
7
- *
8
- * @param args {@link UseMethodParameters}.
9
- * @returns object {@link UseMethodReturnType}.
10
- * @example
11
- * ```tsx
12
- * function MethodCallComponent() {
13
- * const { call, data, isLoading } = useMethod({
14
- * functionName: 'updateUserProfile',
15
- * args: ['123', { name: 'John Doe' }],
16
- * onLoading: (isLoading) => console.log('Loading:', isLoading),
17
- * onError: (error) => console.error('Error:', error),
18
- * onSuccess: (data) => console.log('Success:', data),
19
- * });
20
- *
21
- * if (isLoading) return <p>Updating profile...</p>;
22
- *
23
- * return (
24
- * <div>
25
- * <p>Updated Profile: {JSON.stringify(data)}</p>
26
- * <button onClick={call}>Update</button>
27
- * </div>
28
- * );
29
- * }
30
- * ```
31
- */
32
- function useMethod(args) {
33
- return __1.ActorHooks.useMethod(args);
34
- }
@@ -1,7 +0,0 @@
1
- import type { BaseActor } from "../../../types";
2
- /**
3
- * Hook for accessing the method attributes of an actor.
4
- *
5
- * @returns An array of method attributes for the actor.
6
- */
7
- export declare const useMethodAttributes: <A = BaseActor>() => import("@ic-reactor/core/dist/classes/actor/types").MethodAttributes<A>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMethodAttributes = void 0;
4
- const __1 = require("..");
5
- /**
6
- * Hook for accessing the method attributes of an actor.
7
- *
8
- * @returns An array of method attributes for the actor.
9
- */
10
- const useMethodAttributes = () => __1.ActorHooks.useMethodAttributes();
11
- exports.useMethodAttributes = useMethodAttributes;
@@ -1,7 +0,0 @@
1
- import type { BaseActor } from "../../../types";
2
- /**
3
- * Hook for accessing the method names of an actor.
4
- *
5
- * @returns An array of method names for the actor.
6
- */
7
- export declare const useMethodNames: <A = BaseActor>() => Extract<keyof A, string>[];
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMethodNames = void 0;
4
- const __1 = require("..");
5
- /**
6
- * Hook for accessing the method names of an actor.
7
- *
8
- * @returns An array of method names for the actor.
9
- */
10
- const useMethodNames = () => __1.ActorHooks.useMethodNames();
11
- exports.useMethodNames = useMethodNames;
@@ -1,28 +0,0 @@
1
- import type { BaseActor, FunctionName, UseQueryCallParameters, UseQueryCallReturnType } from "../../../types";
2
- /**
3
- * Hook for making query calls to actors. It supports automatic refetching on component mount and at specified intervals.
4
- *
5
- * @param args {@link UseQueryCallParameters}.
6
- * @returns object {@link UseQueryCallReturnType}.
7
- * @example
8
- * ```tsx
9
- * function QueryCallComponent() {
10
- * const { call, data, isLoading } = useQueryCall({
11
- * functionName: 'getUserProfile',
12
- * args: ['123'],
13
- * refetchOnMount: true,
14
- * refetchInterval: 5000, // refetch every 5 seconds
15
- * });
16
- *
17
- * if (isLoading) return <p>isLoading profile...</p>;
18
- *
19
- * return (
20
- * <div>
21
- * <p>User Profile: {JSON.stringify(data)}</p>
22
- * <button onClick={call}>Refetch</button>
23
- * </div>
24
- * );
25
- * }
26
- * ```
27
- */
28
- export declare function useQueryCall<A = BaseActor, M extends FunctionName<A> = FunctionName<A>>(args: UseQueryCallParameters<A, M>): UseQueryCallReturnType<A, M>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useQueryCall = useQueryCall;
4
- const __1 = require("..");
5
- /**
6
- * Hook for making query calls to actors. It supports automatic refetching on component mount and at specified intervals.
7
- *
8
- * @param args {@link UseQueryCallParameters}.
9
- * @returns object {@link UseQueryCallReturnType}.
10
- * @example
11
- * ```tsx
12
- * function QueryCallComponent() {
13
- * const { call, data, isLoading } = useQueryCall({
14
- * functionName: 'getUserProfile',
15
- * args: ['123'],
16
- * refetchOnMount: true,
17
- * refetchInterval: 5000, // refetch every 5 seconds
18
- * });
19
- *
20
- * if (isLoading) return <p>isLoading profile...</p>;
21
- *
22
- * return (
23
- * <div>
24
- * <p>User Profile: {JSON.stringify(data)}</p>
25
- * <button onClick={call}>Refetch</button>
26
- * </div>
27
- * );
28
- * }
29
- * ```
30
- */
31
- function useQueryCall(args) {
32
- return __1.ActorHooks.useQueryCall(args);
33
- }
@@ -1,29 +0,0 @@
1
- import type { BaseActor, FunctionName, UseUpdateCallParameters, UseUpdateCallReturnType } from "../../../types";
2
- /**
3
- * Hook for making update calls to actors, handling loading states, and managing errors. It supports custom event handlers for loading, success, and error events.
4
- *
5
- * @param args {@link UseUpdateCallParameters}.
6
- * @returns object {@link UseUpdateCallReturnType}.
7
- * @example
8
- * ```tsx
9
- * function UpdateCallComponent() {
10
- * const { call, data, isLoading } = useUpdateCall({
11
- * functionName: 'updateUserProfile',
12
- * args: ['123', { name: 'John Doe' }],
13
- * onLoading: (isLoading) => console.log('Loading:', isLoading),
14
- * onError: (error) => console.error('Error:', error),
15
- * onSuccess: (data) => console.log('Success:', data),
16
- * });
17
- *
18
- * if (isLoading) return <p>Updating profile...</p>;
19
- *
20
- * return (
21
- * <div>
22
- * <p>Updated Profile: {JSON.stringify(data)}</p>
23
- * <button onClick={call}>Update</button>
24
- * </div>
25
- * );
26
- * }
27
- * ```
28
- */
29
- export declare function useUpdateCall<A = BaseActor, M extends FunctionName<A> = FunctionName<A>>(args: UseUpdateCallParameters<A, M>): UseUpdateCallReturnType<A, M>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useUpdateCall = useUpdateCall;
4
- const __1 = require("..");
5
- /**
6
- * Hook for making update calls to actors, handling loading states, and managing errors. It supports custom event handlers for loading, success, and error events.
7
- *
8
- * @param args {@link UseUpdateCallParameters}.
9
- * @returns object {@link UseUpdateCallReturnType}.
10
- * @example
11
- * ```tsx
12
- * function UpdateCallComponent() {
13
- * const { call, data, isLoading } = useUpdateCall({
14
- * functionName: 'updateUserProfile',
15
- * args: ['123', { name: 'John Doe' }],
16
- * onLoading: (isLoading) => console.log('Loading:', isLoading),
17
- * onError: (error) => console.error('Error:', error),
18
- * onSuccess: (data) => console.log('Success:', data),
19
- * });
20
- *
21
- * if (isLoading) return <p>Updating profile...</p>;
22
- *
23
- * return (
24
- * <div>
25
- * <p>Updated Profile: {JSON.stringify(data)}</p>
26
- * <button onClick={call}>Update</button>
27
- * </div>
28
- * );
29
- * }
30
- * ```
31
- */
32
- function useUpdateCall(args) {
33
- return __1.ActorHooks.useUpdateCall(args);
34
- }
@@ -1,8 +0,0 @@
1
- import type { FunctionName, 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 useVisitMethod<A = BaseActor>(functionName: FunctionName<A>): <V extends import("@dfinity/candid/lib/esm/idl").Visitor<unknown, unknown>>(extractorClass: V, data: import("@ic-reactor/core/dist/classes/actor/types").VisitorType<V>["data"]) => ReturnType<V["visitFunc"]>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useVisitMethod = useVisitMethod;
4
- const __1 = require("..");
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 useVisitMethod(functionName) {
12
- return __1.ActorHooks.useVisitMethod(functionName);
13
- }
@@ -1,8 +0,0 @@
1
- import type { 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>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useVisitService = useVisitService;
4
- const __1 = require("..");
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 __1.ActorHooks.useVisitService();
13
- }
@@ -1,16 +0,0 @@
1
- import { createActorContext } from "./create";
2
- export { createActorContext };
3
- /** @ignore */
4
- export declare const ActorHooks: import("./types").CreateActorContextReturnType<import("@ic-reactor/core/dist/types").BaseActor>;
5
- export * from "./provider";
6
- export * from "./hooks/useMethodNames";
7
- export * from "./hooks/useQueryCall";
8
- export * from "./hooks/useUpdateCall";
9
- export * from "./hooks/useMethodAttributes";
10
- export * from "./hooks/useActorStore";
11
- export * from "./hooks/useActorState";
12
- export * from "./hooks/useVisitMethod";
13
- export * from "./hooks/useVisitService";
14
- export * from "./hooks/useActorInterface";
15
- export * from "./hooks/useInitializeActor";
16
- export * from "./hooks/useMethod";
@@ -1,33 +0,0 @@
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
- exports.ActorHooks = exports.createActorContext = void 0;
18
- const create_1 = require("./create");
19
- Object.defineProperty(exports, "createActorContext", { enumerable: true, get: function () { return create_1.createActorContext; } });
20
- /** @ignore */
21
- exports.ActorHooks = (0, create_1.createActorContext)();
22
- __exportStar(require("./provider"), exports);
23
- __exportStar(require("./hooks/useMethodNames"), exports);
24
- __exportStar(require("./hooks/useQueryCall"), exports);
25
- __exportStar(require("./hooks/useUpdateCall"), exports);
26
- __exportStar(require("./hooks/useMethodAttributes"), exports);
27
- __exportStar(require("./hooks/useActorStore"), exports);
28
- __exportStar(require("./hooks/useActorState"), exports);
29
- __exportStar(require("./hooks/useVisitMethod"), exports);
30
- __exportStar(require("./hooks/useVisitService"), exports);
31
- __exportStar(require("./hooks/useActorInterface"), exports);
32
- __exportStar(require("./hooks/useInitializeActor"), exports);
33
- __exportStar(require("./hooks/useMethod"), exports);
@@ -1,71 +0,0 @@
1
- /**
2
- * `ActorProvider` is a React functional component that serves as a context provider for IC actor interactions within a React application.
3
- * It wraps child components, providing them access to actor-specific hooks and functionalities based on the provided canister ID and configuration.
4
- *
5
- * Props:
6
- * - `canisterId` (optional): string - The Canister ID for actor interactions. If not provided, the default from `createActorContext` is used.
7
- * - `idlFactory` (optional): IDL.InterfaceFactory - The IDL factory for the actor interface. If not provided, the default from `createActorContext` is used.
8
- * - `didjsId` (optional): string - The DID.js ID for authentication. If not provided, the default from `createActorContext` is used.
9
- * - `loadingComponent` (optional): React Node - A component displayed during the loading/fetching state. Defaults to a simple message.
10
- * - `authenticatingComponent` (optional): React Node - A component displayed during the authentication state. Defaults to a simple message.
11
- * - `children`: React Node - The child components that will have access to the actor context.
12
- *
13
- * Behavior:
14
- * - Validates the presence of a `canisterId`. Throws an error if it is missing, ensuring that a valid canister ID is always used for actor operations.
15
- * - Utilizes `useMemo` to combine the default configuration with the props provided to the `ActorProvider`, optimizing for performance by avoiding unnecessary recalculations.
16
- * - Employs the `useActor` hook to initiate actor interactions based on the combined configuration, managing states such as `fetching`, `fetchError`, and the actor `hooks`.
17
- * - Conditionally renders the `loadingComponent` or `fetchError` based on the actor fetching state. Once the actor is ready and no errors are present, it renders the child components, effectively providing them access to the actor context.
18
- *
19
- * @example
20
- * ```jsx
21
- * <ActorProvider canisterId="your-canister-id" idlFactory={yourIdlFactory}>
22
- * <YourComponent />
23
- * </ActorProvider>
24
- * ```
25
- * This setup ensures that `YourComponent` and any of its children can interact with the specified IC actor through the context provided by `ActorProvider`.
26
- */
27
- export declare const ActorProvider: import("react").FC<import("./types").ActorProviderProps>;
28
- /**
29
- * `ActorHookProvider` is a React functional component that serves as a context provider for IC actor hooks within a React application.
30
- * It wraps child components, providing them access to actor-specific hooks and functionalities based on the provided actor hooks and configuration.
31
- *
32
- * Props:
33
- * - `hooks`: ActorHooksReturnType - The actor hooks object containing the various actor interaction hooks.
34
- * - `children`: React Node - The child components that will have access to the actor hooks context.
35
- *
36
- * Behavior:
37
- * - Validates the presence of the `hooks` object. Throws an error if it is missing, ensuring that the actor hooks are always available for actor operations.
38
- * - Utilizes `useMemo` to memoize the `hooks` object, optimizing for performance by avoiding unnecessary recalculations.
39
- * - Renders the child components once the `hooks` object is available, effectively providing them access to the actor hooks context.
40
- *
41
- * @example
42
- * ```jsx
43
- * <ActorHookProvider hooks={yourActorHooks}>
44
- * <YourComponent />
45
- * </ActorHookProvider>
46
- * ```
47
- * This setup ensures that `YourComponent` and any of its children can interact with the specified IC actor hooks through the context provided by `ActorHookProvider`.
48
- */
49
- export declare const ActorHookProvider: import("react").FC<import("./types").ActorHookProviderProps<import("@ic-reactor/core/dist/types").BaseActor>>;
50
- /**
51
- * `ActorManagerProvider` is a React functional component that serves as a context provider for IC actor managers within a React application.
52
- * It wraps child components, providing them access to actor-specific manager functionalities based on the provided actor manager and configuration.
53
- *
54
- * Props:
55
- * - `actorManager`: ActorManager - The actor manager object containing the actor manager functionalities.
56
- * - `children`: React Node - The child components that will have access to the actor manager context.
57
- *
58
- * Behavior:
59
- * - Validates the presence of the `actorManager`. Throws an error if it is missing, ensuring that the actor manager is always available for actor operations.
60
- * - Utilizes `useMemo` to memoize the `actorManager`, optimizing for performance by avoiding unnecessary recalculations.
61
- * - Renders the child components once the `actorManager` is available, effectively providing them access to the actor manager context.
62
- *
63
- * @example
64
- * ```jsx
65
- * <ActorManagerProvider actorManager={yourActorManager}>
66
- * <YourComponent />
67
- * </ActorManagerProvider>
68
- * ```
69
- * This setup ensures that `YourComponent` and any of its children can interact with the specified IC actor manager through the context provided by `ActorManagerProvider`.
70
- */
71
- export declare const ActorManagerProvider: import("react").FC<import("./types").ActorManagerProviderProps<import("@ic-reactor/core/dist/types").BaseActor>>;
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ActorManagerProvider = exports.ActorHookProvider = exports.ActorProvider = void 0;
4
- const _1 = require(".");
5
- /**
6
- * `ActorProvider` is a React functional component that serves as a context provider for IC actor interactions within a React application.
7
- * It wraps child components, providing them access to actor-specific hooks and functionalities based on the provided canister ID and configuration.
8
- *
9
- * Props:
10
- * - `canisterId` (optional): string - The Canister ID for actor interactions. If not provided, the default from `createActorContext` is used.
11
- * - `idlFactory` (optional): IDL.InterfaceFactory - The IDL factory for the actor interface. If not provided, the default from `createActorContext` is used.
12
- * - `didjsId` (optional): string - The DID.js ID for authentication. If not provided, the default from `createActorContext` is used.
13
- * - `loadingComponent` (optional): React Node - A component displayed during the loading/fetching state. Defaults to a simple message.
14
- * - `authenticatingComponent` (optional): React Node - A component displayed during the authentication state. Defaults to a simple message.
15
- * - `children`: React Node - The child components that will have access to the actor context.
16
- *
17
- * Behavior:
18
- * - Validates the presence of a `canisterId`. Throws an error if it is missing, ensuring that a valid canister ID is always used for actor operations.
19
- * - Utilizes `useMemo` to combine the default configuration with the props provided to the `ActorProvider`, optimizing for performance by avoiding unnecessary recalculations.
20
- * - Employs the `useActor` hook to initiate actor interactions based on the combined configuration, managing states such as `fetching`, `fetchError`, and the actor `hooks`.
21
- * - Conditionally renders the `loadingComponent` or `fetchError` based on the actor fetching state. Once the actor is ready and no errors are present, it renders the child components, effectively providing them access to the actor context.
22
- *
23
- * @example
24
- * ```jsx
25
- * <ActorProvider canisterId="your-canister-id" idlFactory={yourIdlFactory}>
26
- * <YourComponent />
27
- * </ActorProvider>
28
- * ```
29
- * This setup ensures that `YourComponent` and any of its children can interact with the specified IC actor through the context provided by `ActorProvider`.
30
- */
31
- exports.ActorProvider = _1.ActorHooks.ActorProvider;
32
- /**
33
- * `ActorHookProvider` is a React functional component that serves as a context provider for IC actor hooks within a React application.
34
- * It wraps child components, providing them access to actor-specific hooks and functionalities based on the provided actor hooks and configuration.
35
- *
36
- * Props:
37
- * - `hooks`: ActorHooksReturnType - The actor hooks object containing the various actor interaction hooks.
38
- * - `children`: React Node - The child components that will have access to the actor hooks context.
39
- *
40
- * Behavior:
41
- * - Validates the presence of the `hooks` object. Throws an error if it is missing, ensuring that the actor hooks are always available for actor operations.
42
- * - Utilizes `useMemo` to memoize the `hooks` object, optimizing for performance by avoiding unnecessary recalculations.
43
- * - Renders the child components once the `hooks` object is available, effectively providing them access to the actor hooks context.
44
- *
45
- * @example
46
- * ```jsx
47
- * <ActorHookProvider hooks={yourActorHooks}>
48
- * <YourComponent />
49
- * </ActorHookProvider>
50
- * ```
51
- * This setup ensures that `YourComponent` and any of its children can interact with the specified IC actor hooks through the context provided by `ActorHookProvider`.
52
- */
53
- exports.ActorHookProvider = _1.ActorHooks.ActorHookProvider;
54
- /**
55
- * `ActorManagerProvider` is a React functional component that serves as a context provider for IC actor managers within a React application.
56
- * It wraps child components, providing them access to actor-specific manager functionalities based on the provided actor manager and configuration.
57
- *
58
- * Props:
59
- * - `actorManager`: ActorManager - The actor manager object containing the actor manager functionalities.
60
- * - `children`: React Node - The child components that will have access to the actor manager context.
61
- *
62
- * Behavior:
63
- * - Validates the presence of the `actorManager`. Throws an error if it is missing, ensuring that the actor manager is always available for actor operations.
64
- * - Utilizes `useMemo` to memoize the `actorManager`, optimizing for performance by avoiding unnecessary recalculations.
65
- * - Renders the child components once the `actorManager` is available, effectively providing them access to the actor manager context.
66
- *
67
- * @example
68
- * ```jsx
69
- * <ActorManagerProvider actorManager={yourActorManager}>
70
- * <YourComponent />
71
- * </ActorManagerProvider>
72
- * ```
73
- * This setup ensures that `YourComponent` and any of its children can interact with the specified IC actor manager through the context provided by `ActorManagerProvider`.
74
- */
75
- exports.ActorManagerProvider = _1.ActorHooks.ActorManagerProvider;