@xyo-network/os-runtime 4.2.10 → 4.2.12
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/neutral/helpers/DappInitializer.d.ts +18 -0
- package/dist/neutral/helpers/DappInitializer.d.ts.map +1 -0
- package/dist/neutral/helpers/index.d.ts +1 -0
- package/dist/neutral/helpers/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +40 -2
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/helpers/DappInitializer.d.ts +18 -0
- package/dist/node/helpers/DappInitializer.d.ts.map +1 -0
- package/dist/node/helpers/index.d.ts +1 -0
- package/dist/node/helpers/index.d.ts.map +1 -1
- package/dist/node/index.mjs +40 -2
- package/dist/node/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/helpers/DappInitializer.ts +57 -0
- package/src/helpers/index.ts +1 -0
- package/src/spec/boot.test.ts +89 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RegisteredDapp, WindowDappNodeSet, XyOsContext } from '@xyo-network/os-model';
|
|
2
|
+
/** Helper class to simulate full dapp initialization by the OS */
|
|
3
|
+
export interface DappInitializerConfig<T extends RegisteredDapp = RegisteredDapp> {
|
|
4
|
+
allowedNames: string[];
|
|
5
|
+
dapp: T;
|
|
6
|
+
xnsNetwork: string | undefined;
|
|
7
|
+
xnsNodeUrl: string | undefined;
|
|
8
|
+
xyOs: XyOsContext;
|
|
9
|
+
}
|
|
10
|
+
export declare class DappInitializer<T extends RegisteredDapp = RegisteredDapp> {
|
|
11
|
+
private _config;
|
|
12
|
+
constructor(config: DappInitializerConfig);
|
|
13
|
+
get config(): DappInitializerConfig<RegisteredDapp<import("@xyo-network/os-model").DappParams>>;
|
|
14
|
+
install(): Promise<WindowDappNodeSet>;
|
|
15
|
+
private initializeDappContext;
|
|
16
|
+
private installDappWallet;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=DappInitializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DappInitializer.d.ts","sourceRoot":"","sources":["../../../src/helpers/DappInitializer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAC/C,MAAM,uBAAuB,CAAA;AAK9B,mEAAmE;AACnE,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc;IAC9E,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,IAAI,EAAE,CAAC,CAAA;IACP,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,qBAAa,eAAe,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc;IACpE,OAAO,CAAC,OAAO,CAAuB;gBAE1B,MAAM,EAAE,qBAAqB;IAIzC,IAAI,MAAM,sFAET;IAEK,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;YAM7B,qBAAqB;YAQrB,iBAAiB;CAchC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -3657,6 +3657,43 @@ var ValidDappAccessInterfaces = {
|
|
|
3657
3657
|
[RegisteredNames]: RegisteredNamesInterface
|
|
3658
3658
|
};
|
|
3659
3659
|
|
|
3660
|
+
// src/helpers/DappInitializer.ts
|
|
3661
|
+
import { assertEx as assertEx28 } from "@xylabs/assert";
|
|
3662
|
+
var DappInitializer = class {
|
|
3663
|
+
static {
|
|
3664
|
+
__name(this, "DappInitializer");
|
|
3665
|
+
}
|
|
3666
|
+
_config;
|
|
3667
|
+
constructor(config) {
|
|
3668
|
+
this._config = config;
|
|
3669
|
+
}
|
|
3670
|
+
get config() {
|
|
3671
|
+
return assertEx28(this._config, () => new Error("Options not set"));
|
|
3672
|
+
}
|
|
3673
|
+
async install() {
|
|
3674
|
+
const dappWithWalletId = await this.installDappWallet();
|
|
3675
|
+
return await this.initializeDappContext(dappWithWalletId);
|
|
3676
|
+
}
|
|
3677
|
+
async initializeDappContext(dappWithWalletId) {
|
|
3678
|
+
const { allowedNames, xnsNetwork, xnsNodeUrl, xyOs } = this.config;
|
|
3679
|
+
return await RunningDappCache.findOrCreate(dappWithWalletId, xyOs, allowedNames ?? [], xnsNodeUrl, xnsNetwork);
|
|
3680
|
+
}
|
|
3681
|
+
async installDappWallet() {
|
|
3682
|
+
const { xyOs, dapp } = this.config;
|
|
3683
|
+
const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [
|
|
3684
|
+
dapp.config.name
|
|
3685
|
+
]);
|
|
3686
|
+
const walletId = await dappSeedPhraseRepository.findOrCreate(dapp.config.name);
|
|
3687
|
+
return {
|
|
3688
|
+
...dapp,
|
|
3689
|
+
config: {
|
|
3690
|
+
...dapp.config,
|
|
3691
|
+
walletId
|
|
3692
|
+
}
|
|
3693
|
+
};
|
|
3694
|
+
}
|
|
3695
|
+
};
|
|
3696
|
+
|
|
3660
3697
|
// src/helpers/monitor/XyOsMonitor.ts
|
|
3661
3698
|
var DEFAULT_MONITORING_EVENT_NAME = "System Task Duration";
|
|
3662
3699
|
globalThis.getXyOsGlobal = globalThis.getXyOsGlobal ?? (() => {
|
|
@@ -3734,7 +3771,7 @@ var profileModuleEvents = /* @__PURE__ */ __name((mod) => {
|
|
|
3734
3771
|
}, "profileModuleEvents");
|
|
3735
3772
|
|
|
3736
3773
|
// src/PubSubBridgeCaller.ts
|
|
3737
|
-
import { assertEx as
|
|
3774
|
+
import { assertEx as assertEx29 } from "@xylabs/assert";
|
|
3738
3775
|
import { asBridgeInstance } from "@xyo-network/bridge-model";
|
|
3739
3776
|
import { BridgedPubSubModuleName } from "@xyo-network/os-model";
|
|
3740
3777
|
var PubSubBridgeCaller = class {
|
|
@@ -3759,7 +3796,7 @@ var PubSubBridgeCaller = class {
|
|
|
3759
3796
|
}
|
|
3760
3797
|
}
|
|
3761
3798
|
async getPubSubBridge() {
|
|
3762
|
-
const mod =
|
|
3799
|
+
const mod = assertEx29(await this.node.resolve(BridgedPubSubModuleName), () => `${BridgedPubSubModuleName} not found`);
|
|
3763
3800
|
return asBridgeInstance(mod, () => `${BridgedPubSubModuleName} is not a bridge`);
|
|
3764
3801
|
}
|
|
3765
3802
|
};
|
|
@@ -3777,6 +3814,7 @@ export {
|
|
|
3777
3814
|
DappContextCreator,
|
|
3778
3815
|
DappDefaultsResource,
|
|
3779
3816
|
DappDefaultsResourceQueries,
|
|
3817
|
+
DappInitializer,
|
|
3780
3818
|
DappIntentCaller,
|
|
3781
3819
|
DappIntentResource,
|
|
3782
3820
|
DappMenuCaller,
|