*Add dist

This commit is contained in:
Derrick Hammer 2022-07-20 03:36:21 -04:00
parent 97a4d8d170
commit b4a7e2708f
3 changed files with 73 additions and 0 deletions

17
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,17 @@
import { ErrTuple } from "libskynet";
import type { RPCRequest } from "@lumeweb/dht-rpc-client";
export declare class RpcNetwork {
private _actionQueue;
get ready(): Promise<ErrTuple>;
addRelay(pubkey: string): void;
removeRelay(pubkey: string): void;
clearRelays(): void;
query(query: string, chain: string, data?: object | any[], force?: boolean): RpcQuery;
processQueue(): Promise<void>;
}
export declare class RpcQuery {
private _promise;
constructor(network: RpcNetwork, query: RPCRequest);
get result(): Promise<any>;
}
//# sourceMappingURL=index.d.ts.map

1
dist/index.d.ts.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAe1D,qBAAa,UAAU;IACrB,OAAO,CAAC,YAAY,CAA2B;IAE/C,IAAI,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,CAE7B;IAEM,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI9B,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIjC,WAAW,IAAI,IAAI;IAInB,KAAK,CACV,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,MAAM,GAAG,GAAG,EAAO,EACzB,KAAK,GAAE,OAAe,GACrB,QAAQ;IASE,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAI3C;AAED,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAe;gBAEnB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IAMlD,IAAI,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,CAOzB;CACF"}

55
dist/index.js vendored Normal file
View File

@ -0,0 +1,55 @@
import { callModule as callModuleKernel, connectModule as connectModuleKernel, } from "libkernel";
import { callModule as callModuleModule, connectModule as connectModuleModule, } from "libkmodule";
const RPC_MODULE = "AQDaEPIo_lpdvz7AKbeafERBHR331RiyvweJ6OrFTplzyg";
let callModule, connectModule;
if (window.document) {
callModule = callModuleKernel;
connectModule = connectModuleKernel;
}
else {
callModule = callModuleModule;
connectModule = connectModuleModule;
}
export class RpcNetwork {
_actionQueue = [];
get ready() {
return callModule(RPC_MODULE, "ready");
}
addRelay(pubkey) {
this._actionQueue.push(callModule(RPC_MODULE, "addRelay", { pubkey }));
}
removeRelay(pubkey) {
this._actionQueue.push(callModule(RPC_MODULE, "removeRelay", { pubkey }));
}
clearRelays() {
this._actionQueue.push(callModule(RPC_MODULE, "clearRelays"));
}
query(query, chain, data = {}, force = false) {
return new RpcQuery(this, {
query,
chain,
data,
force: force,
});
}
async processQueue() {
await Promise.allSettled(this._actionQueue);
this._actionQueue = [];
}
}
export class RpcQuery {
_promise;
constructor(network, query) {
this._promise = network
.processQueue()
.then(() => callModule(RPC_MODULE, "query", query));
}
get result() {
return this._promise.then((result) => {
if (result[1]) {
throw new Error(result[1]);
}
return result[0];
});
}
}