@xyo-network/os-react-runtime 4.2.0-rc.1 → 4.2.0-rc.3
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/browser/hooks/os/useDappContextCreator.d.ts.map +1 -1
- package/dist/browser/index.mjs +32 -27
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/modules/Dapp/Container.d.ts +1 -0
- package/dist/browser/modules/Dapp/Container.d.ts.map +1 -1
- package/dist/browser/modules/Dapp/Page/Row.d.ts.map +1 -1
- package/dist/browser/modules/Dapp/modules/Window/DappWindow.d.ts.map +1 -1
- package/dist/browser/modules/Dapp/modules/Window/hooks/lib/deriveDappState.d.ts +3 -3
- package/dist/browser/modules/Dapp/modules/Window/hooks/lib/deriveDappState.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/hooks/os/useDappContextCreator.tsx +20 -15
- package/src/modules/Dapp/Container.tsx +5 -3
- package/src/modules/Dapp/Page/Row.tsx +4 -5
- package/src/modules/Dapp/modules/Window/DappWindow.tsx +2 -4
- package/src/modules/Dapp/modules/Window/hooks/lib/deriveDappState.ts +6 -6
|
@@ -8,4 +8,5 @@ export interface DappContainerProps {
|
|
|
8
8
|
xnsNodeUrl: string | undefined;
|
|
9
9
|
}
|
|
10
10
|
export declare const DappContainer: React.FC<DappContainerProps>;
|
|
11
|
+
export declare const DappContainerMemo: React.NamedExoticComponent<DappContainerProps>;
|
|
11
12
|
//# sourceMappingURL=Container.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../../src/modules/Dapp/Container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,
|
|
1
|
+
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../../src/modules/Dapp/Container.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,KAAwB,MAAM,OAAO,CAAA;AAM5C,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,EAAE,UAAU,CAAA;IAC1B,OAAO,EAAE,sBAAsB,CAAA;IAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAgCtD,CAAA;AAED,eAAO,MAAM,iBAAiB,gDAAsB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../../../src/modules/Dapp/Page/Row.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../../../src/modules/Dapp/Page/Row.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,gBAAgB,CAAA;IAC7B,kBAAkB,CAAC,EAAE,sBAAsB,EAAE,CAAA;IAC7C,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAuC5C,CAAA;AAED,eAAO,MAAM,mBAAmB,ySAQ7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DappWindow.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/Dapp/modules/Window/DappWindow.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAIzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAOjD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAA;IAChC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,eAAe,CAAC,EAAE,KAAK,CAAA;CACxB;AAED,gIAAgI;AAChI,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"DappWindow.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/Dapp/modules/Window/DappWindow.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAIzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAOjD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAA;IAChC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,eAAe,CAAC,EAAE,KAAK,CAAA;CACxB;AAED,gIAAgI;AAChI,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAsHhD,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { DappIntent
|
|
1
|
+
import type { DappIntent } from '@xyo-network/os-model';
|
|
2
2
|
export interface DappState {
|
|
3
3
|
active: boolean;
|
|
4
|
+
closed: boolean;
|
|
4
5
|
minimized: boolean;
|
|
5
|
-
open: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare const deriveDappState: (intent?: DappIntent
|
|
7
|
+
export declare const deriveDappState: (intent?: DappIntent) => DappState;
|
|
8
8
|
//# sourceMappingURL=deriveDappState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deriveDappState.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/Dapp/modules/Window/hooks/lib/deriveDappState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"deriveDappState.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/Dapp/modules/Window/hooks/lib/deriveDappState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGvD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,eAAe,YAAa,UAAU,KAAG,SAUrD,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/os-react-runtime",
|
|
3
|
-
"version": "4.2.0-rc.
|
|
3
|
+
"version": "4.2.0-rc.3",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -48,23 +48,23 @@
|
|
|
48
48
|
"@xylabs/react-shared": "^5.3.14",
|
|
49
49
|
"@xyo-network/archivist-indexeddb": "^3.6.6",
|
|
50
50
|
"@xyo-network/archivist-model": "^3.6.6",
|
|
51
|
-
"@xyo-network/bios-browser": "^4.2.0-rc.
|
|
52
|
-
"@xyo-network/bios-model": "^4.2.0-rc.
|
|
51
|
+
"@xyo-network/bios-browser": "^4.2.0-rc.3",
|
|
52
|
+
"@xyo-network/bios-model": "^4.2.0-rc.3",
|
|
53
53
|
"@xyo-network/diviner-boundwitness-indexeddb": "^3.6.6",
|
|
54
54
|
"@xyo-network/diviner-model": "^3.6.6",
|
|
55
55
|
"@xyo-network/diviner-payload-generic": "^3.6.6",
|
|
56
56
|
"@xyo-network/diviner-payload-indexeddb": "^3.6.6",
|
|
57
57
|
"@xyo-network/diviner-payload-model": "^3.6.6",
|
|
58
|
-
"@xyo-network/kernel": "^4.2.0-rc.
|
|
59
|
-
"@xyo-network/kernel-model": "^4.2.0-rc.
|
|
58
|
+
"@xyo-network/kernel": "^4.2.0-rc.3",
|
|
59
|
+
"@xyo-network/kernel-model": "^4.2.0-rc.3",
|
|
60
60
|
"@xyo-network/module-event-emitter": "^3.6.6",
|
|
61
61
|
"@xyo-network/module-events": "^3.6.6",
|
|
62
62
|
"@xyo-network/module-factory-locator": "^3.6.6",
|
|
63
63
|
"@xyo-network/node-model": "^3.6.6",
|
|
64
|
-
"@xyo-network/os-model": "^4.2.0-rc.
|
|
65
|
-
"@xyo-network/os-react-debug": "^4.2.0-rc.
|
|
66
|
-
"@xyo-network/os-react-model": "^4.2.0-rc.
|
|
67
|
-
"@xyo-network/os-runtime": "^4.2.0-rc.
|
|
64
|
+
"@xyo-network/os-model": "^4.2.0-rc.3",
|
|
65
|
+
"@xyo-network/os-react-debug": "^4.2.0-rc.3",
|
|
66
|
+
"@xyo-network/os-react-model": "^4.2.0-rc.3",
|
|
67
|
+
"@xyo-network/os-runtime": "^4.2.0-rc.3",
|
|
68
68
|
"@xyo-network/payload-model": "^3.6.6",
|
|
69
69
|
"@xyo-network/react-archivist": "^4.3.1",
|
|
70
70
|
"@xyo-network/react-card": "^4.3.1",
|
|
@@ -28,6 +28,8 @@ export const useDappContextCreator = (
|
|
|
28
28
|
const context = useXyOsUiContext()
|
|
29
29
|
const [windowDappNodeSet, setWindowDappNodeSet] = useState<WindowDappNodeSet>({ context: undefined, dappWallet: undefined })
|
|
30
30
|
const [dappWindowNodeError, setDappWindowNodeError] = useState<Error>()
|
|
31
|
+
// ensure the dapp is targeted by the current intent
|
|
32
|
+
const targetedDapp = !!(dapp && context && currentIntent?.targetDappId === dapp?.config.name)
|
|
31
33
|
|
|
32
34
|
// Keep a ref of the windowDappNodeSet to use in effect hooks without needing it as a dependency
|
|
33
35
|
const windowDappNodeSetRef = useRef<WindowDappNodeSet>(windowDappNodeSet)
|
|
@@ -36,7 +38,7 @@ export const useDappContextCreator = (
|
|
|
36
38
|
}, [windowDappNodeSet])
|
|
37
39
|
|
|
38
40
|
const createNode = useCallback(async () => {
|
|
39
|
-
if (
|
|
41
|
+
if (targetedDapp) {
|
|
40
42
|
try {
|
|
41
43
|
const windowDappNodeSet = await RunningDappCache.findOrCreate(dapp, context, allowedNames ?? [], xnsNodeUrl, xnsNetwork)
|
|
42
44
|
setWindowDappNodeSet(windowDappNodeSet)
|
|
@@ -44,7 +46,7 @@ export const useDappContextCreator = (
|
|
|
44
46
|
setDappWindowNodeError(e as Error)
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
|
-
}, [dapp, context, allowedNames])
|
|
49
|
+
}, [dapp, currentIntent, context, allowedNames])
|
|
48
50
|
|
|
49
51
|
useEffect(() => {
|
|
50
52
|
if (createOnMount) {
|
|
@@ -58,21 +60,24 @@ export const useDappContextCreator = (
|
|
|
58
60
|
useAsyncEffect(
|
|
59
61
|
|
|
60
62
|
async () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
// unless the dapp was passed, do nothing
|
|
64
|
+
if (targetedDapp) {
|
|
65
|
+
switch (currentIntent?.intent) {
|
|
66
|
+
case DappIntentTypes.Launch: {
|
|
67
|
+
await createNode()
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
case DappIntentTypes.Close: {
|
|
71
|
+
if (windowDappNodeSetRef.current.context) {
|
|
72
|
+
// In case a cached dapp was closed, clear its Dapp Archivist to allow for a fresh start upon next launch
|
|
73
|
+
await DappContextCreator.resetDappArchivist(windowDappNodeSetRef.current.context)
|
|
74
|
+
setWindowDappNodeSet({ context: null, dappWallet: undefined })
|
|
75
|
+
}
|
|
76
|
+
break
|
|
71
77
|
}
|
|
72
|
-
|
|
78
|
+
case DappIntentTypes.Minimize:
|
|
79
|
+
// do nothing
|
|
73
80
|
}
|
|
74
|
-
case DappIntentTypes.Minimize:
|
|
75
|
-
// do nothing
|
|
76
81
|
}
|
|
77
82
|
},
|
|
78
83
|
[createNode, currentIntent],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DappIntent } from '@xyo-network/os-model'
|
|
2
2
|
import type { RegisteredReactDappSet } from '@xyo-network/os-react-model'
|
|
3
|
-
import React, { useMemo } from 'react'
|
|
3
|
+
import React, { memo, useMemo } from 'react'
|
|
4
4
|
|
|
5
5
|
import { useDappContextCreator } from '../../hooks/index.ts'
|
|
6
6
|
import { DappIconButton } from './Button/index.ts'
|
|
@@ -24,9 +24,9 @@ export const DappContainer: React.FC<DappContainerProps> = ({
|
|
|
24
24
|
|
|
25
25
|
const dappState = useMemo(() => {
|
|
26
26
|
if (currentIntent?.targetDappId === dapp.config.name) {
|
|
27
|
-
return deriveDappState(currentIntent
|
|
27
|
+
return deriveDappState(currentIntent)
|
|
28
28
|
}
|
|
29
|
-
}, [currentIntent,
|
|
29
|
+
}, [currentIntent, dapp])
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<DappIconButton
|
|
@@ -46,3 +46,5 @@ export const DappContainer: React.FC<DappContainerProps> = ({
|
|
|
46
46
|
</DappIconButton>
|
|
47
47
|
)
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
export const DappContainerMemo = memo(DappContainer)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @eslint-react/no-array-index-key */
|
|
2
1
|
import {
|
|
3
2
|
Divider, Fade, styled,
|
|
4
3
|
} from '@mui/material'
|
|
@@ -8,7 +7,7 @@ import React, { useMemo } from 'react'
|
|
|
8
7
|
|
|
9
8
|
import { useDappIntentListener } from '../../../hooks/index.ts'
|
|
10
9
|
import { DappInstallTypeFilters } from '../../../utils/index.ts'
|
|
11
|
-
import {
|
|
10
|
+
import { DappContainerMemo } from '../Container.tsx'
|
|
12
11
|
import { DividerChip } from './DividerChip.js'
|
|
13
12
|
|
|
14
13
|
export interface DappsRowProps {
|
|
@@ -42,10 +41,10 @@ export const DappsRow: React.FC<DappsRowProps> = ({
|
|
|
42
41
|
<Fade in={!!filteredRegisteredDappSets?.length} timeout={1000}>
|
|
43
42
|
<StyledGridContainer>
|
|
44
43
|
{filteredRegisteredDappSets?.map(
|
|
45
|
-
|
|
46
|
-
<
|
|
44
|
+
dappSet => (
|
|
45
|
+
<DappContainerMemo
|
|
47
46
|
currentIntent={intentPayload}
|
|
48
|
-
key={
|
|
47
|
+
key={dappSet.dapp.config.name}
|
|
49
48
|
dappSet={dappSet as RegisteredReactDappSet}
|
|
50
49
|
xnsNodeUrl={xnsNodeUrl}
|
|
51
50
|
xnsNetwork={xnsNetwork}
|
|
@@ -38,9 +38,7 @@ export const DappWindow: React.FC<DappWindowProps> = ({
|
|
|
38
38
|
DappComponent, name, scrollable = true, version,
|
|
39
39
|
} = decomposeDappSet(dappSet)
|
|
40
40
|
|
|
41
|
-
const {
|
|
42
|
-
active, minimized, open,
|
|
43
|
-
} = dappState ?? {}
|
|
41
|
+
const { active, minimized } = dappState ?? {}
|
|
44
42
|
|
|
45
43
|
const TypedDappComponent = useMemo(() => DappComponent as React.FC<{
|
|
46
44
|
name?: string
|
|
@@ -102,7 +100,7 @@ export const DappWindow: React.FC<DappWindowProps> = ({
|
|
|
102
100
|
/>
|
|
103
101
|
)}
|
|
104
102
|
/* Ensure that loading goes away when error occurs */
|
|
105
|
-
splashScreen={resolvedError ? null : <DappLoadingFlexbox minimize={!!minimized} name={name} open={!!
|
|
103
|
+
splashScreen={resolvedError ? null : <DappLoadingFlexbox minimize={!!minimized} name={name} open={!!active} />}
|
|
106
104
|
>
|
|
107
105
|
{resolvedError || errors?.length > 0
|
|
108
106
|
? (
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { DappIntent
|
|
1
|
+
import type { DappIntent } from '@xyo-network/os-model'
|
|
2
2
|
import { DappIntentTypes } from '@xyo-network/os-model'
|
|
3
3
|
|
|
4
4
|
export interface DappState {
|
|
5
5
|
active: boolean
|
|
6
|
+
closed: boolean
|
|
6
7
|
minimized: boolean
|
|
7
|
-
open: boolean
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const deriveDappState = (intent?: DappIntent
|
|
10
|
+
export const deriveDappState = (intent?: DappIntent): DappState => {
|
|
11
11
|
const minimized = intent?.intent === DappIntentTypes.Minimize
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const active = intent?.intent === DappIntentTypes.Launch
|
|
13
|
+
const closed = intent?.intent === DappIntentTypes.Close
|
|
14
14
|
|
|
15
15
|
return {
|
|
16
16
|
active,
|
|
17
|
+
closed,
|
|
17
18
|
minimized,
|
|
18
|
-
open,
|
|
19
19
|
}
|
|
20
20
|
}
|