@ic-reactor/core 1.6.0-beta.6 → 1.6.0-beta.7
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/classes/actor/index.d.ts +1 -1
- package/dist/classes/actor/types.d.ts +1 -3
- package/dist/classes/{candid → adapter}/index.d.ts +2 -2
- package/dist/classes/{candid → adapter}/index.js +12 -3
- package/dist/classes/{candid → adapter}/types.d.ts +1 -1
- package/dist/classes/agent/index.d.ts +1 -1
- package/dist/classes/agent/types.d.ts +1 -1
- package/dist/classes/index.d.ts +1 -1
- package/dist/classes/index.js +1 -1
- package/dist/classes/types.d.ts +1 -1
- package/dist/classes/types.js +1 -1
- package/dist/createActorManager.d.ts +1 -1
- package/dist/createAgentManager.d.ts +1 -1
- package/dist/createCandidAdapter.d.ts +2 -2
- package/dist/createCandidAdapter.js +2 -2
- package/dist/createReactorCore.js +1 -1
- package/dist/types.d.ts +1 -2
- package/dist/utils/agent.d.ts +1 -0
- package/dist/utils/agent.js +17 -0
- package/dist/utils/candid.d.ts +1 -0
- package/dist/utils/candid.js +17 -0
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +20 -5
- package/dist/utils/principal.d.ts +1 -0
- package/dist/utils/principal.js +17 -0
- package/package.json +9 -8
- /package/dist/classes/{candid → adapter}/types.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ActorMethodParameters, ActorMethodReturnType, ActorStore, ActorManagerParameters, FunctionName, VisitService, BaseActor, ActorMethodState, MethodAttributes } from "./types";
|
|
2
2
|
import { IDL } from "@dfinity/candid";
|
|
3
3
|
import type { AgentManager } from "../agent";
|
|
4
|
-
import type { UpdateAgentParameters } from "
|
|
4
|
+
import type { UpdateAgentParameters } from "../types";
|
|
5
5
|
export declare class ActorManager<A = BaseActor> {
|
|
6
6
|
private _actor;
|
|
7
7
|
private _idlFactory;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { IDL } from "@dfinity/candid";
|
|
2
1
|
import type { AgentManager } from "../agent";
|
|
3
|
-
import type { ActorMethod, ActorSubclass, Principal } from "../../types";
|
|
4
|
-
import { StoreApiWithDevtools } from "../types";
|
|
2
|
+
import type { IDL, StoreApiWithDevtools, ActorMethod, ActorSubclass, Principal } from "../../types";
|
|
5
3
|
export interface DefaultActorType {
|
|
6
4
|
[key: string]: ActorMethod;
|
|
7
5
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { HttpAgent } from "@dfinity/agent";
|
|
2
|
-
import type { CanisterId, CandidAdapterParameters, CandidDefenition } from "../../types";
|
|
2
|
+
import type { CanisterId, CandidAdapterParameters, CandidDefenition, ReactorParser } from "../../types";
|
|
3
3
|
export declare class CandidAdapter {
|
|
4
4
|
agent: HttpAgent;
|
|
5
5
|
didjsCanisterId: string;
|
|
6
6
|
private parserModule?;
|
|
7
7
|
unsubscribeAgent: () => void;
|
|
8
8
|
constructor({ agentManager, agent, didjsCanisterId, }: CandidAdapterParameters);
|
|
9
|
-
initializeParser(): Promise<void>;
|
|
9
|
+
initializeParser(module?: ReactorParser): Promise<void>;
|
|
10
10
|
private getDefaultDidJsId;
|
|
11
11
|
getCandidDefinition(canisterId: CanisterId): Promise<CandidDefenition>;
|
|
12
12
|
getFromMetadata(canisterId: CanisterId): Promise<string | undefined>;
|
|
@@ -31,12 +31,18 @@ class CandidAdapter {
|
|
|
31
31
|
}
|
|
32
32
|
this.didjsCanisterId = didjsCanisterId || this.getDefaultDidJsId();
|
|
33
33
|
}
|
|
34
|
-
initializeParser() {
|
|
34
|
+
initializeParser(module) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
|
|
36
|
+
if (module !== undefined) {
|
|
37
|
+
this.parserModule = module;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
37
40
|
try {
|
|
38
41
|
this.parserModule = require("@ic-reactor/parser");
|
|
39
|
-
|
|
42
|
+
if (typeof this.parserModule !== "undefined" &&
|
|
43
|
+
"default" in this.parserModule) {
|
|
44
|
+
yield this.parserModule.default();
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
47
|
catch (error) {
|
|
42
48
|
throw new Error(`Error initializing parser: ${error}`);
|
|
@@ -100,6 +106,9 @@ class CandidAdapter {
|
|
|
100
106
|
let candidDef = "";
|
|
101
107
|
try {
|
|
102
108
|
candidDef = this.parseDidToJs(data);
|
|
109
|
+
if (candidDef === "") {
|
|
110
|
+
throw new Error("Cannot compile Candid to JavaScript");
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
113
|
catch (error) {
|
|
105
114
|
candidDef = (yield this.fetchDidTojs(data))[0];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference path="../../../src/classes/candid/parser.d.ts" />
|
|
2
1
|
import type { AgentManager } from "../agent";
|
|
3
2
|
import type { IDL, HttpAgent } from "../../types";
|
|
4
3
|
export interface CandidAdapterParameters {
|
|
@@ -12,3 +11,4 @@ export interface CandidDefenition {
|
|
|
12
11
|
idl: typeof IDL;
|
|
13
12
|
}) => never[];
|
|
14
13
|
}
|
|
14
|
+
export type ReactorParser = typeof import("@ic-reactor/parser") | typeof import("@ic-reactor/parser/dist/node") | typeof import("@ic-reactor/parser/dist/bundler");
|
|
@@ -26,7 +26,7 @@ export declare class AgentManager {
|
|
|
26
26
|
getAgent: () => HttpAgent;
|
|
27
27
|
getAgentHost: () => URL;
|
|
28
28
|
getIsLocal: () => boolean;
|
|
29
|
-
getNetwork: () => "
|
|
29
|
+
getNetwork: () => "local" | "remote" | "ic";
|
|
30
30
|
getAgentState: AgentStore["getState"];
|
|
31
31
|
subscribeAgentState: AgentStore["subscribe"];
|
|
32
32
|
getAuthState: AuthStore["getState"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpAgent, HttpAgentOptions, Identity } from "@dfinity/agent";
|
|
2
2
|
import type { AuthClient } from "@dfinity/auth-client";
|
|
3
|
-
import { StoreApiWithDevtools } from "
|
|
3
|
+
import type { StoreApiWithDevtools } from "../../types";
|
|
4
4
|
export { HttpAgentOptions, AuthClient, Identity };
|
|
5
5
|
export interface AgentManagerParameters extends HttpAgentOptions {
|
|
6
6
|
port?: number;
|
package/dist/classes/index.d.ts
CHANGED
package/dist/classes/index.js
CHANGED
|
@@ -16,4 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./actor"), exports);
|
|
18
18
|
__exportStar(require("./agent"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./adapter"), exports);
|
package/dist/classes/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./agent/types";
|
|
2
2
|
export * from "./actor/types";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./adapter/types";
|
|
4
4
|
import { NamedSet } from "zustand/middleware";
|
|
5
5
|
import type { StoreApi } from "zustand";
|
|
6
6
|
export interface StoreApiWithDevtools<T> extends StoreApi<T> {
|
package/dist/classes/types.js
CHANGED
|
@@ -16,4 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./agent/types"), exports);
|
|
18
18
|
__exportStar(require("./actor/types"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./adapter/types"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActorManager } from "./classes/actor";
|
|
2
|
-
import { ActorManagerParameters, BaseActor } from "./types";
|
|
2
|
+
import type { ActorManagerParameters, BaseActor } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Actor manager handles the lifecycle of the actors.
|
|
5
5
|
* It is responsible for creating and managing the actors.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentManager } from "./classes/agent";
|
|
2
|
-
import { AgentManagerParameters } from "./types";
|
|
2
|
+
import type { AgentManagerParameters } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Agent manager handles the lifecycle of the `@dfinity/agent`.
|
|
5
5
|
* It is responsible for creating agent and managing the agent's state.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CandidAdapter } from "./classes/
|
|
2
|
-
import { CandidAdapterParameters } from "./types";
|
|
1
|
+
import { CandidAdapter } from "./classes/adapter";
|
|
2
|
+
import type { CandidAdapterParameters } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* The `CandidAdapter` class is used to interact with a canister and retrieve its Candid interface definition.
|
|
5
5
|
* It provides methods to fetch the Candid definition either from the canister's metadata or by using a temporary hack method.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCandidAdapter = void 0;
|
|
4
|
-
const
|
|
4
|
+
const adapter_1 = require("./classes/adapter");
|
|
5
5
|
/**
|
|
6
6
|
* The `CandidAdapter` class is used to interact with a canister and retrieve its Candid interface definition.
|
|
7
7
|
* It provides methods to fetch the Candid definition either from the canister's metadata or by using a temporary hack method.
|
|
@@ -11,6 +11,6 @@ const candid_1 = require("./classes/candid");
|
|
|
11
11
|
* @includeExample ./packages/core/README.md:151-192
|
|
12
12
|
*/
|
|
13
13
|
const createCandidAdapter = (config) => {
|
|
14
|
-
return new
|
|
14
|
+
return new adapter_1.CandidAdapter(config);
|
|
15
15
|
};
|
|
16
16
|
exports.createCandidAdapter = createCandidAdapter;
|
|
@@ -21,8 +21,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.createReactorCore = void 0;
|
|
24
|
-
const utils_1 = require("./utils");
|
|
25
24
|
const createReactorStore_1 = require("./createReactorStore");
|
|
25
|
+
const utils_1 = require("./utils");
|
|
26
26
|
/**
|
|
27
27
|
* The Core module is the main entry point for the library.
|
|
28
28
|
* Create a new actor manager with the given options.
|
package/dist/types.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ import type { ActorManager } from "./classes/actor";
|
|
|
7
7
|
import type { AgentManager } from "./classes/agent";
|
|
8
8
|
import type { AuthClientLoginOptions } from "@dfinity/auth-client";
|
|
9
9
|
export * from "./classes/types";
|
|
10
|
-
export type { ActorManager, AgentManager };
|
|
11
|
-
export type { ActorMethod, AuthClientLoginOptions, HttpAgentOptions, ActorSubclass, Principal, HttpAgent, Identity, IDL, };
|
|
10
|
+
export type { ActorManager, AgentManager, ActorMethod, AuthClientLoginOptions, HttpAgentOptions, ActorSubclass, Principal, HttpAgent, Identity, IDL, };
|
|
12
11
|
export interface CreateReactorStoreParameters extends HttpAgentOptions, Omit<ActorManagerParameters, "agentManager"> {
|
|
13
12
|
agentManager?: AgentManager;
|
|
14
13
|
withProcessEnv?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@dfinity/agent";
|
|
@@ -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("@dfinity/agent"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@dfinity/candid";
|
|
@@ -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("@dfinity/candid"), exports);
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -10,14 +10,29 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
29
|
+
exports.agent = exports.principal = exports.candid = void 0;
|
|
18
30
|
__exportStar(require("./helper"), exports);
|
|
19
31
|
__exportStar(require("./constants"), exports);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
// Re-export the peerDependencies
|
|
33
|
+
/// https://agent-js.icp.xyz/candid
|
|
34
|
+
exports.candid = __importStar(require("./candid"));
|
|
35
|
+
/// https://agent-js.icp.xyz/principal
|
|
36
|
+
exports.principal = __importStar(require("./principal"));
|
|
37
|
+
/// https://agent-js.icp.xyz/agent
|
|
38
|
+
exports.agent = __importStar(require("./agent"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@dfinity/principal";
|
|
@@ -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("@dfinity/principal"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/core",
|
|
3
|
-
"version": "1.6.0-beta.
|
|
3
|
+
"version": "1.6.0-beta.7",
|
|
4
4
|
"description": "A library for intracting with the Internet Computer canisters",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,19 +41,20 @@
|
|
|
41
41
|
"zustand": "^4.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@ic-reactor/parser": "^0.1.0-beta.
|
|
44
|
+
"@ic-reactor/parser": "^0.1.0-beta.2"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\"
|
|
47
|
+
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
|
|
48
48
|
"start": "tsc watch",
|
|
49
|
-
"bundle": "
|
|
50
|
-
"bundle:dev": "npx webpack --mode development",
|
|
51
|
-
"bundle:prod": "npx webpack --mode production",
|
|
52
|
-
"build": "
|
|
49
|
+
"bundle": "yarn bundle:dev && yarn bundle:prod",
|
|
50
|
+
"bundle:dev": "npx webpack-cli --mode development",
|
|
51
|
+
"bundle:prod": "npx webpack-cli --mode production",
|
|
52
|
+
"build:tsc": "tsc",
|
|
53
|
+
"build": "yarn build:tsc && yarn bundle",
|
|
53
54
|
"clean": "npx rimraf dist && npx rimraf umd && npx rimraf node_modules"
|
|
54
55
|
},
|
|
55
56
|
"engines": {
|
|
56
57
|
"node": ">=10"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "970609e4e07d49e34894eaa9ea258ef02390aea1"
|
|
59
60
|
}
|
|
File without changes
|