@ic-reactor/core 2.0.0 → 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/dist/client.d.ts +161 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +499 -0
- package/dist/client.js.map +1 -0
- package/dist/display/helper.d.ts +10 -0
- package/dist/display/helper.d.ts.map +1 -0
- package/dist/display/helper.js +67 -0
- package/dist/display/helper.js.map +1 -0
- package/dist/display/index.d.ts +4 -0
- package/dist/display/index.d.ts.map +1 -0
- package/dist/display/index.js +4 -0
- package/dist/display/index.js.map +1 -0
- package/dist/display/types.d.ts +31 -0
- package/dist/display/types.d.ts.map +1 -0
- package/dist/display/types.js +2 -0
- package/dist/display/types.js.map +1 -0
- package/dist/display/visitor.d.ts +28 -0
- package/dist/display/visitor.d.ts.map +1 -0
- package/dist/display/visitor.js +318 -0
- package/dist/display/visitor.js.map +1 -0
- package/dist/display-reactor.d.ts +245 -0
- package/dist/display-reactor.d.ts.map +1 -0
- package/dist/display-reactor.js +331 -0
- package/dist/display-reactor.js.map +1 -0
- package/dist/errors/index.d.ts +118 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +204 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -47
- package/dist/index.js.map +1 -0
- package/dist/reactor.d.ts +133 -0
- package/dist/reactor.d.ts.map +1 -0
- package/dist/reactor.js +325 -0
- package/dist/reactor.js.map +1 -0
- package/dist/types/client.d.ts +89 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +2 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/reactor.d.ts +117 -0
- package/dist/types/reactor.d.ts.map +1 -0
- package/dist/types/reactor.js +2 -0
- package/dist/types/reactor.js.map +1 -0
- package/dist/types/result.d.ts +48 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +2 -0
- package/dist/types/result.js.map +1 -0
- package/dist/types/transform.d.ts +7 -0
- package/dist/types/transform.d.ts.map +1 -0
- package/dist/types/transform.js +2 -0
- package/dist/types/transform.js.map +1 -0
- package/dist/types/variant.d.ts +18 -0
- package/dist/types/variant.d.ts.map +1 -0
- package/dist/types/variant.js +2 -0
- package/dist/types/variant.js.map +1 -0
- package/dist/utils/agent.d.ts +30 -1
- package/dist/utils/agent.d.ts.map +1 -0
- package/dist/utils/agent.js +118 -16
- package/dist/utils/agent.js.map +1 -0
- package/dist/utils/candid.d.ts +39 -1
- package/dist/utils/candid.d.ts.map +1 -0
- package/dist/utils/candid.js +76 -16
- package/dist/utils/candid.js.map +1 -0
- package/dist/utils/constants.d.ts +3 -4
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +7 -11
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/helper.d.ts +16 -39
- package/dist/utils/helper.d.ts.map +1 -0
- package/dist/utils/helper.js +53 -155
- package/dist/utils/helper.js.map +1 -0
- package/dist/utils/index.d.ts +4 -5
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -49
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/polling.d.ts +176 -0
- package/dist/utils/polling.d.ts.map +1 -0
- package/dist/utils/polling.js +170 -0
- package/dist/utils/polling.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +65 -39
- package/LICENSE.md +0 -8
- package/README.md +0 -283
- package/dist/classes/actor/index.d.ts +0 -34
- package/dist/classes/actor/index.js +0 -245
- package/dist/classes/actor/types.d.ts +0 -113
- package/dist/classes/actor/types.js +0 -2
- package/dist/classes/adapter/index.d.ts +0 -19
- package/dist/classes/adapter/index.js +0 -140
- package/dist/classes/adapter/types.d.ts +0 -14
- package/dist/classes/adapter/types.js +0 -2
- package/dist/classes/agent/index.d.ts +0 -36
- package/dist/classes/agent/index.js +0 -218
- package/dist/classes/agent/types.d.ts +0 -87
- package/dist/classes/agent/types.js +0 -2
- package/dist/classes/index.d.ts +0 -3
- package/dist/classes/index.js +0 -19
- package/dist/classes/types.d.ts +0 -15
- package/dist/classes/types.js +0 -20
- package/dist/createActorManager.d.ts +0 -12
- package/dist/createActorManager.js +0 -17
- package/dist/createAgentManager.d.ts +0 -12
- package/dist/createAgentManager.js +0 -17
- package/dist/createCandidAdapter.d.ts +0 -11
- package/dist/createCandidAdapter.js +0 -16
- package/dist/createReactorCore.d.ts +0 -10
- package/dist/createReactorCore.js +0 -112
- package/dist/createReactorStore.d.ts +0 -11
- package/dist/createReactorStore.js +0 -31
- package/dist/types.d.ts +0 -96
- package/dist/types.js +0 -17
- package/dist/utils/hash.d.ts +0 -12
- package/dist/utils/hash.js +0 -70
- package/dist/utils/principal.d.ts +0 -1
- package/dist/utils/principal.js +0 -17
package/dist/types.d.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { ActorMethod, ActorSubclass, HttpAgentOptions, HttpAgent, Identity, CallConfig } from "@dfinity/agent";
|
|
2
|
-
import type { Principal } from "@dfinity/principal";
|
|
3
|
-
import type { IDL } from "@dfinity/candid";
|
|
4
|
-
import type { ActorManagerParameters, ActorMethodParameters, ActorMethodReturnType, ActorMethodState, BaseActor, FunctionName } from "./classes/actor/types";
|
|
5
|
-
import type { ActorManager } from "./classes/actor";
|
|
6
|
-
import type { AgentManager } from "./classes/agent";
|
|
7
|
-
import type { AuthClientLoginOptions } from "@dfinity/auth-client";
|
|
8
|
-
export * from "./classes/types";
|
|
9
|
-
export type { ActorManager, AgentManager, ActorMethod, AuthClientLoginOptions, HttpAgentOptions, ActorSubclass, Principal, HttpAgent, Identity, IDL, };
|
|
10
|
-
export interface CreateReactorStoreParameters extends HttpAgentOptions, Omit<ActorManagerParameters, "agentManager"> {
|
|
11
|
-
agentManager?: AgentManager;
|
|
12
|
-
withProcessEnv?: boolean;
|
|
13
|
-
withLocalEnv?: boolean;
|
|
14
|
-
port?: number;
|
|
15
|
-
}
|
|
16
|
-
export type ActorGetStateFunction<A, M extends FunctionName<A>> = {
|
|
17
|
-
(key: "data"): ActorMethodReturnType<A[M]>;
|
|
18
|
-
(key: "loading"): boolean;
|
|
19
|
-
(key: "error"): Error | undefined;
|
|
20
|
-
(): ActorMethodState<A, M>[string];
|
|
21
|
-
};
|
|
22
|
-
export type ActorSubscribeFunction<A, M extends FunctionName<A>> = (callback: (state: ActorMethodState<A, M>[string]) => void) => () => void;
|
|
23
|
-
export type ActorCallFunction<A, M extends FunctionName<A>> = (replaceArgs?: ActorMethodParameters<A[M]>) => Promise<ActorMethodReturnType<A[M]>>;
|
|
24
|
-
export type ActorQueryReturnType<A, M extends FunctionName<A>> = {
|
|
25
|
-
intervalId: NodeJS.Timeout | null;
|
|
26
|
-
requestHash: string;
|
|
27
|
-
getState: ActorGetStateFunction<A, M>;
|
|
28
|
-
subscribe: ActorSubscribeFunction<A, M>;
|
|
29
|
-
call: ActorCallFunction<A, M>;
|
|
30
|
-
dataPromise: Promise<ActorMethodReturnType<A[M]>>;
|
|
31
|
-
};
|
|
32
|
-
export type ActorUpdateReturnType<A, M extends FunctionName<A>> = {
|
|
33
|
-
requestHash: string;
|
|
34
|
-
getState: ActorGetStateFunction<A, M>;
|
|
35
|
-
subscribe: ActorSubscribeFunction<A, M>;
|
|
36
|
-
call: ActorCallFunction<A, M>;
|
|
37
|
-
};
|
|
38
|
-
export interface ActorQueryParameters<A, M extends FunctionName<A>> extends CallConfig {
|
|
39
|
-
functionName: M;
|
|
40
|
-
args?: ActorMethodParameters<A[M]>;
|
|
41
|
-
refetchOnMount?: boolean;
|
|
42
|
-
refetchInterval?: number | false;
|
|
43
|
-
}
|
|
44
|
-
export interface ActorUpdateParameters<A, M extends FunctionName<A>> extends CallConfig {
|
|
45
|
-
functionName: M;
|
|
46
|
-
args?: ActorMethodParameters<A[M]>;
|
|
47
|
-
}
|
|
48
|
-
export type ActorMethodCall<A = Record<string, ActorMethod>> = <M extends FunctionName<A>>(functionName: M, args: ActorMethodParameters<A[M]>, options?: CallConfig) => ActorUpdateReturnType<A, M>;
|
|
49
|
-
export type ActorQuery<A = Record<string, ActorMethod>> = <M extends FunctionName<A>>(params: ActorQueryParameters<A, M>) => ActorQueryReturnType<A, M>;
|
|
50
|
-
export type ActorUpdate<A = Record<string, ActorMethod>> = <M extends FunctionName<A>>(params: ActorUpdateParameters<A, M>) => ActorUpdateReturnType<A, M>;
|
|
51
|
-
export type CreateReactorCoreParameters = CreateReactorStoreParameters;
|
|
52
|
-
export interface CreateReactorCoreReturnType<A = BaseActor> extends AgentManager, Omit<ActorManager<A>, "updateMethodState"> {
|
|
53
|
-
queryCall: ActorQuery<A>;
|
|
54
|
-
updateCall: ActorUpdate<A>;
|
|
55
|
-
}
|
|
56
|
-
export type UnwrapResult<T> = T extends {
|
|
57
|
-
Ok: infer U;
|
|
58
|
-
} ? U : T extends {
|
|
59
|
-
Err: infer E;
|
|
60
|
-
} ? E : T;
|
|
61
|
-
type ExtractOkErr<T> = T extends {
|
|
62
|
-
Ok: infer U;
|
|
63
|
-
} ? {
|
|
64
|
-
OkType: U;
|
|
65
|
-
ErrType: never;
|
|
66
|
-
} : T extends {
|
|
67
|
-
Err: infer E;
|
|
68
|
-
} ? {
|
|
69
|
-
OkType: never;
|
|
70
|
-
ErrType: E;
|
|
71
|
-
} : {
|
|
72
|
-
OkType: T;
|
|
73
|
-
ErrType: never;
|
|
74
|
-
};
|
|
75
|
-
export type ExtractOk<T> = T extends {
|
|
76
|
-
Ok: infer U;
|
|
77
|
-
} ? U : never;
|
|
78
|
-
export type ExtractErr<T> = T extends {
|
|
79
|
-
Err: infer E;
|
|
80
|
-
} ? E : never;
|
|
81
|
-
export type CompiledOkResult<U> = {
|
|
82
|
-
isOk: true;
|
|
83
|
-
isErr: false;
|
|
84
|
-
value: U;
|
|
85
|
-
error: null;
|
|
86
|
-
};
|
|
87
|
-
export type CompiledErrResult<E> = {
|
|
88
|
-
isOk: false;
|
|
89
|
-
isErr: true;
|
|
90
|
-
value: null;
|
|
91
|
-
error: E;
|
|
92
|
-
};
|
|
93
|
-
export type CompiledResult<T> = ExtractOkErr<T> extends {
|
|
94
|
-
OkType: infer U;
|
|
95
|
-
ErrType: infer E;
|
|
96
|
-
} ? CompiledOkResult<U> | CompiledErrResult<E> : never;
|
package/dist/types.js
DELETED
|
@@ -1,17 +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
|
-
__exportStar(require("./classes/types"), exports);
|
package/dist/utils/hash.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a stable string representation of any JavaScript value
|
|
3
|
-
* Handles circular references and maintains consistent object key ordering
|
|
4
|
-
*/
|
|
5
|
-
export declare function stringifyStable(value: unknown): string;
|
|
6
|
-
/**
|
|
7
|
-
* Creates a simple numeric hash code and returns it as a hex string
|
|
8
|
-
* @param value - Any JavaScript value
|
|
9
|
-
* @param length - Desired length of the hex string (default: 8)
|
|
10
|
-
* @returns string - Hex string of specified length
|
|
11
|
-
*/
|
|
12
|
-
export declare function createSimpleHash(value: unknown, length?: number): string;
|
package/dist/utils/hash.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringifyStable = stringifyStable;
|
|
4
|
-
exports.createSimpleHash = createSimpleHash;
|
|
5
|
-
/**
|
|
6
|
-
* Creates a stable string representation of any JavaScript value
|
|
7
|
-
* Handles circular references and maintains consistent object key ordering
|
|
8
|
-
*/
|
|
9
|
-
function stringifyStable(value) {
|
|
10
|
-
const seen = new WeakSet();
|
|
11
|
-
return JSON.stringify(value, (_, value) => {
|
|
12
|
-
if (value === undefined)
|
|
13
|
-
return "[undefined]";
|
|
14
|
-
if (value === null)
|
|
15
|
-
return "[null]";
|
|
16
|
-
if (Number.isNaN(value))
|
|
17
|
-
return "[NaN]";
|
|
18
|
-
if (value === Infinity)
|
|
19
|
-
return "[Infinity]";
|
|
20
|
-
if (value === -Infinity)
|
|
21
|
-
return "[-Infinity]";
|
|
22
|
-
if (typeof value === "bigint")
|
|
23
|
-
return value.toString();
|
|
24
|
-
if (typeof value === "function")
|
|
25
|
-
return value.toString();
|
|
26
|
-
if (value instanceof Date)
|
|
27
|
-
return value.toISOString();
|
|
28
|
-
if (value instanceof RegExp)
|
|
29
|
-
return value.toString();
|
|
30
|
-
if (ArrayBuffer.isView(value)) {
|
|
31
|
-
return Array.from(value).join(",");
|
|
32
|
-
}
|
|
33
|
-
if (typeof value === "object" && value !== null) {
|
|
34
|
-
if (seen.has(value))
|
|
35
|
-
return "[Circular]";
|
|
36
|
-
seen.add(value);
|
|
37
|
-
if (Array.isArray(value)) {
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
const sortedObj = {};
|
|
41
|
-
const sortedKeys = Object.keys(value).sort();
|
|
42
|
-
for (const key of sortedKeys) {
|
|
43
|
-
sortedObj[key] = value[key];
|
|
44
|
-
}
|
|
45
|
-
return sortedObj;
|
|
46
|
-
}
|
|
47
|
-
return value;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Creates a simple numeric hash code and returns it as a hex string
|
|
52
|
-
* @param value - Any JavaScript value
|
|
53
|
-
* @param length - Desired length of the hex string (default: 8)
|
|
54
|
-
* @returns string - Hex string of specified length
|
|
55
|
-
*/
|
|
56
|
-
function createSimpleHash(value, length = 8) {
|
|
57
|
-
const str = stringifyStable(value);
|
|
58
|
-
let hash = 0;
|
|
59
|
-
// Generate a more distributed hash
|
|
60
|
-
for (let i = 0; i < str.length; i++) {
|
|
61
|
-
const char = str.charCodeAt(i);
|
|
62
|
-
hash = (hash << 5) - hash + char;
|
|
63
|
-
hash = hash & hash; // Convert to 32-bit integer
|
|
64
|
-
}
|
|
65
|
-
// Convert to positive hex string and ensure proper length
|
|
66
|
-
const positiveHash = Math.abs(hash);
|
|
67
|
-
const hexString = positiveHash.toString(16);
|
|
68
|
-
// Pad with zeros to match desired length
|
|
69
|
-
return hexString.padStart(length, "0");
|
|
70
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@dfinity/principal";
|
package/dist/utils/principal.js
DELETED
|
@@ -1,17 +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
|
-
__exportStar(require("@dfinity/principal"), exports);
|