@ic-reactor/react 0.5.3 → 0.5.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.
package/dist/index.js CHANGED
@@ -41,6 +41,16 @@ const createReActor = (_a) => {
41
41
  process.env.NODE_ENV === "development"));
42
42
  const actorManager = (0, store_1.createReActorStore)(Object.assign({ isLocalEnv,
43
43
  withServiceFields }, options));
44
- return Object.assign(Object.assign({}, (0, actor_1.getActorHooks)(actorManager)), (0, auth_1.getAuthHooks)(actorManager.agentManager));
44
+ const getServiceFields = () => {
45
+ if (!withServiceFields || !actorManager.serviceFields) {
46
+ throw new Error("Service fields not initialized. Pass `withServiceFields` to initialize service fields.");
47
+ }
48
+ return actorManager.serviceFields;
49
+ };
50
+ const getAgent = () => {
51
+ return actorManager.agentManager.getAgent();
52
+ };
53
+ return Object.assign(Object.assign({ getAgent,
54
+ getServiceFields }, (0, actor_1.getActorHooks)(actorManager)), (0, auth_1.getAuthHooks)(actorManager.agentManager));
45
55
  };
46
56
  exports.createReActor = createReActor;
package/dist/types.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  /// <reference types="react" />
2
- import type { ActorState, ActorSubclass, CanisterId, CreateReActorOptions, ExtractActorMethodArgs, ExtractActorMethodReturnType, ExtractedFunction, ExtractedService, Identity, Principal, ServiceMethodType, ServiceMethodTypeAndName } from "@ic-reactor/store";
3
- import { AuthHooks } from "./hooks/auth";
4
- export type * from "@ic-reactor/store";
5
- export type * from "@ic-reactor/store/dist/actor/types";
2
+ import type { ActorState, ActorSubclass, CanisterId, CreateReActorOptions, ExtractActorMethodArgs, ExtractActorMethodReturnType, ExtractedFunction, ExtractedService, HttpAgent, Identity, Principal, ServiceMethodType, ServiceMethodTypeAndName } from "@ic-reactor/store";
3
+ import type { AuthHooks } from "./hooks/auth";
6
4
  export type AuthArgs = {
7
5
  onAuthentication?: (promise: () => Promise<Identity>) => void;
8
6
  onAuthenticationSuccess?: (identity: Identity) => void;
@@ -67,11 +65,15 @@ export interface ActorDefaultHooks<A, W extends boolean = false> {
67
65
  type: T;
68
66
  }) => T extends "query" ? ActorUseQueryReturn<A, M, W> : ActorUseUpdateReturn<A, M, W>;
69
67
  }
68
+ export type GetFunctions<A> = {
69
+ getAgent: () => HttpAgent;
70
+ getServiceFields: () => ExtractedService<A>;
71
+ };
70
72
  export type CreateReActor = {
71
73
  <A extends ActorSubclass<any>>(options: CreateReActorOptions & {
72
74
  withServiceFields: true;
73
- }): ActorHooksWithField<A> & AuthHooks;
75
+ }): GetFunctions<A> & ActorHooksWithField<A> & AuthHooks;
74
76
  <A extends ActorSubclass<any>>(options: CreateReActorOptions & {
75
77
  withServiceFields?: false | undefined;
76
- }): ActorHooksWithoutField<A> & AuthHooks;
78
+ }): GetFunctions<A> & ActorHooksWithoutField<A> & AuthHooks;
77
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/react",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "A React library for interacting with Dfinity actors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -48,5 +48,5 @@
48
48
  "react": ">=16.8",
49
49
  "zustand": "4.4"
50
50
  },
51
- "gitHead": "581df4947caeb34fcdf2b773e5f8543fdb5ceaaa"
51
+ "gitHead": "e2ec7048f2d3517cb5ffb9a9188d508cb50fe924"
52
52
  }