@ic-reactor/react 2.0.1 → 3.0.0-beta.1
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.
- package/README.md +105 -79
- package/dist/createActorHooks.d.ts +39 -0
- package/dist/createActorHooks.d.ts.map +1 -0
- package/dist/createActorHooks.js +30 -0
- package/dist/createActorHooks.js.map +1 -0
- package/dist/createAuthHooks.d.ts +37 -0
- package/dist/createAuthHooks.d.ts.map +1 -0
- package/dist/createAuthHooks.js +94 -0
- package/dist/createAuthHooks.js.map +1 -0
- package/dist/createInfiniteQuery.d.ts +129 -0
- package/dist/createInfiniteQuery.d.ts.map +1 -0
- package/dist/createInfiniteQuery.js +160 -0
- package/dist/createInfiniteQuery.js.map +1 -0
- package/dist/createMutation.d.ts +19 -0
- package/dist/createMutation.d.ts.map +1 -0
- package/dist/createMutation.js +98 -0
- package/dist/createMutation.js.map +1 -0
- package/dist/createQuery.d.ts +20 -0
- package/dist/createQuery.d.ts.map +1 -0
- package/dist/createQuery.js +111 -0
- package/dist/createQuery.js.map +1 -0
- package/dist/createSuspenseInfiniteQuery.d.ts +122 -0
- package/dist/createSuspenseInfiniteQuery.d.ts.map +1 -0
- package/dist/createSuspenseInfiniteQuery.js +160 -0
- package/dist/createSuspenseInfiniteQuery.js.map +1 -0
- package/dist/createSuspenseQuery.d.ts +25 -0
- package/dist/createSuspenseQuery.d.ts.map +1 -0
- package/dist/createSuspenseQuery.js +116 -0
- package/dist/createSuspenseQuery.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -2
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -18
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useActorInfiniteQuery.d.ts +37 -0
- package/dist/hooks/useActorInfiniteQuery.d.ts.map +1 -0
- package/dist/hooks/useActorInfiniteQuery.js +33 -0
- package/dist/hooks/useActorInfiniteQuery.js.map +1 -0
- package/dist/hooks/useActorMutation.d.ts +23 -0
- package/dist/hooks/useActorMutation.d.ts.map +1 -0
- package/dist/hooks/useActorMutation.js +39 -0
- package/dist/hooks/useActorMutation.js.map +1 -0
- package/dist/hooks/useActorQuery.d.ts +32 -0
- package/dist/hooks/useActorQuery.d.ts.map +1 -0
- package/dist/hooks/useActorQuery.js +35 -0
- package/dist/hooks/useActorQuery.js.map +1 -0
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +36 -0
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +1 -0
- package/dist/hooks/useActorSuspenseInfiniteQuery.js +33 -0
- package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +1 -0
- package/dist/hooks/useActorSuspenseQuery.d.ts +32 -0
- package/dist/hooks/useActorSuspenseQuery.d.ts.map +1 -0
- package/dist/hooks/useActorSuspenseQuery.js +36 -0
- package/dist/hooks/useActorSuspenseQuery.js.map +1 -0
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -49
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +232 -13
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -22
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +131 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +125 -0
- package/dist/validation.js.map +1 -0
- package/package.json +70 -35
- package/LICENSE.md +0 -8
- package/dist/context/actor/create.d.ts +0 -63
- package/dist/context/actor/create.js +0 -119
- package/dist/context/actor/hooks/useActorInterface.d.ts +0 -4
- package/dist/context/actor/hooks/useActorInterface.js +0 -10
- package/dist/context/actor/hooks/useActorState.d.ts +0 -21
- package/dist/context/actor/hooks/useActorState.js +0 -25
- package/dist/context/actor/hooks/useActorStore.d.ts +0 -32
- package/dist/context/actor/hooks/useActorStore.js +0 -36
- package/dist/context/actor/hooks/useInitializeActor.d.ts +0 -6
- package/dist/context/actor/hooks/useInitializeActor.js +0 -10
- package/dist/context/actor/hooks/useMethod.d.ts +0 -29
- package/dist/context/actor/hooks/useMethod.js +0 -34
- package/dist/context/actor/hooks/useMethodAttributes.d.ts +0 -7
- package/dist/context/actor/hooks/useMethodAttributes.js +0 -11
- package/dist/context/actor/hooks/useMethodNames.d.ts +0 -7
- package/dist/context/actor/hooks/useMethodNames.js +0 -11
- package/dist/context/actor/hooks/useQueryCall.d.ts +0 -28
- package/dist/context/actor/hooks/useQueryCall.js +0 -33
- package/dist/context/actor/hooks/useUpdateCall.d.ts +0 -29
- package/dist/context/actor/hooks/useUpdateCall.js +0 -34
- package/dist/context/actor/hooks/useVisitMethod.d.ts +0 -8
- package/dist/context/actor/hooks/useVisitMethod.js +0 -13
- package/dist/context/actor/hooks/useVisitService.d.ts +0 -8
- package/dist/context/actor/hooks/useVisitService.js +0 -13
- package/dist/context/actor/index.d.ts +0 -16
- package/dist/context/actor/index.js +0 -33
- package/dist/context/actor/provider.d.ts +0 -71
- package/dist/context/actor/provider.js +0 -75
- package/dist/context/actor/types.d.ts +0 -35
- package/dist/context/actor/types.js +0 -2
- package/dist/context/adapter/create.d.ts +0 -2
- package/dist/context/adapter/create.js +0 -102
- package/dist/context/adapter/hooks/useCandidAdapter.d.ts +0 -23
- package/dist/context/adapter/hooks/useCandidAdapter.js +0 -27
- package/dist/context/adapter/hooks/useCandidEvaluation.d.ts +0 -5
- package/dist/context/adapter/hooks/useCandidEvaluation.js +0 -9
- package/dist/context/adapter/index.d.ts +0 -6
- package/dist/context/adapter/index.js +0 -24
- package/dist/context/adapter/provider.d.ts +0 -23
- package/dist/context/adapter/provider.js +0 -27
- package/dist/context/adapter/types.d.ts +0 -52
- package/dist/context/adapter/types.js +0 -2
- package/dist/context/agent/create.d.ts +0 -74
- package/dist/context/agent/create.js +0 -104
- package/dist/context/agent/hooks/useAgent.d.ts +0 -14
- package/dist/context/agent/hooks/useAgent.js +0 -18
- package/dist/context/agent/hooks/useAgentManager.d.ts +0 -14
- package/dist/context/agent/hooks/useAgentManager.js +0 -18
- package/dist/context/agent/hooks/useAgentState.d.ts +0 -21
- package/dist/context/agent/hooks/useAgentState.js +0 -25
- package/dist/context/agent/hooks/useAuth.d.ts +0 -57
- package/dist/context/agent/hooks/useAuth.js +0 -61
- package/dist/context/agent/hooks/useAuthState.d.ts +0 -19
- package/dist/context/agent/hooks/useAuthState.js +0 -23
- package/dist/context/agent/hooks/useUserPrincipal.d.ts +0 -17
- package/dist/context/agent/hooks/useUserPrincipal.js +0 -21
- package/dist/context/agent/index.d.ts +0 -12
- package/dist/context/agent/index.js +0 -29
- package/dist/context/agent/provider.d.ts +0 -28
- package/dist/context/agent/provider.js +0 -32
- package/dist/context/agent/types.d.ts +0 -17
- package/dist/context/agent/types.js +0 -2
- package/dist/core.d.ts +0 -1
- package/dist/core.js +0 -9
- package/dist/createReactor.d.ts +0 -49
- package/dist/createReactor.js +0 -69
- package/dist/helpers/actorHooks.d.ts +0 -18
- package/dist/helpers/actorHooks.js +0 -283
- package/dist/helpers/agentHooks.d.ts +0 -3
- package/dist/helpers/agentHooks.js +0 -22
- package/dist/helpers/authHooks.d.ts +0 -2
- package/dist/helpers/authHooks.js +0 -120
- package/dist/helpers/extractActorContext.d.ts +0 -4
- package/dist/helpers/extractActorContext.js +0 -44
- package/dist/helpers/extractAgentContext.d.ts +0 -28
- package/dist/helpers/extractAgentContext.js +0 -59
- package/dist/helpers/index.d.ts +0 -5
- package/dist/helpers/index.js +0 -21
- package/dist/helpers/types.d.ts +0 -222
- package/dist/helpers/types.js +0 -2
- package/dist/hooks/types.d.ts +0 -22
- package/dist/hooks/types.js +0 -2
- package/dist/hooks/useActor.d.ts +0 -67
- package/dist/hooks/useActor.js +0 -197
- package/dist/hooks/useActorManager.d.ts +0 -68
- package/dist/hooks/useActorManager.js +0 -75
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -17
|
@@ -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,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;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { IDL, ActorHooksReturnType, BaseActor, ActorManagerParameters, CanisterId, InitializeActor, ActorManager } from "../../types";
|
|
2
|
-
export interface CreateActorContextType<A = BaseActor> extends ActorHooksReturnType<A> {
|
|
3
|
-
useInitializeActor?: () => InitializeActor;
|
|
4
|
-
}
|
|
5
|
-
export interface CreateActorContextReturnType<A = BaseActor> extends ActorHooksReturnType<A> {
|
|
6
|
-
ActorProvider: React.FC<ActorProviderProps>;
|
|
7
|
-
ActorHookProvider: React.FC<ActorHookProviderProps<A>>;
|
|
8
|
-
ActorManagerProvider: React.FC<ActorManagerProviderProps<A>>;
|
|
9
|
-
useInitializeActor: () => InitializeActor;
|
|
10
|
-
}
|
|
11
|
-
export interface ActorHookProviderProps<A> {
|
|
12
|
-
hooks: ActorHooksReturnType<A>;
|
|
13
|
-
children?: React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
export interface ActorManagerProviderProps<A> {
|
|
16
|
-
children?: React.ReactNode | undefined;
|
|
17
|
-
actorManager: ActorManager<A>;
|
|
18
|
-
}
|
|
19
|
-
export interface ActorProviderProps extends CreateActorContextParameters {
|
|
20
|
-
children?: React.ReactNode | undefined;
|
|
21
|
-
candidString?: string;
|
|
22
|
-
fetchingComponent?: React.ReactNode;
|
|
23
|
-
errorComponent?: (error: string) => React.ReactNode;
|
|
24
|
-
loadingComponent?: React.ReactNode;
|
|
25
|
-
authenticatingComponent?: React.ReactNode;
|
|
26
|
-
}
|
|
27
|
-
export interface CreateActorContextParameters extends Omit<ActorManagerParameters, "idlFactory" | "agentManager" | "canisterId"> {
|
|
28
|
-
didjsId?: string;
|
|
29
|
-
canisterId?: CanisterId;
|
|
30
|
-
idlFactory?: IDL.InterfaceFactory;
|
|
31
|
-
disableAutoFetch?: boolean;
|
|
32
|
-
}
|
|
33
|
-
export interface ActorChildrenProps extends React.PropsWithChildren {
|
|
34
|
-
useActorState: ActorHooksReturnType["useActorState"];
|
|
35
|
-
}
|