@xyo-network/dapp-template 4.2.0 → 4.2.2
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/DappHost.d.ts.map +1 -1
- package/dist/neutral/helpers/index.d.ts +2 -0
- package/dist/neutral/helpers/index.d.ts.map +1 -0
- package/dist/neutral/helpers/registration/DappInitializer.d.ts +18 -0
- package/dist/neutral/helpers/registration/DappInitializer.d.ts.map +1 -0
- package/dist/neutral/helpers/registration/index.d.ts +3 -0
- package/dist/neutral/helpers/registration/index.d.ts.map +1 -0
- package/dist/neutral/helpers/registration/useInstallDapp.d.ts +8 -0
- package/dist/neutral/helpers/registration/useInstallDapp.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +2 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +153 -7
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/DappHost.d.ts.map +1 -1
- package/dist/node/helpers/index.d.ts +2 -0
- package/dist/node/helpers/index.d.ts.map +1 -0
- package/dist/node/helpers/registration/DappInitializer.d.ts +18 -0
- package/dist/node/helpers/registration/DappInitializer.d.ts.map +1 -0
- package/dist/node/helpers/registration/index.d.ts +3 -0
- package/dist/node/helpers/registration/index.d.ts.map +1 -0
- package/dist/node/helpers/registration/useInstallDapp.d.ts +8 -0
- package/dist/node/helpers/registration/useInstallDapp.d.ts.map +1 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.mjs +153 -7
- package/dist/node/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/DappHost.tsx +14 -129
- package/src/dapp.stories.tsx +1 -1
- package/src/helpers/index.ts +1 -0
- package/src/helpers/registration/DappInitializer.ts +53 -0
- package/src/helpers/registration/index.ts +2 -0
- package/src/helpers/registration/useInstallDapp.tsx +39 -0
- package/src/index.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DappHost.d.ts","sourceRoot":"","sources":["../../src/DappHost.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DappHost.d.ts","sourceRoot":"","sources":["../../src/DappHost.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtE,OAAO,KAAkB,MAAM,OAAO,CAAA;AAKtC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAgB5C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WindowDappNodeSet, XyOsContext } from '@xyo-network/os-model';
|
|
2
|
+
import type { RegisteredReactDapp } from '@xyo-network/os-react-model';
|
|
3
|
+
export interface DappInitializerConfig {
|
|
4
|
+
allowedNames: string[];
|
|
5
|
+
dapp: RegisteredReactDapp;
|
|
6
|
+
xnsNetwork: string | undefined;
|
|
7
|
+
xnsNodeUrl: string | undefined;
|
|
8
|
+
xyOs: XyOsContext;
|
|
9
|
+
}
|
|
10
|
+
export declare class DappInitializer {
|
|
11
|
+
private _config;
|
|
12
|
+
constructor(config: DappInitializerConfig);
|
|
13
|
+
get config(): DappInitializerConfig;
|
|
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/registration/DappInitializer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtE,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,IAAI,EAAE,mBAAmB,CAAA;IACzB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAuB;gBAE1B,MAAM,EAAE,qBAAqB;IAIzC,IAAI,MAAM,0BAET;IAEK,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;YAM7B,qBAAqB;YAQrB,iBAAiB;CAchC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/helpers/registration/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RegisteredReactDapp } from '@xyo-network/os-react-model';
|
|
2
|
+
export declare const useInitializeDapp: (dapp: RegisteredReactDapp) => {
|
|
3
|
+
context: import("@xyo-network/os-model").XyOsContext | null | undefined;
|
|
4
|
+
dappMenu: import("@xyo-network/os-react-runtime").DappMenuProperties;
|
|
5
|
+
dappWallet: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
6
|
+
errors: (Error | undefined)[];
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useInstallDapp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInstallDapp.d.ts","sourceRoot":"","sources":["../../../../src/helpers/registration/useInstallDapp.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAOtE,eAAO,MAAM,iBAAiB,SAAU,mBAAmB;;;;;CA8B1D,CAAA"}
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { default as accountsDappManifest } from './dapp.manifest.json';
|
|
2
|
+
export * from './DappHost.tsx';
|
|
2
3
|
export * from './Params.ts';
|
|
3
4
|
export * from './Payloads.ts';
|
|
4
5
|
export * from './UiParams.ts';
|
|
6
|
+
export * from './XyOsHost.tsx';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACtE,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACtE,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -33,9 +33,153 @@ var dapp_manifest_default = {
|
|
|
33
33
|
schema: "network.xyo.manifest.package.dapp"
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
// src/DappHost.tsx
|
|
37
|
+
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
|
38
|
+
import { DappRendered } from "@xyo-network/os-react-runtime";
|
|
39
|
+
import React2, { useMemo as useMemo2 } from "react";
|
|
40
|
+
|
|
41
|
+
// src/helpers/registration/DappInitializer.ts
|
|
42
|
+
import { assertEx } from "@xylabs/assert";
|
|
43
|
+
import { DappSeedPhraseRepository, RunningDappCache } from "@xyo-network/os-runtime";
|
|
44
|
+
var DappInitializer = class {
|
|
45
|
+
static {
|
|
46
|
+
__name(this, "DappInitializer");
|
|
47
|
+
}
|
|
48
|
+
_config;
|
|
49
|
+
constructor(config) {
|
|
50
|
+
this._config = config;
|
|
51
|
+
}
|
|
52
|
+
get config() {
|
|
53
|
+
return assertEx(this._config, () => new Error("Options not set"));
|
|
54
|
+
}
|
|
55
|
+
async install() {
|
|
56
|
+
const dappWithWalletId = await this.installDappWallet();
|
|
57
|
+
return await this.initializeDappContext(dappWithWalletId);
|
|
58
|
+
}
|
|
59
|
+
async initializeDappContext(dappWithWalletId) {
|
|
60
|
+
const { allowedNames, xnsNetwork, xnsNodeUrl, xyOs } = this.config;
|
|
61
|
+
return await RunningDappCache.findOrCreate(dappWithWalletId, xyOs, allowedNames ?? [], xnsNodeUrl, xnsNetwork);
|
|
62
|
+
}
|
|
63
|
+
async installDappWallet() {
|
|
64
|
+
const { xyOs, dapp } = this.config;
|
|
65
|
+
const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [
|
|
66
|
+
dapp.config.name
|
|
67
|
+
]);
|
|
68
|
+
const walletId = await dappSeedPhraseRepository.findOrCreate(dapp.config.name);
|
|
69
|
+
return {
|
|
70
|
+
...dapp,
|
|
71
|
+
config: {
|
|
72
|
+
...dapp.config,
|
|
73
|
+
walletId
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/helpers/registration/useInstallDapp.tsx
|
|
80
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
81
|
+
import { useDappMenu, useManageDappInjectableParamsFromRoute, useManageDappPathFromRoute, useXyOsUiContext } from "@xyo-network/os-react-runtime";
|
|
82
|
+
var useInitializeDapp = /* @__PURE__ */ __name((dapp) => {
|
|
83
|
+
const xyOs = useXyOsUiContext();
|
|
84
|
+
const [installedDapp, nodeCreateError] = usePromise(async () => {
|
|
85
|
+
if (xyOs && dapp) {
|
|
86
|
+
const installer = new DappInitializer({
|
|
87
|
+
allowedNames: [
|
|
88
|
+
dapp.config.name
|
|
89
|
+
],
|
|
90
|
+
dapp,
|
|
91
|
+
xnsNetwork: void 0,
|
|
92
|
+
xnsNodeUrl: void 0,
|
|
93
|
+
xyOs
|
|
94
|
+
});
|
|
95
|
+
return await installer.install();
|
|
96
|
+
}
|
|
97
|
+
}, [
|
|
98
|
+
xyOs,
|
|
99
|
+
dapp
|
|
100
|
+
]);
|
|
101
|
+
const { dappWallet, context } = installedDapp ?? {};
|
|
102
|
+
const routingError = useManageDappPathFromRoute(context, dapp.config.name);
|
|
103
|
+
const injectableErrors = useManageDappInjectableParamsFromRoute(context);
|
|
104
|
+
const dappMenu = useDappMenu(context, dapp.config.name);
|
|
105
|
+
return {
|
|
106
|
+
context,
|
|
107
|
+
dappMenu,
|
|
108
|
+
dappWallet,
|
|
109
|
+
errors: [
|
|
110
|
+
routingError,
|
|
111
|
+
nodeCreateError,
|
|
112
|
+
...injectableErrors
|
|
113
|
+
].filter(Boolean)
|
|
114
|
+
};
|
|
115
|
+
}, "useInitializeDapp");
|
|
116
|
+
|
|
117
|
+
// src/XyOsHost.tsx
|
|
118
|
+
import { Typography } from "@mui/material";
|
|
119
|
+
import { FlexCol } from "@xylabs/react-flexbox";
|
|
120
|
+
import { usePromise as usePromise2 } from "@xylabs/react-promise";
|
|
121
|
+
import { HDWallet } from "@xyo-network/account";
|
|
122
|
+
import { Kernel } from "@xyo-network/kernel";
|
|
123
|
+
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
124
|
+
import { XyOsUiContextProvider } from "@xyo-network/os-react-runtime";
|
|
125
|
+
import { EventBus, XyOs } from "@xyo-network/os-runtime";
|
|
126
|
+
import { useMemo } from "react";
|
|
127
|
+
var XyOsHost = /* @__PURE__ */ __name(({ children, eventBus, kernel, locator: locator2, wallet }) => {
|
|
128
|
+
const [walletToUse] = usePromise2(async () => wallet ?? await HDWallet.random(), [
|
|
129
|
+
wallet
|
|
130
|
+
]);
|
|
131
|
+
const eventBusToUse = useMemo(() => eventBus ?? new EventBus(), [
|
|
132
|
+
kernel
|
|
133
|
+
]);
|
|
134
|
+
const kernelToUse = useMemo(() => kernel ?? new Kernel(), [
|
|
135
|
+
kernel
|
|
136
|
+
]);
|
|
137
|
+
const locatorToUse = useMemo(() => locator2 ?? new ModuleFactoryLocator(), [
|
|
138
|
+
locator2
|
|
139
|
+
]);
|
|
140
|
+
const [os, error] = usePromise2(async () => {
|
|
141
|
+
if (walletToUse && kernelToUse && eventBusToUse && locatorToUse) {
|
|
142
|
+
const os2 = new XyOs({
|
|
143
|
+
kernel: kernelToUse,
|
|
144
|
+
eventBus: new EventBus(),
|
|
145
|
+
locator: locatorToUse
|
|
146
|
+
});
|
|
147
|
+
await os2.boot(walletToUse, locatorToUse);
|
|
148
|
+
return os2;
|
|
149
|
+
}
|
|
150
|
+
}, [
|
|
151
|
+
kernelToUse,
|
|
152
|
+
walletToUse,
|
|
153
|
+
locator2,
|
|
154
|
+
eventBusToUse,
|
|
155
|
+
locatorToUse
|
|
156
|
+
]);
|
|
157
|
+
return os ? /* @__PURE__ */ React.createElement(XyOsUiContextProvider, {
|
|
158
|
+
value: os
|
|
159
|
+
}, children) : /* @__PURE__ */ React.createElement(FlexCol, null, /* @__PURE__ */ React.createElement(Typography, null, "wallet:", walletToUse ? "ready" : "loading"), /* @__PURE__ */ React.createElement(Typography, null, "kernel:", kernelToUse ? "ready" : "loading"), /* @__PURE__ */ React.createElement(Typography, null, "os:", os ? "ready" : "loading"), /* @__PURE__ */ React.createElement(Typography, null, "os-error:", error?.message));
|
|
160
|
+
}, "XyOsHost");
|
|
161
|
+
|
|
162
|
+
// src/DappHost.tsx
|
|
163
|
+
var DappHost = /* @__PURE__ */ __name(({ dapp }) => {
|
|
164
|
+
const { context, dappMenu, dappWallet, errors } = useInitializeDapp(dapp);
|
|
165
|
+
const dappState = useMemo2(() => ({
|
|
166
|
+
active: true,
|
|
167
|
+
minimized: false,
|
|
168
|
+
closed: false
|
|
169
|
+
}), []);
|
|
170
|
+
return /* @__PURE__ */ React2.createElement(XyOsHost, null, /* @__PURE__ */ React2.createElement(FlexCol2, null, /* @__PURE__ */ React2.createElement(DappRendered, {
|
|
171
|
+
context,
|
|
172
|
+
dapp,
|
|
173
|
+
dappMenuProperties: dappMenu,
|
|
174
|
+
dappState,
|
|
175
|
+
dappWallet,
|
|
176
|
+
errors
|
|
177
|
+
})));
|
|
178
|
+
}, "DappHost");
|
|
179
|
+
|
|
36
180
|
// src/Params.ts
|
|
37
181
|
import { IndexedDbArchivist } from "@xyo-network/archivist-indexeddb";
|
|
38
|
-
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
182
|
+
import { ModuleFactoryLocator as ModuleFactoryLocator2 } from "@xyo-network/module-factory-locator";
|
|
39
183
|
|
|
40
184
|
// src/icon/Icon.tsx
|
|
41
185
|
var CustomDappIconSvg = `
|
|
@@ -84,7 +228,7 @@ var CustomDappIconSvg = `
|
|
|
84
228
|
`;
|
|
85
229
|
|
|
86
230
|
// src/Params.ts
|
|
87
|
-
var locator = new
|
|
231
|
+
var locator = new ModuleFactoryLocator2();
|
|
88
232
|
locator.register(IndexedDbArchivist);
|
|
89
233
|
var CustomDappParams = {
|
|
90
234
|
iconSvg: CustomDappIconSvg,
|
|
@@ -151,14 +295,14 @@ var CustomDappMenuPayloads = [
|
|
|
151
295
|
// src/window/Dapp.tsx
|
|
152
296
|
import { ErrorRender } from "@xylabs/react-error";
|
|
153
297
|
import { DappPathSwitcher, useAddDappMenuItems } from "@xyo-network/os-react-runtime";
|
|
154
|
-
import
|
|
298
|
+
import React4 from "react";
|
|
155
299
|
|
|
156
300
|
// src/components/Dapp.tsx
|
|
157
301
|
import { FlexRow } from "@xylabs/react-flexbox";
|
|
158
|
-
import
|
|
302
|
+
import React3 from "react";
|
|
159
303
|
var CustomDappPathToComponent = [
|
|
160
304
|
{
|
|
161
|
-
component: /* @__PURE__ */
|
|
305
|
+
component: /* @__PURE__ */ React3.createElement(FlexRow, null),
|
|
162
306
|
path: "home"
|
|
163
307
|
}
|
|
164
308
|
];
|
|
@@ -166,10 +310,10 @@ var CustomDappPathToComponent = [
|
|
|
166
310
|
// src/window/Dapp.tsx
|
|
167
311
|
var CustomDapp = /* @__PURE__ */ __name(() => {
|
|
168
312
|
const { menuConfig, path, error } = useAddDappMenuItems(CustomDappMenuPayloads);
|
|
169
|
-
return /* @__PURE__ */
|
|
313
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(ErrorRender, {
|
|
170
314
|
error,
|
|
171
315
|
scope: "CustomDapp"
|
|
172
|
-
}), /* @__PURE__ */
|
|
316
|
+
}), /* @__PURE__ */ React4.createElement(DappPathSwitcher, {
|
|
173
317
|
activePath: path?.path ?? menuConfig?.defaultPath,
|
|
174
318
|
pathToComponent: CustomDappPathToComponent
|
|
175
319
|
}));
|
|
@@ -191,7 +335,9 @@ export {
|
|
|
191
335
|
CustomDappName,
|
|
192
336
|
CustomDappParams,
|
|
193
337
|
CustomDappUiParams,
|
|
338
|
+
DappHost,
|
|
194
339
|
DappPayloads,
|
|
340
|
+
XyOsHost,
|
|
195
341
|
dapp_manifest_default as accountsDappManifest
|
|
196
342
|
};
|
|
197
343
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dapp.manifest.json","../../src/Params.ts","../../src/icon/Icon.tsx","../../src/Payloads.ts","../../src/window/Dapp.tsx","../../src/components/Dapp.tsx","../../src/UiParams.ts"],"sourcesContent":["{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"0'\",\n \"name\": \"Node\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"1'\",\n \"name\": \"DappArchivist\",\n \"dbName\": \"DappArchivist\",\n \"storeName\": \"payloads\",\n \"schema\": \"network.xyo.archivist.config\",\n \"labels\": {\n \"network.xyo.archivist.persistence.scope\": \"device\"\n }\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest.package.dapp\"\n}","import { IndexedDbArchivist } from '@xyo-network/archivist-indexeddb'\nimport { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'\nimport type { UnregisteredDapp } from '@xyo-network/os-model'\n\nimport { CustomDappIconSvg } from './icon/index.ts'\n\nconst locator = new ModuleFactoryLocator()\nlocator.register(IndexedDbArchivist)\n\nexport const CustomDappParams: UnregisteredDapp['params'] = {\n iconSvg: CustomDappIconSvg,\n locator,\n}\n\nexport { CustomDappParams as default }\n","/* eslint-disable @stylistic/max-len */\nexport const CustomDappIconSvg = `\n<svg id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 40 40\">\n <path\n fill=\"transparent\"\n d=\"M6.44,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M18.01,27.91c-.55.55-.83,1.22-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83s-1.44.28-2,.83Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M33.56,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M36.55,26.94c-.82-.82-1.82-1.23-3-1.23-.32,0-.63.04-.93.11-.3.07-.59.17-.87.31l-5.87-8.09c-.18.03-.36.05-.56.05h-1.13l6.42,8.83c-.39.4-.7.85-.93,1.36-.23.51-.35,1.06-.35,1.66,0,1.18.41,2.17,1.23,3s1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3-.41-2.17-1.23-3ZM35.55,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M19.29,25.73c-1,.16-1.84.64-2.52,1.42-.67.79-1.01,1.7-1.01,2.75,0,1.18.41,2.17,1.23,3,.82.82,1.82,1.23,3,1.23s2.17-.41,3-1.23c.82-.82,1.23-1.82,1.23-3,0-1.05-.34-1.97-1.01-2.74-.67-.78-1.51-1.25-2.52-1.43v-7.65h-1.41v7.65ZM22,27.91c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M14.1,18l-5.89,8.08c-.28-.13-.56-.22-.86-.28-.29-.06-.6-.09-.91-.09-1.18,0-2.17.41-3,1.23-.82.82-1.23,1.82-1.23,3s.41,2.17,1.23,3,1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3c0-.6-.12-1.15-.36-1.66s-.56-.96-.95-1.36l6.45-8.83h-1c-.25,0-.48-.03-.7-.08ZM8.44,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M20,12.91c1.26,0,2.46.19,3.61.56,1.15.37,2.23.88,3.23,1.54V4.86c0-.44-.15-.82-.46-1.12s-.68-.46-1.12-.46h-10.52c-.44,0-.82.15-1.12.46s-.46.68-.46,1.12v10.15c1-.66,2.08-1.17,3.23-1.54s2.36-.56,3.61-.56ZM17.7,5.83c.63-.63,1.4-.95,2.3-.95s1.66.32,2.3.95.95,1.4.95,2.3-.32,1.66-.95,2.3-1.4.95-2.3.95-1.66-.32-2.3-.95-.95-1.4-.95-2.3.32-1.66.95-2.3Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M20,10.32c.6,0,1.12-.21,1.55-.64.43-.43.65-.94.65-1.55s-.22-1.12-.65-1.55c-.43-.43-.95-.65-1.55-.65s-1.12.22-1.55.65-.64.95-.64,1.55.21,1.12.64,1.55.94.64,1.55.64Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M20,11.37c.9,0,1.66-.32,2.3-.95s.95-1.4.95-2.3-.32-1.66-.95-2.3-1.4-.95-2.3-.95-1.66.32-2.3.95-.95,1.4-.95,2.3.32,1.66.95,2.3,1.4.95,2.3.95ZM18.45,6.58c.43-.43.95-.65,1.55-.65s1.12.22,1.55.65c.43.43.65.95.65,1.55s-.22,1.12-.65,1.55c-.43.43-.95.64-1.55.64s-1.12-.21-1.55-.64-.64-.95-.64-1.55.21-1.12.64-1.55Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M27.21,2.9c-.5-.5-1.15-.75-1.95-.75h-10.52c-.8,0-1.45.25-1.95.75-.5.5-.75,1.15-.75,1.95v10.52c0,.8.25,1.45.75,1.95.35.35.77.56,1.25.67.22.05.45.08.7.08h10.52c.2,0,.38-.02.56-.05.55-.09,1.01-.33,1.39-.71.5-.5.75-1.15.75-1.95V4.86c0-.8-.25-1.45-.75-1.95ZM25.93,16.74c-.26.14-.55.22-.86.22h-10.15s-.08-.01-.12-.01c-.25-.02-.5-.08-.74-.2-.28-.14-.45-.35-.5-.63.99-.7,2.03-1.22,3.12-1.57s2.19-.52,3.31-.52,2.27.18,3.4.55c1.13.36,2.18.88,3.16,1.54-.15.27-.36.48-.63.63ZM26.84,15.01c-1-.66-2.08-1.17-3.23-1.54-1.15-.37-2.36-.56-3.61-.56s-2.46.19-3.61.56-2.23.88-3.23,1.54V4.86c0-.44.15-.82.46-1.12s.68-.46,1.12-.46h10.52c.44,0,.82.15,1.12.46s.46.68.46,1.12v10.15Z\"\n />\n </svg>\n `\n","/* eslint-disable @stylistic/max-len */\nimport type {\n DappConfig,\n DappIcon,\n DappName,\n DappNavItem,\n DappNavMenuConfig,\n DappPackageManifestPayload,\n DappVersion,\n} from '@xyo-network/os-model'\nimport {\n DappConfigSchema,\n DappIconSchema,\n DappMode,\n DappNavItemSchema,\n DappNavMenuConfigSchema,\n} from '@xyo-network/os-model'\n\nimport dappManifest from './dapp.manifest.json' assert { type: 'json' }\n\nexport const CustomDappName: DappName = 'Custom Dapp' as const\n\nconst version: DappVersion = '1.0.0'\n\nexport const CustomDappConfig: DappConfig = {\n manifest: dappManifest as DappPackageManifestPayload,\n modes: [DappMode.Window],\n name: CustomDappName,\n schema: DappConfigSchema,\n sources: ['network.xyo.dapp.accounts.source'],\n version,\n}\n\nexport const CustomDappIcon: DappIcon = {\n active: false,\n installed: 'installed',\n name: CustomDappName,\n schema: DappIconSchema,\n type: 'system',\n version,\n}\n\nexport const DappPayloads = [CustomDappConfig, CustomDappIcon]\n\nexport type CustomDappMenuItemPaths = 'home' | 'settings'\n\nconst CustomDappMenuItems: DappNavItem<CustomDappMenuItemPaths>[] = [\n {\n path: 'home',\n primaryText: 'Home',\n schema: DappNavItemSchema,\n svgIcon: `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\" fill=\"none\"><path fill=\"currentColor\" d=\"M420-360h120l-23-129q20-10 31.5-29t11.5-42q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 23 11.5 42t31.5 29l-23 129Zm60 280q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z\"/></svg>\n `,\n weight: 0,\n },\n {\n path: 'settings',\n primaryText: 'Settings',\n schema: DappNavItemSchema,\n svgIcon: `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\" fill=\"none\"><path fill=\"currentColor\" d=\"M420-360h120l-23-129q20-10 31.5-29t11.5-42q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 23 11.5 42t31.5 29l-23 129Zm60 280q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z\"/></svg>\n `,\n weight: 0,\n },\n]\n\nconst CustomDappMenuConfig: DappNavMenuConfig = {\n defaultPath: 'home',\n schema: DappNavMenuConfigSchema,\n}\n\nexport const CustomDappMenuPayloads = [...CustomDappMenuItems, CustomDappMenuConfig]\n","import { ErrorRender } from '@xylabs/react-error'\nimport { DappPathSwitcher, useAddDappMenuItems } from '@xyo-network/os-react-runtime'\nimport React from 'react'\n\nimport { CustomDappPathToComponent } from '../components/index.ts'\nimport { CustomDappMenuPayloads } from '../Payloads.js'\n\nexport const CustomDapp = () => {\n const {\n menuConfig, path, error,\n } = useAddDappMenuItems(CustomDappMenuPayloads)\n\n return (\n <>\n <ErrorRender error={error} scope=\"CustomDapp\" />\n <DappPathSwitcher activePath={path?.path ?? menuConfig?.defaultPath} pathToComponent={CustomDappPathToComponent} />\n </>\n )\n}\n","import { FlexRow } from '@xylabs/react-flexbox'\nimport type { PathToComponent } from '@xyo-network/os-react-runtime'\nimport React from 'react'\n\nexport const CustomDappPathToComponent: PathToComponent[] = [\n {\n component: <FlexRow />,\n path: 'home',\n },\n]\n","import type { UnregisteredReactDapp } from '@xyo-network/os-react-model'\n\nimport { CustomDappParams } from './Params.js'\nimport { CustomDapp } from './window/index.ts'\n\nexport const CustomDappUiParams: UnregisteredReactDapp['params'] = {\n ...CustomDappParams,\n modes: { window: { component: CustomDapp } },\n}\n\nexport { CustomDappUiParams as default }\n"],"mappings":";;;;AAAA;AAAA,EACE,SAAW;AAAA,EACX,OAAS;AAAA,IACP;AAAA,MACE,QAAU;AAAA,QACR,aAAe;AAAA,QACf,MAAQ;AAAA,QACR,QAAU;AAAA,MACZ;AAAA,MACA,SAAW;AAAA,QACT,SAAW,CAAC;AAAA,QACZ,QAAU;AAAA,UACR;AAAA,YACE,QAAU;AAAA,cACR,aAAe;AAAA,cACf,MAAQ;AAAA,cACR,QAAU;AAAA,cACV,WAAa;AAAA,cACb,QAAU;AAAA,cACV,QAAU;AAAA,gBACR,2CAA2C;AAAA,cAC7C;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAU;AACZ;;;AC7BA,SAASA,0BAA0B;AACnC,SAASC,4BAA4B;;;ACA9B,IAAMC,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ADKjC,IAAMC,UAAU,IAAIC,qBAAAA;AACpBD,QAAQE,SAASC,kBAAAA;AAEV,IAAMC,mBAA+C;EAC1DC,SAASC;EACTN;AACF;;;AEFA,SACEO,kBACAC,gBACAC,UACAC,mBACAC,+BACK;AAIA,IAAMC,iBAA2B;AAExC,IAAMC,UAAuB;AAEtB,IAAMC,mBAA+B;EAC1CC,UAAUC;EACVC,OAAO;IAACC,SAASC;;EACjBC,MAAMR;EACNS,QAAQC;EACRC,SAAS;IAAC;;EACVV;AACF;AAEO,IAAMW,iBAA2B;EACtCC,QAAQ;EACRC,WAAW;EACXN,MAAMR;EACNS,QAAQM;EACRC,MAAM;EACNf;AACF;AAEO,IAAMgB,eAAe;EAACf;EAAkBU;;AAI/C,IAAMM,sBAA8D;EAClE;IACEC,MAAM;IACNC,aAAa;IACbX,QAAQY;IACRC,SAAS;;;IAGTC,QAAQ;EACV;EACA;IACEJ,MAAM;IACNC,aAAa;IACbX,QAAQY;IACRC,SAAS;;;IAGTC,QAAQ;EACV;;AAGF,IAAMC,uBAA0C;EAC9CC,aAAa;EACbhB,QAAQiB;AACV;AAEO,IAAMC,yBAAyB;KAAIT;EAAqBM;;;;ACxE/D,SAASI,mBAAmB;AAC5B,SAASC,kBAAkBC,2BAA2B;AACtD,OAAOC,YAAW;;;ACFlB,SAASC,eAAe;AAExB,OAAOC,WAAW;AAEX,IAAMC,4BAA+C;EAC1D;IACEC,WAAW,sBAAA,cAACH,SAAAA,IAAAA;IACZI,MAAM;EACR;;;;ADDK,IAAMC,aAAa,6BAAA;AACxB,QAAM,EACJC,YAAYC,MAAMC,MAAK,IACrBC,oBAAoBC,sBAAAA;AAExB,SACE,gBAAAC,OAAA,cAAAA,OAAA,UAAA,MACE,gBAAAA,OAAA,cAACC,aAAAA;IAAYJ;IAAcK,OAAM;MACjC,gBAAAF,OAAA,cAACG,kBAAAA;IAAiBC,YAAYR,MAAMA,QAAQD,YAAYU;IAAaC,iBAAiBC;;AAG5F,GAX0B;;;AEFnB,IAAMC,qBAAsD;EACjE,GAAGC;EACHC,OAAO;IAAEC,QAAQ;MAAEC,WAAWC;IAAW;EAAE;AAC7C;","names":["IndexedDbArchivist","ModuleFactoryLocator","CustomDappIconSvg","locator","ModuleFactoryLocator","register","IndexedDbArchivist","CustomDappParams","iconSvg","CustomDappIconSvg","DappConfigSchema","DappIconSchema","DappMode","DappNavItemSchema","DappNavMenuConfigSchema","CustomDappName","version","CustomDappConfig","manifest","dappManifest","modes","DappMode","Window","name","schema","DappConfigSchema","sources","CustomDappIcon","active","installed","DappIconSchema","type","DappPayloads","CustomDappMenuItems","path","primaryText","DappNavItemSchema","svgIcon","weight","CustomDappMenuConfig","defaultPath","DappNavMenuConfigSchema","CustomDappMenuPayloads","ErrorRender","DappPathSwitcher","useAddDappMenuItems","React","FlexRow","React","CustomDappPathToComponent","component","path","CustomDapp","menuConfig","path","error","useAddDappMenuItems","CustomDappMenuPayloads","React","ErrorRender","scope","DappPathSwitcher","activePath","defaultPath","pathToComponent","CustomDappPathToComponent","CustomDappUiParams","CustomDappParams","modes","window","component","CustomDapp"]}
|
|
1
|
+
{"version":3,"sources":["../../src/dapp.manifest.json","../../src/DappHost.tsx","../../src/helpers/registration/DappInitializer.ts","../../src/helpers/registration/useInstallDapp.tsx","../../src/XyOsHost.tsx","../../src/Params.ts","../../src/icon/Icon.tsx","../../src/Payloads.ts","../../src/window/Dapp.tsx","../../src/components/Dapp.tsx","../../src/UiParams.ts"],"sourcesContent":["{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"0'\",\n \"name\": \"Node\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"1'\",\n \"name\": \"DappArchivist\",\n \"dbName\": \"DappArchivist\",\n \"storeName\": \"payloads\",\n \"schema\": \"network.xyo.archivist.config\",\n \"labels\": {\n \"network.xyo.archivist.persistence.scope\": \"device\"\n }\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest.package.dapp\"\n}","import { FlexCol } from '@xylabs/react-flexbox'\nimport type { RegisteredReactDapp } from '@xyo-network/os-react-model'\nimport type { DappState } from '@xyo-network/os-react-runtime'\nimport { DappRendered } from '@xyo-network/os-react-runtime'\nimport React, { useMemo } from 'react'\n\nimport { useInitializeDapp } from './helpers/index.ts'\nimport { XyOsHost } from './XyOsHost.tsx'\n\nexport interface DappHostProps {\n dapp: RegisteredReactDapp\n}\n\nexport const DappHost: React.FC<DappHostProps> = ({ dapp }) => {\n const {\n context, dappMenu, dappWallet, errors,\n } = useInitializeDapp(dapp)\n\n const dappState: DappState = useMemo(() => ({\n active: true, minimized: false, closed: false,\n }), [])\n\n return (\n <XyOsHost>\n <FlexCol>\n <DappRendered context={context} dapp={dapp} dappMenuProperties={dappMenu} dappState={dappState} dappWallet={dappWallet} errors={errors} />\n </FlexCol>\n </XyOsHost>\n )\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { WindowDappNodeSet, XyOsContext } from '@xyo-network/os-model'\nimport type { RegisteredReactDapp } from '@xyo-network/os-react-model'\nimport { DappSeedPhraseRepository, RunningDappCache } from '@xyo-network/os-runtime'\n\nexport interface DappInitializerConfig {\n allowedNames: string[]\n dapp: RegisteredReactDapp\n xnsNetwork: string | undefined\n xnsNodeUrl: string | undefined\n xyOs: XyOsContext\n}\n\nexport class DappInitializer {\n private _config: DappInitializerConfig\n\n constructor(config: DappInitializerConfig) {\n this._config = config\n }\n\n get config() {\n return assertEx(this._config, () => new Error('Options not set'))\n }\n\n async install(): Promise<WindowDappNodeSet> {\n const dappWithWalletId = await this.installDappWallet()\n\n return await this.initializeDappContext(dappWithWalletId)\n }\n\n private async initializeDappContext(dappWithWalletId: RegisteredReactDapp): Promise<WindowDappNodeSet> {\n const {\n allowedNames, xnsNetwork, xnsNodeUrl, xyOs,\n } = this.config\n\n return await RunningDappCache.findOrCreate(dappWithWalletId, xyOs, allowedNames ?? [], xnsNodeUrl, xnsNetwork)\n }\n\n private async installDappWallet(): Promise<RegisteredReactDapp> {\n const { xyOs, dapp } = this.config\n const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [dapp.config.name])\n const walletId = await dappSeedPhraseRepository.findOrCreate(dapp.config.name)\n\n // Update the dapp with the walletId\n return {\n ...dapp,\n config: {\n ...dapp.config,\n walletId,\n },\n }\n }\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport type { RegisteredReactDapp } from '@xyo-network/os-react-model'\nimport {\n useDappMenu, useManageDappInjectableParamsFromRoute, useManageDappPathFromRoute, useXyOsUiContext,\n} from '@xyo-network/os-react-runtime'\n\nimport { DappInitializer } from './DappInitializer.ts'\n\nexport const useInitializeDapp = (dapp: RegisteredReactDapp) => {\n const xyOs = useXyOsUiContext()\n\n const [installedDapp, nodeCreateError] = usePromise(async () => {\n if (xyOs && dapp) {\n const installer = new DappInitializer({\n allowedNames: [dapp.config.name],\n dapp,\n xnsNetwork: undefined,\n xnsNodeUrl: undefined,\n xyOs,\n })\n return await installer.install()\n }\n }, [xyOs, dapp])\n\n const { dappWallet, context } = installedDapp ?? {}\n\n // support for routing\n const routingError = useManageDappPathFromRoute(context, dapp.config.name)\n const injectableErrors = useManageDappInjectableParamsFromRoute(context)\n\n const dappMenu = useDappMenu(context, dapp.config.name)\n\n return {\n context,\n dappMenu,\n dappWallet,\n errors: [routingError, nodeCreateError, ...injectableErrors].filter(Boolean),\n }\n}\n","import { Typography } from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { usePromise } from '@xylabs/react-promise'\nimport { HDWallet, type WalletInstance } from '@xyo-network/account'\nimport { Kernel } from '@xyo-network/kernel'\nimport type { KernelExternal } from '@xyo-network/kernel-model'\nimport { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'\nimport { XyOsUiContextProvider } from '@xyo-network/os-react-runtime'\nimport { EventBus, XyOs } from '@xyo-network/os-runtime'\nimport type React from 'react'\nimport { useMemo } from 'react'\n\nexport interface XyOsHostProps {\n children?: React.ReactNode\n eventBus?: EventBus\n kernel?: KernelExternal\n locator?: ModuleFactoryLocator\n wallet?: WalletInstance\n}\n\nexport const XyOsHost: React.FC<XyOsHostProps> = ({\n children, eventBus, kernel, locator, wallet,\n}) => {\n const [walletToUse] = usePromise(async () => wallet ?? await HDWallet.random(), [wallet])\n const eventBusToUse: EventBus = useMemo(() => eventBus ?? new EventBus(), [kernel])\n const kernelToUse: KernelExternal = useMemo(() => kernel ?? new Kernel(), [kernel])\n const locatorToUse = useMemo(() => locator ?? new ModuleFactoryLocator(), [locator])\n\n const [os, error] = usePromise(async () => {\n if (walletToUse && kernelToUse && eventBusToUse && locatorToUse) {\n const os = new XyOs({\n kernel: kernelToUse, eventBus: new EventBus(), locator: locatorToUse,\n })\n await os.boot(walletToUse, locatorToUse)\n return os\n }\n }, [kernelToUse, walletToUse, locator, eventBusToUse, locatorToUse])\n\n return os\n ? <XyOsUiContextProvider value={os}>{children}</XyOsUiContextProvider>\n : (\n <FlexCol>\n <Typography>\n wallet:\n {walletToUse ? 'ready' : 'loading'}\n </Typography>\n <Typography>\n kernel:\n {kernelToUse ? 'ready' : 'loading'}\n </Typography>\n <Typography>\n os:\n {os ? 'ready' : 'loading'}\n </Typography>\n <Typography>\n os-error:\n {error?.message}\n </Typography>\n </FlexCol>\n )\n}\n","import { IndexedDbArchivist } from '@xyo-network/archivist-indexeddb'\nimport { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'\nimport type { UnregisteredDapp } from '@xyo-network/os-model'\n\nimport { CustomDappIconSvg } from './icon/index.ts'\n\nconst locator = new ModuleFactoryLocator()\nlocator.register(IndexedDbArchivist)\n\nexport const CustomDappParams: UnregisteredDapp['params'] = {\n iconSvg: CustomDappIconSvg,\n locator,\n}\n\nexport { CustomDappParams as default }\n","/* eslint-disable @stylistic/max-len */\nexport const CustomDappIconSvg = `\n<svg id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 40 40\">\n <path\n fill=\"transparent\"\n d=\"M6.44,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M18.01,27.91c-.55.55-.83,1.22-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83s-1.44.28-2,.83Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M33.56,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M36.55,26.94c-.82-.82-1.82-1.23-3-1.23-.32,0-.63.04-.93.11-.3.07-.59.17-.87.31l-5.87-8.09c-.18.03-.36.05-.56.05h-1.13l6.42,8.83c-.39.4-.7.85-.93,1.36-.23.51-.35,1.06-.35,1.66,0,1.18.41,2.17,1.23,3s1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3-.41-2.17-1.23-3ZM35.55,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M19.29,25.73c-1,.16-1.84.64-2.52,1.42-.67.79-1.01,1.7-1.01,2.75,0,1.18.41,2.17,1.23,3,.82.82,1.82,1.23,3,1.23s2.17-.41,3-1.23c.82-.82,1.23-1.82,1.23-3,0-1.05-.34-1.97-1.01-2.74-.67-.78-1.51-1.25-2.52-1.43v-7.65h-1.41v7.65ZM22,27.91c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M14.1,18l-5.89,8.08c-.28-.13-.56-.22-.86-.28-.29-.06-.6-.09-.91-.09-1.18,0-2.17.41-3,1.23-.82.82-1.23,1.82-1.23,3s.41,2.17,1.23,3,1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3c0-.6-.12-1.15-.36-1.66s-.56-.96-.95-1.36l6.45-8.83h-1c-.25,0-.48-.03-.7-.08ZM8.44,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M20,12.91c1.26,0,2.46.19,3.61.56,1.15.37,2.23.88,3.23,1.54V4.86c0-.44-.15-.82-.46-1.12s-.68-.46-1.12-.46h-10.52c-.44,0-.82.15-1.12.46s-.46.68-.46,1.12v10.15c1-.66,2.08-1.17,3.23-1.54s2.36-.56,3.61-.56ZM17.7,5.83c.63-.63,1.4-.95,2.3-.95s1.66.32,2.3.95.95,1.4.95,2.3-.32,1.66-.95,2.3-1.4.95-2.3.95-1.66-.32-2.3-.95-.95-1.4-.95-2.3.32-1.66.95-2.3Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M20,10.32c.6,0,1.12-.21,1.55-.64.43-.43.65-.94.65-1.55s-.22-1.12-.65-1.55c-.43-.43-.95-.65-1.55-.65s-1.12.22-1.55.65-.64.95-.64,1.55.21,1.12.64,1.55.94.64,1.55.64Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M20,11.37c.9,0,1.66-.32,2.3-.95s.95-1.4.95-2.3-.32-1.66-.95-2.3-1.4-.95-2.3-.95-1.66.32-2.3.95-.95,1.4-.95,2.3.32,1.66.95,2.3,1.4.95,2.3.95ZM18.45,6.58c.43-.43.95-.65,1.55-.65s1.12.22,1.55.65c.43.43.65.95.65,1.55s-.22,1.12-.65,1.55c-.43.43-.95.64-1.55.64s-1.12-.21-1.55-.64-.64-.95-.64-1.55.21-1.12.64-1.55Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M27.21,2.9c-.5-.5-1.15-.75-1.95-.75h-10.52c-.8,0-1.45.25-1.95.75-.5.5-.75,1.15-.75,1.95v10.52c0,.8.25,1.45.75,1.95.35.35.77.56,1.25.67.22.05.45.08.7.08h10.52c.2,0,.38-.02.56-.05.55-.09,1.01-.33,1.39-.71.5-.5.75-1.15.75-1.95V4.86c0-.8-.25-1.45-.75-1.95ZM25.93,16.74c-.26.14-.55.22-.86.22h-10.15s-.08-.01-.12-.01c-.25-.02-.5-.08-.74-.2-.28-.14-.45-.35-.5-.63.99-.7,2.03-1.22,3.12-1.57s2.19-.52,3.31-.52,2.27.18,3.4.55c1.13.36,2.18.88,3.16,1.54-.15.27-.36.48-.63.63ZM26.84,15.01c-1-.66-2.08-1.17-3.23-1.54-1.15-.37-2.36-.56-3.61-.56s-2.46.19-3.61.56-2.23.88-3.23,1.54V4.86c0-.44.15-.82.46-1.12s.68-.46,1.12-.46h10.52c.44,0,.82.15,1.12.46s.46.68.46,1.12v10.15Z\"\n />\n </svg>\n `\n","/* eslint-disable @stylistic/max-len */\nimport type {\n DappConfig,\n DappIcon,\n DappName,\n DappNavItem,\n DappNavMenuConfig,\n DappPackageManifestPayload,\n DappVersion,\n} from '@xyo-network/os-model'\nimport {\n DappConfigSchema,\n DappIconSchema,\n DappMode,\n DappNavItemSchema,\n DappNavMenuConfigSchema,\n} from '@xyo-network/os-model'\n\nimport dappManifest from './dapp.manifest.json' assert { type: 'json' }\n\nexport const CustomDappName: DappName = 'Custom Dapp' as const\n\nconst version: DappVersion = '1.0.0'\n\nexport const CustomDappConfig: DappConfig = {\n manifest: dappManifest as DappPackageManifestPayload,\n modes: [DappMode.Window],\n name: CustomDappName,\n schema: DappConfigSchema,\n sources: ['network.xyo.dapp.accounts.source'],\n version,\n}\n\nexport const CustomDappIcon: DappIcon = {\n active: false,\n installed: 'installed',\n name: CustomDappName,\n schema: DappIconSchema,\n type: 'system',\n version,\n}\n\nexport const DappPayloads = [CustomDappConfig, CustomDappIcon]\n\nexport type CustomDappMenuItemPaths = 'home' | 'settings'\n\nconst CustomDappMenuItems: DappNavItem<CustomDappMenuItemPaths>[] = [\n {\n path: 'home',\n primaryText: 'Home',\n schema: DappNavItemSchema,\n svgIcon: `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\" fill=\"none\"><path fill=\"currentColor\" d=\"M420-360h120l-23-129q20-10 31.5-29t11.5-42q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 23 11.5 42t31.5 29l-23 129Zm60 280q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z\"/></svg>\n `,\n weight: 0,\n },\n {\n path: 'settings',\n primaryText: 'Settings',\n schema: DappNavItemSchema,\n svgIcon: `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\" fill=\"none\"><path fill=\"currentColor\" d=\"M420-360h120l-23-129q20-10 31.5-29t11.5-42q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 23 11.5 42t31.5 29l-23 129Zm60 280q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z\"/></svg>\n `,\n weight: 0,\n },\n]\n\nconst CustomDappMenuConfig: DappNavMenuConfig = {\n defaultPath: 'home',\n schema: DappNavMenuConfigSchema,\n}\n\nexport const CustomDappMenuPayloads = [...CustomDappMenuItems, CustomDappMenuConfig]\n","import { ErrorRender } from '@xylabs/react-error'\nimport { DappPathSwitcher, useAddDappMenuItems } from '@xyo-network/os-react-runtime'\nimport React from 'react'\n\nimport { CustomDappPathToComponent } from '../components/index.ts'\nimport { CustomDappMenuPayloads } from '../Payloads.js'\n\nexport const CustomDapp = () => {\n const {\n menuConfig, path, error,\n } = useAddDappMenuItems(CustomDappMenuPayloads)\n\n return (\n <>\n <ErrorRender error={error} scope=\"CustomDapp\" />\n <DappPathSwitcher activePath={path?.path ?? menuConfig?.defaultPath} pathToComponent={CustomDappPathToComponent} />\n </>\n )\n}\n","import { FlexRow } from '@xylabs/react-flexbox'\nimport type { PathToComponent } from '@xyo-network/os-react-runtime'\nimport React from 'react'\n\nexport const CustomDappPathToComponent: PathToComponent[] = [\n {\n component: <FlexRow />,\n path: 'home',\n },\n]\n","import type { UnregisteredReactDapp } from '@xyo-network/os-react-model'\n\nimport { CustomDappParams } from './Params.js'\nimport { CustomDapp } from './window/index.ts'\n\nexport const CustomDappUiParams: UnregisteredReactDapp['params'] = {\n ...CustomDappParams,\n modes: { window: { component: CustomDapp } },\n}\n\nexport { CustomDappUiParams as default }\n"],"mappings":";;;;AAAA;AAAA,EACE,SAAW;AAAA,EACX,OAAS;AAAA,IACP;AAAA,MACE,QAAU;AAAA,QACR,aAAe;AAAA,QACf,MAAQ;AAAA,QACR,QAAU;AAAA,MACZ;AAAA,MACA,SAAW;AAAA,QACT,SAAW,CAAC;AAAA,QACZ,QAAU;AAAA,UACR;AAAA,YACE,QAAU;AAAA,cACR,aAAe;AAAA,cACf,MAAQ;AAAA,cACR,QAAU;AAAA,cACV,WAAa;AAAA,cACb,QAAU;AAAA,cACV,QAAU;AAAA,gBACR,2CAA2C;AAAA,cAC7C;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAU;AACZ;;;AC7BA,SAASA,WAAAA,gBAAe;AAGxB,SAASC,oBAAoB;AAC7B,OAAOC,UAASC,WAAAA,gBAAe;;;ACJ/B,SAASC,gBAAgB;AAGzB,SAASC,0BAA0BC,wBAAwB;AAUpD,IAAMC,kBAAN,MAAMA;EAbb,OAaaA;;;EACHC;EAERC,YAAYC,QAA+B;AACzC,SAAKF,UAAUE;EACjB;EAEA,IAAIA,SAAS;AACX,WAAOC,SAAS,KAAKH,SAAS,MAAM,IAA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ACA;IACEJ,MAAM;IACNC,aAAa;IACbX,QAAQY;IACRC,SAAS;;;IAGTC,QAAQ;EACV;;AAGF,IAAMC,uBAA0C;EAC9CC,aAAa;EACbhB,QAAQiB;AACV;AAEO,IAAMC,yBAAyB;KAAIT;EAAqBM;;;;ACxE/D,SAASI,mBAAmB;AAC5B,SAASC,kBAAkBC,2BAA2B;AACtD,OAAOC,YAAW;;;ACFlB,SAASC,eAAe;AAExB,OAAOC,YAAW;AAEX,IAAMC,4BAA+C;EAC1D;IACEC,WAAW,gBAAAF,OAAA,cAACD,SAAAA,IAAAA;IACZI,MAAM;EACR;;;;ADDK,IAAMC,aAAa,6BAAA;AACxB,QAAM,EACJC,YAAYC,MAAMC,MAAK,IACrBC,oBAAoBC,sBAAAA;AAExB,SACE,gBAAAC,OAAA,cAAAA,OAAA,UAAA,MACE,gBAAAA,OAAA,cAACC,aAAAA;IAAYJ;IAAcK,OAAM;MACjC,gBAAAF,OAAA,cAACG,kBAAAA;IAAiBC,YAAYR,MAAMA,QAAQD,YAAYU;IAAaC,iBAAiBC;;AAG5F,GAX0B;;;AEFnB,IAAMC,qBAAsD;EACjE,GAAGC;EACHC,OAAO;IAAEC,QAAQ;MAAEC,WAAWC;IAAW;EAAE;AAC7C;","names":["FlexCol","DappRendered","React","useMemo","assertEx","DappSeedPhraseRepository","RunningDappCache","DappInitializer","_config","constructor","config","assertEx","Error","install","dappWithWalletId","installDappWallet","initializeDappContext","allowedNames","xnsNetwork","xnsNodeUrl","xyOs","RunningDappCache","findOrCreate","dapp","dappSeedPhraseRepository","DappSeedPhraseRepository","name","walletId","usePromise","useDappMenu","useManageDappInjectableParamsFromRoute","useManageDappPathFromRoute","useXyOsUiContext","useInitializeDapp","dapp","xyOs","useXyOsUiContext","installedDapp","nodeCreateError","usePromise","installer","DappInitializer","allowedNames","config","name","xnsNetwork","undefined","xnsNodeUrl","install","dappWallet","context","routingError","useManageDappPathFromRoute","injectableErrors","useManageDappInjectableParamsFromRoute","dappMenu","useDappMenu","errors","filter","Boolean","Typography","FlexCol","usePromise","HDWallet","Kernel","ModuleFactoryLocator","XyOsUiContextProvider","EventBus","XyOs","useMemo","XyOsHost","children","eventBus","kernel","locator","wallet","walletToUse","usePromise","HDWallet","random","eventBusToUse","useMemo","EventBus","kernelToUse","Kernel","locatorToUse","ModuleFactoryLocator","os","error","XyOs","boot","XyOsUiContextProvider","value","FlexCol","Typography","message","DappHost","dapp","context","dappMenu","dappWallet","errors","useInitializeDapp","dappState","useMemo","active","minimized","closed","React","XyOsHost","FlexCol","DappRendered","dappMenuProperties","IndexedDbArchivist","ModuleFactoryLocator","CustomDappIconSvg","locator","ModuleFactoryLocator","register","IndexedDbArchivist","CustomDappParams","iconSvg","CustomDappIconSvg","DappConfigSchema","DappIconSchema","DappMode","DappNavItemSchema","DappNavMenuConfigSchema","CustomDappName","version","CustomDappConfig","manifest","dappManifest","modes","DappMode","Window","name","schema","DappConfigSchema","sources","CustomDappIcon","active","installed","DappIconSchema","type","DappPayloads","CustomDappMenuItems","path","primaryText","DappNavItemSchema","svgIcon","weight","CustomDappMenuConfig","defaultPath","DappNavMenuConfigSchema","CustomDappMenuPayloads","ErrorRender","DappPathSwitcher","useAddDappMenuItems","React","FlexRow","React","CustomDappPathToComponent","component","path","CustomDapp","menuConfig","path","error","useAddDappMenuItems","CustomDappMenuPayloads","React","ErrorRender","scope","DappPathSwitcher","activePath","defaultPath","pathToComponent","CustomDappPathToComponent","CustomDappUiParams","CustomDappParams","modes","window","component","CustomDapp"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DappHost.d.ts","sourceRoot":"","sources":["../../src/DappHost.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DappHost.d.ts","sourceRoot":"","sources":["../../src/DappHost.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtE,OAAO,KAAkB,MAAM,OAAO,CAAA;AAKtC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAgB5C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WindowDappNodeSet, XyOsContext } from '@xyo-network/os-model';
|
|
2
|
+
import type { RegisteredReactDapp } from '@xyo-network/os-react-model';
|
|
3
|
+
export interface DappInitializerConfig {
|
|
4
|
+
allowedNames: string[];
|
|
5
|
+
dapp: RegisteredReactDapp;
|
|
6
|
+
xnsNetwork: string | undefined;
|
|
7
|
+
xnsNodeUrl: string | undefined;
|
|
8
|
+
xyOs: XyOsContext;
|
|
9
|
+
}
|
|
10
|
+
export declare class DappInitializer {
|
|
11
|
+
private _config;
|
|
12
|
+
constructor(config: DappInitializerConfig);
|
|
13
|
+
get config(): DappInitializerConfig;
|
|
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/registration/DappInitializer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtE,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,IAAI,EAAE,mBAAmB,CAAA;IACzB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAuB;gBAE1B,MAAM,EAAE,qBAAqB;IAIzC,IAAI,MAAM,0BAET;IAEK,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;YAM7B,qBAAqB;YAQrB,iBAAiB;CAchC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/helpers/registration/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RegisteredReactDapp } from '@xyo-network/os-react-model';
|
|
2
|
+
export declare const useInitializeDapp: (dapp: RegisteredReactDapp) => {
|
|
3
|
+
context: import("@xyo-network/os-model").XyOsContext | null | undefined;
|
|
4
|
+
dappMenu: import("@xyo-network/os-react-runtime").DappMenuProperties;
|
|
5
|
+
dappWallet: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
6
|
+
errors: (Error | undefined)[];
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useInstallDapp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInstallDapp.d.ts","sourceRoot":"","sources":["../../../../src/helpers/registration/useInstallDapp.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAOtE,eAAO,MAAM,iBAAiB,SAAU,mBAAmB;;;;;CA8B1D,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { default as accountsDappManifest } from './dapp.manifest.json';
|
|
2
|
+
export * from './DappHost.tsx';
|
|
2
3
|
export * from './Params.ts';
|
|
3
4
|
export * from './Payloads.ts';
|
|
4
5
|
export * from './UiParams.ts';
|
|
6
|
+
export * from './XyOsHost.tsx';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACtE,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACtE,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -33,9 +33,153 @@ var dapp_manifest_default = {
|
|
|
33
33
|
schema: "network.xyo.manifest.package.dapp"
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
// src/DappHost.tsx
|
|
37
|
+
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
|
38
|
+
import { DappRendered } from "@xyo-network/os-react-runtime";
|
|
39
|
+
import React2, { useMemo as useMemo2 } from "react";
|
|
40
|
+
|
|
41
|
+
// src/helpers/registration/DappInitializer.ts
|
|
42
|
+
import { assertEx } from "@xylabs/assert";
|
|
43
|
+
import { DappSeedPhraseRepository, RunningDappCache } from "@xyo-network/os-runtime";
|
|
44
|
+
var DappInitializer = class {
|
|
45
|
+
static {
|
|
46
|
+
__name(this, "DappInitializer");
|
|
47
|
+
}
|
|
48
|
+
_config;
|
|
49
|
+
constructor(config) {
|
|
50
|
+
this._config = config;
|
|
51
|
+
}
|
|
52
|
+
get config() {
|
|
53
|
+
return assertEx(this._config, () => new Error("Options not set"));
|
|
54
|
+
}
|
|
55
|
+
async install() {
|
|
56
|
+
const dappWithWalletId = await this.installDappWallet();
|
|
57
|
+
return await this.initializeDappContext(dappWithWalletId);
|
|
58
|
+
}
|
|
59
|
+
async initializeDappContext(dappWithWalletId) {
|
|
60
|
+
const { allowedNames, xnsNetwork, xnsNodeUrl, xyOs } = this.config;
|
|
61
|
+
return await RunningDappCache.findOrCreate(dappWithWalletId, xyOs, allowedNames ?? [], xnsNodeUrl, xnsNetwork);
|
|
62
|
+
}
|
|
63
|
+
async installDappWallet() {
|
|
64
|
+
const { xyOs, dapp } = this.config;
|
|
65
|
+
const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [
|
|
66
|
+
dapp.config.name
|
|
67
|
+
]);
|
|
68
|
+
const walletId = await dappSeedPhraseRepository.findOrCreate(dapp.config.name);
|
|
69
|
+
return {
|
|
70
|
+
...dapp,
|
|
71
|
+
config: {
|
|
72
|
+
...dapp.config,
|
|
73
|
+
walletId
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/helpers/registration/useInstallDapp.tsx
|
|
80
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
81
|
+
import { useDappMenu, useManageDappInjectableParamsFromRoute, useManageDappPathFromRoute, useXyOsUiContext } from "@xyo-network/os-react-runtime";
|
|
82
|
+
var useInitializeDapp = /* @__PURE__ */ __name((dapp) => {
|
|
83
|
+
const xyOs = useXyOsUiContext();
|
|
84
|
+
const [installedDapp, nodeCreateError] = usePromise(async () => {
|
|
85
|
+
if (xyOs && dapp) {
|
|
86
|
+
const installer = new DappInitializer({
|
|
87
|
+
allowedNames: [
|
|
88
|
+
dapp.config.name
|
|
89
|
+
],
|
|
90
|
+
dapp,
|
|
91
|
+
xnsNetwork: void 0,
|
|
92
|
+
xnsNodeUrl: void 0,
|
|
93
|
+
xyOs
|
|
94
|
+
});
|
|
95
|
+
return await installer.install();
|
|
96
|
+
}
|
|
97
|
+
}, [
|
|
98
|
+
xyOs,
|
|
99
|
+
dapp
|
|
100
|
+
]);
|
|
101
|
+
const { dappWallet, context } = installedDapp ?? {};
|
|
102
|
+
const routingError = useManageDappPathFromRoute(context, dapp.config.name);
|
|
103
|
+
const injectableErrors = useManageDappInjectableParamsFromRoute(context);
|
|
104
|
+
const dappMenu = useDappMenu(context, dapp.config.name);
|
|
105
|
+
return {
|
|
106
|
+
context,
|
|
107
|
+
dappMenu,
|
|
108
|
+
dappWallet,
|
|
109
|
+
errors: [
|
|
110
|
+
routingError,
|
|
111
|
+
nodeCreateError,
|
|
112
|
+
...injectableErrors
|
|
113
|
+
].filter(Boolean)
|
|
114
|
+
};
|
|
115
|
+
}, "useInitializeDapp");
|
|
116
|
+
|
|
117
|
+
// src/XyOsHost.tsx
|
|
118
|
+
import { Typography } from "@mui/material";
|
|
119
|
+
import { FlexCol } from "@xylabs/react-flexbox";
|
|
120
|
+
import { usePromise as usePromise2 } from "@xylabs/react-promise";
|
|
121
|
+
import { HDWallet } from "@xyo-network/account";
|
|
122
|
+
import { Kernel } from "@xyo-network/kernel";
|
|
123
|
+
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
124
|
+
import { XyOsUiContextProvider } from "@xyo-network/os-react-runtime";
|
|
125
|
+
import { EventBus, XyOs } from "@xyo-network/os-runtime";
|
|
126
|
+
import { useMemo } from "react";
|
|
127
|
+
var XyOsHost = /* @__PURE__ */ __name(({ children, eventBus, kernel, locator: locator2, wallet }) => {
|
|
128
|
+
const [walletToUse] = usePromise2(async () => wallet ?? await HDWallet.random(), [
|
|
129
|
+
wallet
|
|
130
|
+
]);
|
|
131
|
+
const eventBusToUse = useMemo(() => eventBus ?? new EventBus(), [
|
|
132
|
+
kernel
|
|
133
|
+
]);
|
|
134
|
+
const kernelToUse = useMemo(() => kernel ?? new Kernel(), [
|
|
135
|
+
kernel
|
|
136
|
+
]);
|
|
137
|
+
const locatorToUse = useMemo(() => locator2 ?? new ModuleFactoryLocator(), [
|
|
138
|
+
locator2
|
|
139
|
+
]);
|
|
140
|
+
const [os, error] = usePromise2(async () => {
|
|
141
|
+
if (walletToUse && kernelToUse && eventBusToUse && locatorToUse) {
|
|
142
|
+
const os2 = new XyOs({
|
|
143
|
+
kernel: kernelToUse,
|
|
144
|
+
eventBus: new EventBus(),
|
|
145
|
+
locator: locatorToUse
|
|
146
|
+
});
|
|
147
|
+
await os2.boot(walletToUse, locatorToUse);
|
|
148
|
+
return os2;
|
|
149
|
+
}
|
|
150
|
+
}, [
|
|
151
|
+
kernelToUse,
|
|
152
|
+
walletToUse,
|
|
153
|
+
locator2,
|
|
154
|
+
eventBusToUse,
|
|
155
|
+
locatorToUse
|
|
156
|
+
]);
|
|
157
|
+
return os ? /* @__PURE__ */ React.createElement(XyOsUiContextProvider, {
|
|
158
|
+
value: os
|
|
159
|
+
}, children) : /* @__PURE__ */ React.createElement(FlexCol, null, /* @__PURE__ */ React.createElement(Typography, null, "wallet:", walletToUse ? "ready" : "loading"), /* @__PURE__ */ React.createElement(Typography, null, "kernel:", kernelToUse ? "ready" : "loading"), /* @__PURE__ */ React.createElement(Typography, null, "os:", os ? "ready" : "loading"), /* @__PURE__ */ React.createElement(Typography, null, "os-error:", error?.message));
|
|
160
|
+
}, "XyOsHost");
|
|
161
|
+
|
|
162
|
+
// src/DappHost.tsx
|
|
163
|
+
var DappHost = /* @__PURE__ */ __name(({ dapp }) => {
|
|
164
|
+
const { context, dappMenu, dappWallet, errors } = useInitializeDapp(dapp);
|
|
165
|
+
const dappState = useMemo2(() => ({
|
|
166
|
+
active: true,
|
|
167
|
+
minimized: false,
|
|
168
|
+
closed: false
|
|
169
|
+
}), []);
|
|
170
|
+
return /* @__PURE__ */ React2.createElement(XyOsHost, null, /* @__PURE__ */ React2.createElement(FlexCol2, null, /* @__PURE__ */ React2.createElement(DappRendered, {
|
|
171
|
+
context,
|
|
172
|
+
dapp,
|
|
173
|
+
dappMenuProperties: dappMenu,
|
|
174
|
+
dappState,
|
|
175
|
+
dappWallet,
|
|
176
|
+
errors
|
|
177
|
+
})));
|
|
178
|
+
}, "DappHost");
|
|
179
|
+
|
|
36
180
|
// src/Params.ts
|
|
37
181
|
import { IndexedDbArchivist } from "@xyo-network/archivist-indexeddb";
|
|
38
|
-
import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
|
|
182
|
+
import { ModuleFactoryLocator as ModuleFactoryLocator2 } from "@xyo-network/module-factory-locator";
|
|
39
183
|
|
|
40
184
|
// src/icon/Icon.tsx
|
|
41
185
|
var CustomDappIconSvg = `
|
|
@@ -84,7 +228,7 @@ var CustomDappIconSvg = `
|
|
|
84
228
|
`;
|
|
85
229
|
|
|
86
230
|
// src/Params.ts
|
|
87
|
-
var locator = new
|
|
231
|
+
var locator = new ModuleFactoryLocator2();
|
|
88
232
|
locator.register(IndexedDbArchivist);
|
|
89
233
|
var CustomDappParams = {
|
|
90
234
|
iconSvg: CustomDappIconSvg,
|
|
@@ -151,14 +295,14 @@ var CustomDappMenuPayloads = [
|
|
|
151
295
|
// src/window/Dapp.tsx
|
|
152
296
|
import { ErrorRender } from "@xylabs/react-error";
|
|
153
297
|
import { DappPathSwitcher, useAddDappMenuItems } from "@xyo-network/os-react-runtime";
|
|
154
|
-
import
|
|
298
|
+
import React4 from "react";
|
|
155
299
|
|
|
156
300
|
// src/components/Dapp.tsx
|
|
157
301
|
import { FlexRow } from "@xylabs/react-flexbox";
|
|
158
|
-
import
|
|
302
|
+
import React3 from "react";
|
|
159
303
|
var CustomDappPathToComponent = [
|
|
160
304
|
{
|
|
161
|
-
component: /* @__PURE__ */
|
|
305
|
+
component: /* @__PURE__ */ React3.createElement(FlexRow, null),
|
|
162
306
|
path: "home"
|
|
163
307
|
}
|
|
164
308
|
];
|
|
@@ -166,10 +310,10 @@ var CustomDappPathToComponent = [
|
|
|
166
310
|
// src/window/Dapp.tsx
|
|
167
311
|
var CustomDapp = /* @__PURE__ */ __name(() => {
|
|
168
312
|
const { menuConfig, path, error } = useAddDappMenuItems(CustomDappMenuPayloads);
|
|
169
|
-
return /* @__PURE__ */
|
|
313
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(ErrorRender, {
|
|
170
314
|
error,
|
|
171
315
|
scope: "CustomDapp"
|
|
172
|
-
}), /* @__PURE__ */
|
|
316
|
+
}), /* @__PURE__ */ React4.createElement(DappPathSwitcher, {
|
|
173
317
|
activePath: path?.path ?? menuConfig?.defaultPath,
|
|
174
318
|
pathToComponent: CustomDappPathToComponent
|
|
175
319
|
}));
|
|
@@ -191,7 +335,9 @@ export {
|
|
|
191
335
|
CustomDappName,
|
|
192
336
|
CustomDappParams,
|
|
193
337
|
CustomDappUiParams,
|
|
338
|
+
DappHost,
|
|
194
339
|
DappPayloads,
|
|
340
|
+
XyOsHost,
|
|
195
341
|
dapp_manifest_default as accountsDappManifest
|
|
196
342
|
};
|
|
197
343
|
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dapp.manifest.json","../../src/Params.ts","../../src/icon/Icon.tsx","../../src/Payloads.ts","../../src/window/Dapp.tsx","../../src/components/Dapp.tsx","../../src/UiParams.ts"],"sourcesContent":["{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"0'\",\n \"name\": \"Node\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"1'\",\n \"name\": \"DappArchivist\",\n \"dbName\": \"DappArchivist\",\n \"storeName\": \"payloads\",\n \"schema\": \"network.xyo.archivist.config\",\n \"labels\": {\n \"network.xyo.archivist.persistence.scope\": \"device\"\n }\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest.package.dapp\"\n}","import { IndexedDbArchivist } from '@xyo-network/archivist-indexeddb'\nimport { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'\nimport type { UnregisteredDapp } from '@xyo-network/os-model'\n\nimport { CustomDappIconSvg } from './icon/index.ts'\n\nconst locator = new ModuleFactoryLocator()\nlocator.register(IndexedDbArchivist)\n\nexport const CustomDappParams: UnregisteredDapp['params'] = {\n iconSvg: CustomDappIconSvg,\n locator,\n}\n\nexport { CustomDappParams as default }\n","/* eslint-disable @stylistic/max-len */\nexport const CustomDappIconSvg = `\n<svg id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 40 40\">\n <path\n fill=\"transparent\"\n d=\"M6.44,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M18.01,27.91c-.55.55-.83,1.22-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83s-1.44.28-2,.83Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M33.56,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M36.55,26.94c-.82-.82-1.82-1.23-3-1.23-.32,0-.63.04-.93.11-.3.07-.59.17-.87.31l-5.87-8.09c-.18.03-.36.05-.56.05h-1.13l6.42,8.83c-.39.4-.7.85-.93,1.36-.23.51-.35,1.06-.35,1.66,0,1.18.41,2.17,1.23,3s1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3-.41-2.17-1.23-3ZM35.55,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M19.29,25.73c-1,.16-1.84.64-2.52,1.42-.67.79-1.01,1.7-1.01,2.75,0,1.18.41,2.17,1.23,3,.82.82,1.82,1.23,3,1.23s2.17-.41,3-1.23c.82-.82,1.23-1.82,1.23-3,0-1.05-.34-1.97-1.01-2.74-.67-.78-1.51-1.25-2.52-1.43v-7.65h-1.41v7.65ZM22,27.91c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M14.1,18l-5.89,8.08c-.28-.13-.56-.22-.86-.28-.29-.06-.6-.09-.91-.09-1.18,0-2.17.41-3,1.23-.82.82-1.23,1.82-1.23,3s.41,2.17,1.23,3,1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3c0-.6-.12-1.15-.36-1.66s-.56-.96-.95-1.36l6.45-8.83h-1c-.25,0-.48-.03-.7-.08ZM8.44,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M20,12.91c1.26,0,2.46.19,3.61.56,1.15.37,2.23.88,3.23,1.54V4.86c0-.44-.15-.82-.46-1.12s-.68-.46-1.12-.46h-10.52c-.44,0-.82.15-1.12.46s-.46.68-.46,1.12v10.15c1-.66,2.08-1.17,3.23-1.54s2.36-.56,3.61-.56ZM17.7,5.83c.63-.63,1.4-.95,2.3-.95s1.66.32,2.3.95.95,1.4.95,2.3-.32,1.66-.95,2.3-1.4.95-2.3.95-1.66-.32-2.3-.95-.95-1.4-.95-2.3.32-1.66.95-2.3Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M20,10.32c.6,0,1.12-.21,1.55-.64.43-.43.65-.94.65-1.55s-.22-1.12-.65-1.55c-.43-.43-.95-.65-1.55-.65s-1.12.22-1.55.65-.64.95-.64,1.55.21,1.12.64,1.55.94.64,1.55.64Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M20,11.37c.9,0,1.66-.32,2.3-.95s.95-1.4.95-2.3-.32-1.66-.95-2.3-1.4-.95-2.3-.95-1.66.32-2.3.95-.95,1.4-.95,2.3.32,1.66.95,2.3,1.4.95,2.3.95ZM18.45,6.58c.43-.43.95-.65,1.55-.65s1.12.22,1.55.65c.43.43.65.95.65,1.55s-.22,1.12-.65,1.55c-.43.43-.95.64-1.55.64s-1.12-.21-1.55-.64-.64-.95-.64-1.55.21-1.12.64-1.55Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M27.21,2.9c-.5-.5-1.15-.75-1.95-.75h-10.52c-.8,0-1.45.25-1.95.75-.5.5-.75,1.15-.75,1.95v10.52c0,.8.25,1.45.75,1.95.35.35.77.56,1.25.67.22.05.45.08.7.08h10.52c.2,0,.38-.02.56-.05.55-.09,1.01-.33,1.39-.71.5-.5.75-1.15.75-1.95V4.86c0-.8-.25-1.45-.75-1.95ZM25.93,16.74c-.26.14-.55.22-.86.22h-10.15s-.08-.01-.12-.01c-.25-.02-.5-.08-.74-.2-.28-.14-.45-.35-.5-.63.99-.7,2.03-1.22,3.12-1.57s2.19-.52,3.31-.52,2.27.18,3.4.55c1.13.36,2.18.88,3.16,1.54-.15.27-.36.48-.63.63ZM26.84,15.01c-1-.66-2.08-1.17-3.23-1.54-1.15-.37-2.36-.56-3.61-.56s-2.46.19-3.61.56-2.23.88-3.23,1.54V4.86c0-.44.15-.82.46-1.12s.68-.46,1.12-.46h10.52c.44,0,.82.15,1.12.46s.46.68.46,1.12v10.15Z\"\n />\n </svg>\n `\n","/* eslint-disable @stylistic/max-len */\nimport type {\n DappConfig,\n DappIcon,\n DappName,\n DappNavItem,\n DappNavMenuConfig,\n DappPackageManifestPayload,\n DappVersion,\n} from '@xyo-network/os-model'\nimport {\n DappConfigSchema,\n DappIconSchema,\n DappMode,\n DappNavItemSchema,\n DappNavMenuConfigSchema,\n} from '@xyo-network/os-model'\n\nimport dappManifest from './dapp.manifest.json' assert { type: 'json' }\n\nexport const CustomDappName: DappName = 'Custom Dapp' as const\n\nconst version: DappVersion = '1.0.0'\n\nexport const CustomDappConfig: DappConfig = {\n manifest: dappManifest as DappPackageManifestPayload,\n modes: [DappMode.Window],\n name: CustomDappName,\n schema: DappConfigSchema,\n sources: ['network.xyo.dapp.accounts.source'],\n version,\n}\n\nexport const CustomDappIcon: DappIcon = {\n active: false,\n installed: 'installed',\n name: CustomDappName,\n schema: DappIconSchema,\n type: 'system',\n version,\n}\n\nexport const DappPayloads = [CustomDappConfig, CustomDappIcon]\n\nexport type CustomDappMenuItemPaths = 'home' | 'settings'\n\nconst CustomDappMenuItems: DappNavItem<CustomDappMenuItemPaths>[] = [\n {\n path: 'home',\n primaryText: 'Home',\n schema: DappNavItemSchema,\n svgIcon: `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\" fill=\"none\"><path fill=\"currentColor\" d=\"M420-360h120l-23-129q20-10 31.5-29t11.5-42q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 23 11.5 42t31.5 29l-23 129Zm60 280q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z\"/></svg>\n `,\n weight: 0,\n },\n {\n path: 'settings',\n primaryText: 'Settings',\n schema: DappNavItemSchema,\n svgIcon: `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\" fill=\"none\"><path fill=\"currentColor\" d=\"M420-360h120l-23-129q20-10 31.5-29t11.5-42q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 23 11.5 42t31.5 29l-23 129Zm60 280q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z\"/></svg>\n `,\n weight: 0,\n },\n]\n\nconst CustomDappMenuConfig: DappNavMenuConfig = {\n defaultPath: 'home',\n schema: DappNavMenuConfigSchema,\n}\n\nexport const CustomDappMenuPayloads = [...CustomDappMenuItems, CustomDappMenuConfig]\n","import { ErrorRender } from '@xylabs/react-error'\nimport { DappPathSwitcher, useAddDappMenuItems } from '@xyo-network/os-react-runtime'\nimport React from 'react'\n\nimport { CustomDappPathToComponent } from '../components/index.ts'\nimport { CustomDappMenuPayloads } from '../Payloads.js'\n\nexport const CustomDapp = () => {\n const {\n menuConfig, path, error,\n } = useAddDappMenuItems(CustomDappMenuPayloads)\n\n return (\n <>\n <ErrorRender error={error} scope=\"CustomDapp\" />\n <DappPathSwitcher activePath={path?.path ?? menuConfig?.defaultPath} pathToComponent={CustomDappPathToComponent} />\n </>\n )\n}\n","import { FlexRow } from '@xylabs/react-flexbox'\nimport type { PathToComponent } from '@xyo-network/os-react-runtime'\nimport React from 'react'\n\nexport const CustomDappPathToComponent: PathToComponent[] = [\n {\n component: <FlexRow />,\n path: 'home',\n },\n]\n","import type { UnregisteredReactDapp } from '@xyo-network/os-react-model'\n\nimport { CustomDappParams } from './Params.js'\nimport { CustomDapp } from './window/index.ts'\n\nexport const CustomDappUiParams: UnregisteredReactDapp['params'] = {\n ...CustomDappParams,\n modes: { window: { component: CustomDapp } },\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;EACV;;AAGF,IAAMC,uBAA0C;EAC9CC,aAAa;EACbhB,QAAQiB;AACV;AAEO,IAAMC,yBAAyB;KAAIT;EAAqBM;;;;ACxE/D,SAASI,mBAAmB;AAC5B,SAASC,kBAAkBC,2BAA2B;AACtD,OAAOC,YAAW;;;ACFlB,SAASC,eAAe;AAExB,OAAOC,WAAW;AAEX,IAAMC,4BAA+C;EAC1D;IACEC,WAAW,sBAAA,cAACH,SAAAA,IAAAA;IACZI,MAAM;EACR;;;;ADDK,IAAMC,aAAa,6BAAA;AACxB,QAAM,EACJC,YAAYC,MAAMC,MAAK,IACrBC,oBAAoBC,sBAAAA;AAExB,SACE,gBAAAC,OAAA,cAAAA,OAAA,UAAA,MACE,gBAAAA,OAAA,cAACC,aAAAA;IAAYJ;IAAcK,OAAM;MACjC,gBAAAF,OAAA,cAACG,kBAAAA;IAAiBC,YAAYR,MAAMA,QAAQD,YAAYU;IAAaC,iBAAiBC;;AAG5F,GAX0B;;;AEFnB,IAAMC,qBAAsD;EACjE,GAAGC;EACHC,OAAO;IAAEC,QAAQ;MAAEC,WAAWC;IAAW;EAAE;AAC7C;","names":["IndexedDbArchivist","ModuleFactoryLocator","CustomDappIconSvg","locator","ModuleFactoryLocator","register","IndexedDbArchivist","CustomDappParams","iconSvg","CustomDappIconSvg","DappConfigSchema","DappIconSchema","DappMode","DappNavItemSchema","DappNavMenuConfigSchema","CustomDappName","version","CustomDappConfig","manifest","dappManifest","modes","DappMode","Window","name","schema","DappConfigSchema","sources","CustomDappIcon","active","installed","DappIconSchema","type","DappPayloads","CustomDappMenuItems","path","primaryText","DappNavItemSchema","svgIcon","weight","CustomDappMenuConfig","defaultPath","DappNavMenuConfigSchema","CustomDappMenuPayloads","ErrorRender","DappPathSwitcher","useAddDappMenuItems","React","FlexRow","React","CustomDappPathToComponent","component","path","CustomDapp","menuConfig","path","error","useAddDappMenuItems","CustomDappMenuPayloads","React","ErrorRender","scope","DappPathSwitcher","activePath","defaultPath","pathToComponent","CustomDappPathToComponent","CustomDappUiParams","CustomDappParams","modes","window","component","CustomDapp"]}
|
|
1
|
+
{"version":3,"sources":["../../src/dapp.manifest.json","../../src/DappHost.tsx","../../src/helpers/registration/DappInitializer.ts","../../src/helpers/registration/useInstallDapp.tsx","../../src/XyOsHost.tsx","../../src/Params.ts","../../src/icon/Icon.tsx","../../src/Payloads.ts","../../src/window/Dapp.tsx","../../src/components/Dapp.tsx","../../src/UiParams.ts"],"sourcesContent":["{\n \"$schema\": \"https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json\",\n \"nodes\": [\n {\n \"config\": {\n \"accountPath\": \"0'\",\n \"name\": \"Node\",\n \"schema\": \"network.xyo.node.config\"\n },\n \"modules\": {\n \"private\": [],\n \"public\": [\n {\n \"config\": {\n \"accountPath\": \"1'\",\n \"name\": \"DappArchivist\",\n \"dbName\": \"DappArchivist\",\n \"storeName\": \"payloads\",\n \"schema\": \"network.xyo.archivist.config\",\n \"labels\": {\n \"network.xyo.archivist.persistence.scope\": \"device\"\n }\n }\n }\n ]\n }\n }\n ],\n \"schema\": \"network.xyo.manifest.package.dapp\"\n}","import { FlexCol } from '@xylabs/react-flexbox'\nimport type { RegisteredReactDapp } from '@xyo-network/os-react-model'\nimport type { DappState } from '@xyo-network/os-react-runtime'\nimport { DappRendered } from '@xyo-network/os-react-runtime'\nimport React, { useMemo } from 'react'\n\nimport { useInitializeDapp } from './helpers/index.ts'\nimport { XyOsHost } from './XyOsHost.tsx'\n\nexport interface DappHostProps {\n dapp: RegisteredReactDapp\n}\n\nexport const DappHost: React.FC<DappHostProps> = ({ dapp }) => {\n const {\n context, dappMenu, dappWallet, errors,\n } = useInitializeDapp(dapp)\n\n const dappState: DappState = useMemo(() => ({\n active: true, minimized: false, closed: false,\n }), [])\n\n return (\n <XyOsHost>\n <FlexCol>\n <DappRendered context={context} dapp={dapp} dappMenuProperties={dappMenu} dappState={dappState} dappWallet={dappWallet} errors={errors} />\n </FlexCol>\n </XyOsHost>\n )\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { WindowDappNodeSet, XyOsContext } from '@xyo-network/os-model'\nimport type { RegisteredReactDapp } from '@xyo-network/os-react-model'\nimport { DappSeedPhraseRepository, RunningDappCache } from '@xyo-network/os-runtime'\n\nexport interface DappInitializerConfig {\n allowedNames: string[]\n dapp: RegisteredReactDapp\n xnsNetwork: string | undefined\n xnsNodeUrl: string | undefined\n xyOs: XyOsContext\n}\n\nexport class DappInitializer {\n private _config: DappInitializerConfig\n\n constructor(config: DappInitializerConfig) {\n this._config = config\n }\n\n get config() {\n return assertEx(this._config, () => new Error('Options not set'))\n }\n\n async install(): Promise<WindowDappNodeSet> {\n const dappWithWalletId = await this.installDappWallet()\n\n return await this.initializeDappContext(dappWithWalletId)\n }\n\n private async initializeDappContext(dappWithWalletId: RegisteredReactDapp): Promise<WindowDappNodeSet> {\n const {\n allowedNames, xnsNetwork, xnsNodeUrl, xyOs,\n } = this.config\n\n return await RunningDappCache.findOrCreate(dappWithWalletId, xyOs, allowedNames ?? [], xnsNodeUrl, xnsNetwork)\n }\n\n private async installDappWallet(): Promise<RegisteredReactDapp> {\n const { xyOs, dapp } = this.config\n const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [dapp.config.name])\n const walletId = await dappSeedPhraseRepository.findOrCreate(dapp.config.name)\n\n // Update the dapp with the walletId\n return {\n ...dapp,\n config: {\n ...dapp.config,\n walletId,\n },\n }\n }\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport type { RegisteredReactDapp } from '@xyo-network/os-react-model'\nimport {\n useDappMenu, useManageDappInjectableParamsFromRoute, useManageDappPathFromRoute, useXyOsUiContext,\n} from '@xyo-network/os-react-runtime'\n\nimport { DappInitializer } from './DappInitializer.ts'\n\nexport const useInitializeDapp = (dapp: RegisteredReactDapp) => {\n const xyOs = useXyOsUiContext()\n\n const [installedDapp, nodeCreateError] = usePromise(async () => {\n if (xyOs && dapp) {\n const installer = new DappInitializer({\n allowedNames: [dapp.config.name],\n dapp,\n xnsNetwork: undefined,\n xnsNodeUrl: undefined,\n xyOs,\n })\n return await installer.install()\n }\n }, [xyOs, dapp])\n\n const { dappWallet, context } = installedDapp ?? {}\n\n // support for routing\n const routingError = useManageDappPathFromRoute(context, dapp.config.name)\n const injectableErrors = useManageDappInjectableParamsFromRoute(context)\n\n const dappMenu = useDappMenu(context, dapp.config.name)\n\n return {\n context,\n dappMenu,\n dappWallet,\n errors: [routingError, nodeCreateError, ...injectableErrors].filter(Boolean),\n }\n}\n","import { Typography } from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { usePromise } from '@xylabs/react-promise'\nimport { HDWallet, type WalletInstance } from '@xyo-network/account'\nimport { Kernel } from '@xyo-network/kernel'\nimport type { KernelExternal } from '@xyo-network/kernel-model'\nimport { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'\nimport { XyOsUiContextProvider } from '@xyo-network/os-react-runtime'\nimport { EventBus, XyOs } from '@xyo-network/os-runtime'\nimport type React from 'react'\nimport { useMemo } from 'react'\n\nexport interface XyOsHostProps {\n children?: React.ReactNode\n eventBus?: EventBus\n kernel?: KernelExternal\n locator?: ModuleFactoryLocator\n wallet?: WalletInstance\n}\n\nexport const XyOsHost: React.FC<XyOsHostProps> = ({\n children, eventBus, kernel, locator, wallet,\n}) => {\n const [walletToUse] = usePromise(async () => wallet ?? await HDWallet.random(), [wallet])\n const eventBusToUse: EventBus = useMemo(() => eventBus ?? new EventBus(), [kernel])\n const kernelToUse: KernelExternal = useMemo(() => kernel ?? new Kernel(), [kernel])\n const locatorToUse = useMemo(() => locator ?? new ModuleFactoryLocator(), [locator])\n\n const [os, error] = usePromise(async () => {\n if (walletToUse && kernelToUse && eventBusToUse && locatorToUse) {\n const os = new XyOs({\n kernel: kernelToUse, eventBus: new EventBus(), locator: locatorToUse,\n })\n await os.boot(walletToUse, locatorToUse)\n return os\n }\n }, [kernelToUse, walletToUse, locator, eventBusToUse, locatorToUse])\n\n return os\n ? <XyOsUiContextProvider value={os}>{children}</XyOsUiContextProvider>\n : (\n <FlexCol>\n <Typography>\n wallet:\n {walletToUse ? 'ready' : 'loading'}\n </Typography>\n <Typography>\n kernel:\n {kernelToUse ? 'ready' : 'loading'}\n </Typography>\n <Typography>\n os:\n {os ? 'ready' : 'loading'}\n </Typography>\n <Typography>\n os-error:\n {error?.message}\n </Typography>\n </FlexCol>\n )\n}\n","import { IndexedDbArchivist } from '@xyo-network/archivist-indexeddb'\nimport { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'\nimport type { UnregisteredDapp } from '@xyo-network/os-model'\n\nimport { CustomDappIconSvg } from './icon/index.ts'\n\nconst locator = new ModuleFactoryLocator()\nlocator.register(IndexedDbArchivist)\n\nexport const CustomDappParams: UnregisteredDapp['params'] = {\n iconSvg: CustomDappIconSvg,\n locator,\n}\n\nexport { CustomDappParams as default }\n","/* eslint-disable @stylistic/max-len */\nexport const CustomDappIconSvg = `\n<svg id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 40 40\">\n <path\n fill=\"transparent\"\n d=\"M6.44,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M18.01,27.91c-.55.55-.83,1.22-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83s-1.44.28-2,.83Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M33.56,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M36.55,26.94c-.82-.82-1.82-1.23-3-1.23-.32,0-.63.04-.93.11-.3.07-.59.17-.87.31l-5.87-8.09c-.18.03-.36.05-.56.05h-1.13l6.42,8.83c-.39.4-.7.85-.93,1.36-.23.51-.35,1.06-.35,1.66,0,1.18.41,2.17,1.23,3s1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3-.41-2.17-1.23-3ZM35.55,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M19.29,25.73c-1,.16-1.84.64-2.52,1.42-.67.79-1.01,1.7-1.01,2.75,0,1.18.41,2.17,1.23,3,.82.82,1.82,1.23,3,1.23s2.17-.41,3-1.23c.82-.82,1.23-1.82,1.23-3,0-1.05-.34-1.97-1.01-2.74-.67-.78-1.51-1.25-2.52-1.43v-7.65h-1.41v7.65ZM22,27.91c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M14.1,18l-5.89,8.08c-.28-.13-.56-.22-.86-.28-.29-.06-.6-.09-.91-.09-1.18,0-2.17.41-3,1.23-.82.82-1.23,1.82-1.23,3s.41,2.17,1.23,3,1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3c0-.6-.12-1.15-.36-1.66s-.56-.96-.95-1.36l6.45-8.83h-1c-.25,0-.48-.03-.7-.08ZM8.44,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M20,12.91c1.26,0,2.46.19,3.61.56,1.15.37,2.23.88,3.23,1.54V4.86c0-.44-.15-.82-.46-1.12s-.68-.46-1.12-.46h-10.52c-.44,0-.82.15-1.12.46s-.46.68-.46,1.12v10.15c1-.66,2.08-1.17,3.23-1.54s2.36-.56,3.61-.56ZM17.7,5.83c.63-.63,1.4-.95,2.3-.95s1.66.32,2.3.95.95,1.4.95,2.3-.32,1.66-.95,2.3-1.4.95-2.3.95-1.66-.32-2.3-.95-.95-1.4-.95-2.3.32-1.66.95-2.3Z\"\n />\n <path\n fill=\"transparent\"\n d=\"M20,10.32c.6,0,1.12-.21,1.55-.64.43-.43.65-.94.65-1.55s-.22-1.12-.65-1.55c-.43-.43-.95-.65-1.55-.65s-1.12.22-1.55.65-.64.95-.64,1.55.21,1.12.64,1.55.94.64,1.55.64Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M20,11.37c.9,0,1.66-.32,2.3-.95s.95-1.4.95-2.3-.32-1.66-.95-2.3-1.4-.95-2.3-.95-1.66.32-2.3.95-.95,1.4-.95,2.3.32,1.66.95,2.3,1.4.95,2.3.95ZM18.45,6.58c.43-.43.95-.65,1.55-.65s1.12.22,1.55.65c.43.43.65.95.65,1.55s-.22,1.12-.65,1.55c-.43.43-.95.64-1.55.64s-1.12-.21-1.55-.64-.64-.95-.64-1.55.21-1.12.64-1.55Z\"\n />\n <path\n fill=\"currentColor\"\n d=\"M27.21,2.9c-.5-.5-1.15-.75-1.95-.75h-10.52c-.8,0-1.45.25-1.95.75-.5.5-.75,1.15-.75,1.95v10.52c0,.8.25,1.45.75,1.95.35.35.77.56,1.25.67.22.05.45.08.7.08h10.52c.2,0,.38-.02.56-.05.55-.09,1.01-.33,1.39-.71.5-.5.75-1.15.75-1.95V4.86c0-.8-.25-1.45-.75-1.95ZM25.93,16.74c-.26.14-.55.22-.86.22h-10.15s-.08-.01-.12-.01c-.25-.02-.5-.08-.74-.2-.28-.14-.45-.35-.5-.63.99-.7,2.03-1.22,3.12-1.57s2.19-.52,3.31-.52,2.27.18,3.4.55c1.13.36,2.18.88,3.16,1.54-.15.27-.36.48-.63.63ZM26.84,15.01c-1-.66-2.08-1.17-3.23-1.54-1.15-.37-2.36-.56-3.61-.56s-2.46.19-3.61.56-2.23.88-3.23,1.54V4.86c0-.44.15-.82.46-1.12s.68-.46,1.12-.46h10.52c.44,0,.82.15,1.12.46s.46.68.46,1.12v10.15Z\"\n />\n </svg>\n `\n","/* eslint-disable @stylistic/max-len */\nimport type {\n DappConfig,\n DappIcon,\n DappName,\n DappNavItem,\n DappNavMenuConfig,\n DappPackageManifestPayload,\n DappVersion,\n} from '@xyo-network/os-model'\nimport {\n DappConfigSchema,\n DappIconSchema,\n DappMode,\n DappNavItemSchema,\n DappNavMenuConfigSchema,\n} from '@xyo-network/os-model'\n\nimport dappManifest from './dapp.manifest.json' assert { type: 'json' }\n\nexport const CustomDappName: DappName = 'Custom Dapp' as const\n\nconst version: DappVersion = '1.0.0'\n\nexport const CustomDappConfig: DappConfig = {\n manifest: dappManifest as DappPackageManifestPayload,\n modes: [DappMode.Window],\n name: CustomDappName,\n schema: DappConfigSchema,\n sources: ['network.xyo.dapp.accounts.source'],\n version,\n}\n\nexport const CustomDappIcon: DappIcon = {\n active: false,\n installed: 'installed',\n name: CustomDappName,\n schema: DappIconSchema,\n type: 'system',\n version,\n}\n\nexport const DappPayloads = [CustomDappConfig, CustomDappIcon]\n\nexport type CustomDappMenuItemPaths = 'home' | 'settings'\n\nconst CustomDappMenuItems: DappNavItem<CustomDappMenuItemPaths>[] = [\n {\n path: 'home',\n primaryText: 'Home',\n schema: DappNavItemSchema,\n svgIcon: `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\" fill=\"none\"><path fill=\"currentColor\" d=\"M420-360h120l-23-129q20-10 31.5-29t11.5-42q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 23 11.5 42t31.5 29l-23 129Zm60 280q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z\"/></svg>\n `,\n weight: 0,\n },\n {\n path: 'settings',\n primaryText: 'Settings',\n schema: DappNavItemSchema,\n svgIcon: `\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\" fill=\"none\"><path fill=\"currentColor\" d=\"M420-360h120l-23-129q20-10 31.5-29t11.5-42q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 23 11.5 42t31.5 29l-23 129Zm60 280q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z\"/></svg>\n `,\n weight: 0,\n },\n]\n\nconst CustomDappMenuConfig: DappNavMenuConfig = {\n defaultPath: 'home',\n schema: DappNavMenuConfigSchema,\n}\n\nexport const CustomDappMenuPayloads = [...CustomDappMenuItems, CustomDappMenuConfig]\n","import { ErrorRender } from '@xylabs/react-error'\nimport { DappPathSwitcher, useAddDappMenuItems } from '@xyo-network/os-react-runtime'\nimport React from 'react'\n\nimport { CustomDappPathToComponent } from '../components/index.ts'\nimport { CustomDappMenuPayloads } from '../Payloads.js'\n\nexport const CustomDapp = () => {\n const {\n menuConfig, path, error,\n } = useAddDappMenuItems(CustomDappMenuPayloads)\n\n return (\n <>\n <ErrorRender error={error} scope=\"CustomDapp\" />\n <DappPathSwitcher activePath={path?.path ?? menuConfig?.defaultPath} pathToComponent={CustomDappPathToComponent} />\n </>\n )\n}\n","import { FlexRow } from '@xylabs/react-flexbox'\nimport type { PathToComponent } from '@xyo-network/os-react-runtime'\nimport React from 'react'\n\nexport const CustomDappPathToComponent: PathToComponent[] = [\n {\n component: <FlexRow />,\n path: 'home',\n },\n]\n","import type { UnregisteredReactDapp } from '@xyo-network/os-react-model'\n\nimport { CustomDappParams } from './Params.js'\nimport { CustomDapp } from './window/index.ts'\n\nexport const CustomDappUiParams: UnregisteredReactDapp['params'] = {\n ...CustomDappParams,\n modes: { window: { component: CustomDapp } },\n}\n\nexport { CustomDappUiParams as default }\n"],"mappings":";;;;AAAA;AAAA,EACE,SAAW;AAAA,EACX,OAAS;AAAA,IACP;AAAA,MACE,QAAU;AAAA,QACR,aAAe;AAAA,QACf,MAAQ;AAAA,QACR,QAAU;AAAA,MACZ;AAAA,MACA,SAAW;AAAA,QACT,SAAW,CAAC;AAAA,QACZ,QAAU;AAAA,UACR;AAAA,YACE,QAAU;AAAA,cACR,aAAe;AAAA,cACf,MAAQ;AAAA,cACR,QAAU;AAAA,cACV,WAAa;AAAA,cACb,QAAU;AAAA,cACV,QAAU;AAAA,gBACR,2CAA2C;AAAA,cAC7C;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAU;AACZ;;;AC7BA,SAASA,WAAAA,gBAAe;AAGxB,SAASC,oBAAoB;AAC7B,OAAOC,UAASC,WAAAA,gBAAe;;;ACJ/B,SAASC,gBAAgB;AAGzB,SAASC,0BAA0BC,wBAAwB;AAUpD,IAAMC,kBAAN,MAAMA;EAbb,OAaaA;;;EACHC;EAERC,YAAYC,QAA+B;AACzC,SAAKF,UAAUE;EACjB;EAEA,IAAIA,SAAS;AACX,WAAOC,SAAS,KAAKH,SAAS,MAAM,IAAII,MAAM,iBAAA,CAAA;EAChD;EAEA,MAAMC,UAAsC;AAC1C,UAAMC,mBAAmB,MAAM,KAAKC,kBAAiB;AAErD,WAAO,MAAM,KAAKC,sBAAsBF,gBAAAA;EAC1C;EAEA,MAAcE,sBAAsBF,kBAAmE;AACrG,UAAM,EACJ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BAAmB;AAC5B,SAASC,kBAAkBC,2BAA2B;AACtD,OAAOC,YAAW;;;ACFlB,SAASC,eAAe;AAExB,OAAOC,YAAW;AAEX,IAAMC,4BAA+C;EAC1D;IACEC,WAAW,gBAAAF,OAAA,cAACD,SAAAA,IAAAA;IACZI,MAAM;EACR;;;;ADDK,IAAMC,aAAa,6BAAA;AACxB,QAAM,EACJC,YAAYC,MAAMC,MAAK,IACrBC,oBAAoBC,sBAAAA;AAExB,SACE,gBAAAC,OAAA,cAAAA,OAAA,UAAA,MACE,gBAAAA,OAAA,cAACC,aAAAA;IAAYJ;IAAcK,OAAM;MACjC,gBAAAF,OAAA,cAACG,kBAAAA;IAAiBC,YAAYR,MAAMA,QAAQD,YAAYU;IAAaC,iBAAiBC;;AAG5F,GAX0B;;;AEFnB,IAAMC,qBAAsD;EACjE,GAAGC;EACHC,OAAO;IAAEC,QAAQ;MAAEC,WAAWC;IAAW;EAAE;AAC7C;","names":["FlexCol","DappRendered","React","useMemo","assertEx","DappSeedPhraseRepository","RunningDappCache","DappInitializer","_config","constructor","config","assertEx","Error","install","dappWithWalletId","installDappWallet","initializeDappContext","allowedNames","xnsNetwork","xnsNodeUrl","xyOs","RunningDappCache","findOrCreate","dapp","dappSeedPhraseRepository","DappSeedPhraseRepository","name","walletId","usePromise","useDappMenu","useManageDappInjectableParamsFromRoute","useManageDappPathFromRoute","useXyOsUiContext","useInitializeDapp","dapp","xyOs","useXyOsUiContext","installedDapp","nodeCreateError","usePromise","installer","DappInitializer","allowedNames","config","name","xnsNetwork","undefined","xnsNodeUrl","install","dappWallet","context","routingError","useManageDappPathFromRoute","injectableErrors","useManageDappInjectableParamsFromRoute","dappMenu","useDappMenu","errors","filter","Boolean","Typography","FlexCol","usePromise","HDWallet","Kernel","ModuleFactoryLocator","XyOsUiContextProvider","EventBus","XyOs","useMemo","XyOsHost","children","eventBus","kernel","locator","wallet","walletToUse","usePromise","HDWallet","random","eventBusToUse","useMemo","EventBus","kernelToUse","Kernel","locatorToUse","ModuleFactoryLocator","os","error","XyOs","boot","XyOsUiContextProvider","value","FlexCol","Typography","message","DappHost","dapp","context","dappMenu","dappWallet","errors","useInitializeDapp","dappState","useMemo","active","minimized","closed","React","XyOsHost","FlexCol","DappRendered","dappMenuProperties","IndexedDbArchivist","ModuleFactoryLocator","CustomDappIconSvg","locator","ModuleFactoryLocator","register","IndexedDbArchivist","CustomDappParams","iconSvg","CustomDappIconSvg","DappConfigSchema","DappIconSchema","DappMode","DappNavItemSchema","DappNavMenuConfigSchema","CustomDappName","version","CustomDappConfig","manifest","dappManifest","modes","DappMode","Window","name","schema","DappConfigSchema","sources","CustomDappIcon","active","installed","DappIconSchema","type","DappPayloads","CustomDappMenuItems","path","primaryText","DappNavItemSchema","svgIcon","weight","CustomDappMenuConfig","defaultPath","DappNavMenuConfigSchema","CustomDappMenuPayloads","ErrorRender","DappPathSwitcher","useAddDappMenuItems","React","FlexRow","React","CustomDappPathToComponent","component","path","CustomDapp","menuConfig","path","error","useAddDappMenuItems","CustomDappMenuPayloads","React","ErrorRender","scope","DappPathSwitcher","activePath","defaultPath","pathToComponent","CustomDappPathToComponent","CustomDappUiParams","CustomDappParams","modes","window","component","CustomDapp"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/dapp-template",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"@xylabs/react-promise": "^5.3.14",
|
|
43
43
|
"@xyo-network/account": "^3.6.6",
|
|
44
44
|
"@xyo-network/archivist-indexeddb": "^3.6.6",
|
|
45
|
-
"@xyo-network/kernel": "^4.2.
|
|
46
|
-
"@xyo-network/kernel-model": "^4.2.
|
|
45
|
+
"@xyo-network/kernel": "^4.2.2",
|
|
46
|
+
"@xyo-network/kernel-model": "^4.2.2",
|
|
47
47
|
"@xyo-network/module-factory-locator": "^3.6.6",
|
|
48
48
|
"@xyo-network/object": "^3.6.6",
|
|
49
|
-
"@xyo-network/os-model": "^4.2.
|
|
50
|
-
"@xyo-network/os-react-model": "^4.2.
|
|
51
|
-
"@xyo-network/os-react-runtime": "^4.2.
|
|
52
|
-
"@xyo-network/os-runtime": "^4.2.
|
|
49
|
+
"@xyo-network/os-model": "^4.2.2",
|
|
50
|
+
"@xyo-network/os-react-model": "^4.2.2",
|
|
51
|
+
"@xyo-network/os-react-runtime": "^4.2.2",
|
|
52
|
+
"@xyo-network/os-runtime": "^4.2.2",
|
|
53
53
|
"@xyo-network/payload-model": "^3.6.6",
|
|
54
54
|
"@xyo-network/react-node": "^4.3.1",
|
|
55
55
|
"@xyo-network/react-sdk": "^4.3.1",
|
package/src/DappHost.tsx
CHANGED
|
@@ -1,145 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FlexCol, FlexRow } from '@xylabs/react-flexbox'
|
|
3
|
-
import { usePromise } from '@xylabs/react-promise'
|
|
1
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
4
2
|
import type { RegisteredReactDapp } from '@xyo-network/os-react-model'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
DappBottomNavigation,
|
|
9
|
-
DappChrome,
|
|
10
|
-
DappMenuDrawer,
|
|
11
|
-
useDappContextCreator,
|
|
12
|
-
useDappMenu,
|
|
13
|
-
useManageDappPathFromRoute, useXyOsUiContext,
|
|
14
|
-
XyOsUiContextProvider,
|
|
15
|
-
} from '@xyo-network/os-react-runtime'
|
|
16
|
-
import { DappSeedPhraseRepository, NameTransforms } from '@xyo-network/os-runtime'
|
|
17
|
-
import { NodeProvider } from '@xyo-network/react-node'
|
|
18
|
-
import { ErrorRender, WalletProvider } from '@xyo-network/react-sdk'
|
|
19
|
-
import React, {
|
|
20
|
-
useMemo, useState, version,
|
|
21
|
-
} from 'react'
|
|
3
|
+
import type { DappState } from '@xyo-network/os-react-runtime'
|
|
4
|
+
import { DappRendered } from '@xyo-network/os-react-runtime'
|
|
5
|
+
import React, { useMemo } from 'react'
|
|
22
6
|
|
|
7
|
+
import { useInitializeDapp } from './helpers/index.ts'
|
|
23
8
|
import { XyOsHost } from './XyOsHost.tsx'
|
|
24
9
|
|
|
25
|
-
const allowedNames = ['Accounts']
|
|
26
|
-
|
|
27
10
|
export interface DappHostProps {
|
|
28
11
|
dapp: RegisteredReactDapp
|
|
29
12
|
}
|
|
30
13
|
|
|
31
|
-
const
|
|
32
|
-
const xyOs = useXyOsUiContext()
|
|
33
|
-
const [walletId, setWalletId] = useState<string>()
|
|
34
|
-
const [dappWithWalletId, setDappWithWalletId] = useState<RegisteredReactDapp>(dapp)
|
|
35
|
-
|
|
36
|
-
// stub the walletId for the dapp
|
|
37
|
-
usePromise(async () => {
|
|
38
|
-
if (xyOs) {
|
|
39
|
-
const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, allowedNames)
|
|
40
|
-
const walletId = await dappSeedPhraseRepository.findOrCreate(allowedNames[0])
|
|
41
|
-
setWalletId(walletId)
|
|
42
|
-
setDappWithWalletId(dapp => ({
|
|
43
|
-
...dapp,
|
|
44
|
-
config: {
|
|
45
|
-
...dapp.config,
|
|
46
|
-
walletId,
|
|
47
|
-
},
|
|
48
|
-
}))
|
|
49
|
-
}
|
|
50
|
-
}, [xyOs])
|
|
51
|
-
|
|
52
|
-
const name = dapp?.config.name
|
|
53
|
-
const scrollable = true
|
|
54
|
-
|
|
55
|
-
// Create the dapp context
|
|
56
|
-
const {
|
|
57
|
-
dappWallet, context, nodeCreateError,
|
|
58
|
-
} = useDappContextCreator('', '', dappWithWalletId, allowedNames, !!walletId)
|
|
59
|
-
|
|
60
|
-
// support for routing
|
|
61
|
-
useManageDappPathFromRoute(context, dapp.config.name)
|
|
62
|
-
|
|
63
|
-
// Get the dapp component
|
|
64
|
-
const TypedDappComponent = useMemo(() => dapp?.params.modes?.window?.component as React.FC<{
|
|
65
|
-
name?: string
|
|
66
|
-
}>, [])
|
|
67
|
-
|
|
68
|
-
// Get the menu items
|
|
14
|
+
export const DappHost: React.FC<DappHostProps> = ({ dapp }) => {
|
|
69
15
|
const {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} = useDappMenu(context, name)
|
|
16
|
+
context, dappMenu, dappWallet, errors,
|
|
17
|
+
} = useInitializeDapp(dapp)
|
|
73
18
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<Typography>
|
|
78
|
-
xyOs Booted:
|
|
79
|
-
{xyOs ? 'true' : 'false'}
|
|
80
|
-
</Typography>
|
|
81
|
-
</FlexRow>
|
|
82
|
-
<DappChrome
|
|
83
|
-
appBar={(
|
|
84
|
-
<>
|
|
85
|
-
{/* Keep DappBar outside of the Dapp's Node Provider so it can still see the intentArchivist for close and minimize */}
|
|
86
|
-
<DappBar context={context} name={name} version={version} title={activePath ? new NameTransforms(activePath).deSlug() : ''} />
|
|
87
|
-
</>
|
|
88
|
-
)}
|
|
89
|
-
height="100dvh"
|
|
90
|
-
width="100dvw"
|
|
91
|
-
largeScreenMenu={(
|
|
92
|
-
<DappMenuDrawer
|
|
93
|
-
context={context}
|
|
94
|
-
name={name}
|
|
95
|
-
version={version}
|
|
96
|
-
activePath={activePath}
|
|
97
|
-
onPathChange={onPathChange}
|
|
98
|
-
menuConfig={menuConfig}
|
|
99
|
-
menuItems={menuItemsVisible}
|
|
100
|
-
/>
|
|
101
|
-
)}
|
|
102
|
-
smallScreenMenu={(
|
|
103
|
-
<DappBottomNavigation
|
|
104
|
-
activePath={activePath}
|
|
105
|
-
onPathChange={onPathChange}
|
|
106
|
-
menuConfig={menuConfig}
|
|
107
|
-
menuItems={menuItemsVisible}
|
|
108
|
-
sx={{ display: menuConfig ? 'flex' : 'none' }}
|
|
109
|
-
/>
|
|
110
|
-
)}
|
|
111
|
-
>
|
|
112
|
-
<ErrorRender error={nodeCreateError} scope="Accounts Stories" />
|
|
113
|
-
<WalletProvider rootWallet={dappWallet}>
|
|
114
|
-
<XyOsUiContextProvider value={context === null ? undefined : context}>
|
|
115
|
-
{/* Prevent dapps from reaching out to the os node */}
|
|
116
|
-
<NodeProvider node={context?.root}>
|
|
117
|
-
<FlexCol
|
|
118
|
-
alignItems="stretch"
|
|
119
|
-
justifyContent="stretch"
|
|
120
|
-
position="absolute"
|
|
121
|
-
top={0}
|
|
122
|
-
bottom={0}
|
|
123
|
-
left={0}
|
|
124
|
-
right={0}
|
|
125
|
-
sx={{ overflowY: scrollable ? 'auto' : 'hidden' }}
|
|
126
|
-
>
|
|
127
|
-
<TypedDappComponent name="Accounts" />
|
|
128
|
-
</FlexCol>
|
|
129
|
-
<DappAccessFlexbox context={context} />
|
|
19
|
+
const dappState: DappState = useMemo(() => ({
|
|
20
|
+
active: true, minimized: false, closed: false,
|
|
21
|
+
}), [])
|
|
130
22
|
|
|
131
|
-
</NodeProvider>
|
|
132
|
-
</XyOsUiContextProvider>
|
|
133
|
-
</WalletProvider>
|
|
134
|
-
</DappChrome>
|
|
135
|
-
</FlexCol>
|
|
136
|
-
)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export const DappHost: React.FC<DappHostProps> = ({ dapp }) => {
|
|
140
23
|
return (
|
|
141
24
|
<XyOsHost>
|
|
142
|
-
<
|
|
25
|
+
<FlexCol>
|
|
26
|
+
<DappRendered context={context} dapp={dapp} dappMenuProperties={dappMenu} dappState={dappState} dappWallet={dappWallet} errors={errors} />
|
|
27
|
+
</FlexCol>
|
|
143
28
|
</XyOsHost>
|
|
144
29
|
)
|
|
145
30
|
}
|
package/src/dapp.stories.tsx
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './registration/index.ts'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/assert'
|
|
2
|
+
import type { WindowDappNodeSet, XyOsContext } from '@xyo-network/os-model'
|
|
3
|
+
import type { RegisteredReactDapp } from '@xyo-network/os-react-model'
|
|
4
|
+
import { DappSeedPhraseRepository, RunningDappCache } from '@xyo-network/os-runtime'
|
|
5
|
+
|
|
6
|
+
export interface DappInitializerConfig {
|
|
7
|
+
allowedNames: string[]
|
|
8
|
+
dapp: RegisteredReactDapp
|
|
9
|
+
xnsNetwork: string | undefined
|
|
10
|
+
xnsNodeUrl: string | undefined
|
|
11
|
+
xyOs: XyOsContext
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class DappInitializer {
|
|
15
|
+
private _config: DappInitializerConfig
|
|
16
|
+
|
|
17
|
+
constructor(config: DappInitializerConfig) {
|
|
18
|
+
this._config = config
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get config() {
|
|
22
|
+
return assertEx(this._config, () => new Error('Options not set'))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async install(): Promise<WindowDappNodeSet> {
|
|
26
|
+
const dappWithWalletId = await this.installDappWallet()
|
|
27
|
+
|
|
28
|
+
return await this.initializeDappContext(dappWithWalletId)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private async initializeDappContext(dappWithWalletId: RegisteredReactDapp): Promise<WindowDappNodeSet> {
|
|
32
|
+
const {
|
|
33
|
+
allowedNames, xnsNetwork, xnsNodeUrl, xyOs,
|
|
34
|
+
} = this.config
|
|
35
|
+
|
|
36
|
+
return await RunningDappCache.findOrCreate(dappWithWalletId, xyOs, allowedNames ?? [], xnsNodeUrl, xnsNetwork)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private async installDappWallet(): Promise<RegisteredReactDapp> {
|
|
40
|
+
const { xyOs, dapp } = this.config
|
|
41
|
+
const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [dapp.config.name])
|
|
42
|
+
const walletId = await dappSeedPhraseRepository.findOrCreate(dapp.config.name)
|
|
43
|
+
|
|
44
|
+
// Update the dapp with the walletId
|
|
45
|
+
return {
|
|
46
|
+
...dapp,
|
|
47
|
+
config: {
|
|
48
|
+
...dapp.config,
|
|
49
|
+
walletId,
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { usePromise } from '@xylabs/react-promise'
|
|
2
|
+
import type { RegisteredReactDapp } from '@xyo-network/os-react-model'
|
|
3
|
+
import {
|
|
4
|
+
useDappMenu, useManageDappInjectableParamsFromRoute, useManageDappPathFromRoute, useXyOsUiContext,
|
|
5
|
+
} from '@xyo-network/os-react-runtime'
|
|
6
|
+
|
|
7
|
+
import { DappInitializer } from './DappInitializer.ts'
|
|
8
|
+
|
|
9
|
+
export const useInitializeDapp = (dapp: RegisteredReactDapp) => {
|
|
10
|
+
const xyOs = useXyOsUiContext()
|
|
11
|
+
|
|
12
|
+
const [installedDapp, nodeCreateError] = usePromise(async () => {
|
|
13
|
+
if (xyOs && dapp) {
|
|
14
|
+
const installer = new DappInitializer({
|
|
15
|
+
allowedNames: [dapp.config.name],
|
|
16
|
+
dapp,
|
|
17
|
+
xnsNetwork: undefined,
|
|
18
|
+
xnsNodeUrl: undefined,
|
|
19
|
+
xyOs,
|
|
20
|
+
})
|
|
21
|
+
return await installer.install()
|
|
22
|
+
}
|
|
23
|
+
}, [xyOs, dapp])
|
|
24
|
+
|
|
25
|
+
const { dappWallet, context } = installedDapp ?? {}
|
|
26
|
+
|
|
27
|
+
// support for routing
|
|
28
|
+
const routingError = useManageDappPathFromRoute(context, dapp.config.name)
|
|
29
|
+
const injectableErrors = useManageDappInjectableParamsFromRoute(context)
|
|
30
|
+
|
|
31
|
+
const dappMenu = useDappMenu(context, dapp.config.name)
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
context,
|
|
35
|
+
dappMenu,
|
|
36
|
+
dappWallet,
|
|
37
|
+
errors: [routingError, nodeCreateError, ...injectableErrors].filter(Boolean),
|
|
38
|
+
}
|
|
39
|
+
}
|