@xyo-network/os-react-runtime 4.1.4 → 4.2.0-rc.10

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.
Files changed (66) hide show
  1. package/dist/browser/DappPathSwitcher.d.ts.map +1 -1
  2. package/dist/browser/helpers/BridgeActivityHelper.d.ts +10 -10
  3. package/dist/browser/helpers/index.d.ts +0 -1
  4. package/dist/browser/helpers/index.d.ts.map +1 -1
  5. package/dist/browser/hooks/intent/useDappIntentListener.d.ts.map +1 -1
  6. package/dist/browser/hooks/os/useDappContextCreator.d.ts +2 -2
  7. package/dist/browser/hooks/os/useDappContextCreator.d.ts.map +1 -1
  8. package/dist/browser/hooks/useAccountArchivist.d.ts +10 -10
  9. package/dist/browser/index.mjs +454 -470
  10. package/dist/browser/index.mjs.map +1 -1
  11. package/dist/browser/modules/Dapp/Button/IconEx.d.ts +4 -2
  12. package/dist/browser/modules/Dapp/Button/IconEx.d.ts.map +1 -1
  13. package/dist/browser/modules/Dapp/Container.d.ts +3 -0
  14. package/dist/browser/modules/Dapp/Container.d.ts.map +1 -1
  15. package/dist/browser/modules/Dapp/Page/Row.d.ts +2 -1
  16. package/dist/browser/modules/Dapp/Page/Row.d.ts.map +1 -1
  17. package/dist/browser/modules/Dapp/modules/Window/DappWindow.d.ts +10 -3
  18. package/dist/browser/modules/Dapp/modules/Window/DappWindow.d.ts.map +1 -1
  19. package/dist/browser/modules/Dapp/modules/Window/hooks/index.d.ts +2 -1
  20. package/dist/browser/modules/Dapp/modules/Window/hooks/index.d.ts.map +1 -1
  21. package/dist/browser/modules/Dapp/modules/Window/hooks/lib/deriveDappState.d.ts +8 -0
  22. package/dist/browser/modules/Dapp/modules/Window/hooks/lib/deriveDappState.d.ts.map +1 -0
  23. package/dist/browser/modules/Dapp/modules/Window/hooks/lib/index.d.ts +2 -1
  24. package/dist/browser/modules/Dapp/modules/Window/hooks/lib/index.d.ts.map +1 -1
  25. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/index.d.ts +4 -4
  26. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/index.d.ts.map +1 -1
  27. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappInjectableParamsFromRoute.d.ts +1 -1
  28. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappInjectableParamsFromRoute.d.ts.map +1 -1
  29. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappPathFromRoute.d.ts +2 -0
  30. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappPathFromRoute.d.ts.map +1 -1
  31. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappStateFromRoute.d.ts +2 -2
  32. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappStateFromRoute.d.ts.map +1 -1
  33. package/dist/browser/modules/Dapp/modules/Window/hooks/route/index.d.ts +0 -1
  34. package/dist/browser/modules/Dapp/modules/Window/hooks/route/index.d.ts.map +1 -1
  35. package/package.json +11 -10
  36. package/src/DappPathSwitcher.tsx +11 -9
  37. package/src/helpers/index.ts +0 -1
  38. package/src/hooks/intent/useDappIntentListener.tsx +3 -1
  39. package/src/hooks/os/useDappContextCreator.tsx +25 -19
  40. package/src/hooks/os/useWidgetDapps.tsx +1 -1
  41. package/src/modules/Dapp/Button/IconEx.tsx +16 -13
  42. package/src/modules/Dapp/Container.tsx +33 -5
  43. package/src/modules/Dapp/Page/Row.tsx +14 -5
  44. package/src/modules/Dapp/modules/Window/DappWindow.tsx +25 -26
  45. package/src/modules/Dapp/modules/Window/hooks/index.ts +2 -1
  46. package/src/modules/Dapp/modules/Window/hooks/lib/deriveDappState.ts +20 -0
  47. package/src/modules/Dapp/modules/Window/hooks/lib/index.ts +2 -1
  48. package/src/modules/Dapp/modules/Window/hooks/menu/useDappMenu.tsx +1 -1
  49. package/src/modules/Dapp/modules/Window/hooks/route/helpers/RoutingNodes.md +7 -0
  50. package/src/modules/Dapp/modules/Window/hooks/route/helpers/index.ts +4 -4
  51. package/src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappInjectableParamsFromRoute.tsx +1 -1
  52. package/src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappPathFromRoute.tsx +2 -0
  53. package/src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappStateFromRoute.tsx +26 -20
  54. package/src/modules/Dapp/modules/Window/hooks/route/index.ts +0 -1
  55. package/dist/browser/helpers/widgets/UpperWidgetTrayLayout.d.ts +0 -6
  56. package/dist/browser/helpers/widgets/UpperWidgetTrayLayout.d.ts.map +0 -1
  57. package/dist/browser/helpers/widgets/index.d.ts +0 -2
  58. package/dist/browser/helpers/widgets/index.d.ts.map +0 -1
  59. package/dist/browser/modules/Dapp/modules/Window/hooks/route/useManageDappBasedOffRoute.d.ts +0 -19
  60. package/dist/browser/modules/Dapp/modules/Window/hooks/route/useManageDappBasedOffRoute.d.ts.map +0 -1
  61. package/dist/browser/modules/Dapp/modules/Window/hooks/useDappState.d.ts +0 -8
  62. package/dist/browser/modules/Dapp/modules/Window/hooks/useDappState.d.ts.map +0 -1
  63. package/src/helpers/widgets/UpperWidgetTrayLayout.ts +0 -20
  64. package/src/helpers/widgets/index.ts +0 -1
  65. package/src/modules/Dapp/modules/Window/hooks/route/useManageDappBasedOffRoute.tsx +0 -33
  66. package/src/modules/Dapp/modules/Window/hooks/useDappState.tsx +0 -14
@@ -1,57 +1,59 @@
1
- /* eslint-disable @eslint-react/no-array-index-key */
2
1
  import { ErrorBoundary, ErrorRender } from '@xylabs/react-error'
3
2
  import { FlexCol } from '@xylabs/react-flexbox'
4
- import type { RegisteredReactDappSet } from '@xyo-network/os-react-model'
3
+ import type { DappIntent } from '@xyo-network/os-model'
4
+ import type { RegisteredReactDappSet, XyOsUiContext } from '@xyo-network/os-react-model'
5
5
  import { NameTransforms } from '@xyo-network/os-runtime'
6
6
  import { NodeProvider } from '@xyo-network/react-node'
7
7
  import { WalletProvider } from '@xyo-network/react-wallet'
8
+ import type { WalletInstance } from '@xyo-network/wallet-model'
8
9
  import React, { useMemo } from 'react'
9
10
  import { Helmet } from 'react-helmet'
10
11
 
11
- import { useDappContextCreator, useDappIntentListener } from '../../../../hooks/index.ts'
12
12
  import { XyOsUiContextProvider } from '../../../XyOsUi/index.ts'
13
13
  import { DappAccessFlexbox } from '../access-interface/index.ts'
14
14
  import { DappBar } from './AppBar.js'
15
15
  import { DappChrome } from './Chrome.js'
16
+ import type { DappState } from './hooks/index.ts'
16
17
  import {
17
- dappState, decomposeDappSet, useDappMenu, useManageDappBasedOffRoute, useSyncOsRegisteredAccessInterfaces,
18
+ decomposeDappSet, useDappMenu, useManageDappInjectableParamsFromRoute, useManageDappPathFromRoute, useSyncOsRegisteredAccessInterfaces,
18
19
  } from './hooks/index.ts'
19
20
  import { DappLoadingFlexbox } from './LoadingFlexbox.js'
20
21
  import { DappBottomNavigation, DappMenuDrawer } from './menu/index.ts'
21
22
 
22
23
  export interface DappWindowProps {
24
+ context?: XyOsUiContext | null
23
25
  dappSet?: RegisteredReactDappSet
24
- xnsNetwork: string | undefined
25
- xnsNodeUrl: string | undefined
26
+ dappState?: DappState
27
+ dappWallet?: WalletInstance
28
+ errors?: Error[]
29
+ intent?: DappIntent
30
+ nodeCreateError?: Error
26
31
  }
27
32
 
28
33
  /** A component that can load immediately, but delays node loading and dapp mounting till corresponding launch intent arrives */
29
34
  export const DappWindow: React.FC<DappWindowProps> = ({
30
- dappSet, xnsNodeUrl, xnsNetwork,
35
+ context, dappSet, dappState, dappWallet, errors, nodeCreateError,
31
36
  }) => {
32
37
  const {
33
- DappComponent, dapp, name, scrollable = true, version,
38
+ DappComponent, name, scrollable = true, version,
34
39
  } = decomposeDappSet(dappSet)
35
- const {
36
- dappWallet, context, nodeCreateError,
37
- } = useDappContextCreator(xnsNodeUrl, xnsNetwork, dapp)
38
- const { dappIntentType: intentType, intentPayload } = useDappIntentListener(name)
39
- const {
40
- active, minimized, open,
41
- } = dappState(intentType, context)
40
+
41
+ const { active, minimized } = dappState ?? {}
42
42
 
43
43
  const TypedDappComponent = useMemo(() => DappComponent as React.FC<{
44
44
  name?: string
45
45
  }>, [])
46
46
 
47
- const errors = useManageDappBasedOffRoute(intentPayload, name, context)
48
47
  useSyncOsRegisteredAccessInterfaces(context)
48
+ useManageDappPathFromRoute(context, name)
49
+ useManageDappInjectableParamsFromRoute(context)
49
50
 
50
51
  const {
51
52
  activePath, error: menuError, menuConfig, menuItemsVisible, onPathChange,
52
53
  } = useDappMenu(context, name)
53
54
 
54
- const resolvedError = nodeCreateError || menuError
55
+ const resolvedErrors = [nodeCreateError, menuError, ...(errors ?? [])].filter(Boolean)
56
+ const hasErrors = resolvedErrors.length > 0
55
57
 
56
58
  return (
57
59
  <>
@@ -78,7 +80,7 @@ export const DappWindow: React.FC<DappWindowProps> = ({
78
80
  )}
79
81
  height="100dvh"
80
82
  width="100dvw"
81
- largeScreenMenu={(
83
+ largeScreenMenu={active && (
82
84
  <DappMenuDrawer
83
85
  context={context}
84
86
  name={name}
@@ -89,7 +91,7 @@ export const DappWindow: React.FC<DappWindowProps> = ({
89
91
  menuItems={menuItemsVisible}
90
92
  />
91
93
  )}
92
- smallScreenMenu={(
94
+ smallScreenMenu={active && (
93
95
  <DappBottomNavigation
94
96
  activePath={activePath}
95
97
  onPathChange={onPathChange}
@@ -99,16 +101,13 @@ export const DappWindow: React.FC<DappWindowProps> = ({
99
101
  />
100
102
  )}
101
103
  /* Ensure that loading goes away when error occurs */
102
- splashScreen={resolvedError ? null : <DappLoadingFlexbox minimize={minimized} name={name} open={open} />}
104
+ splashScreen={hasErrors ? null : <DappLoadingFlexbox minimize={!!minimized} name={name} open={!!active} />}
103
105
  >
104
- {resolvedError || errors?.length > 0
106
+ {hasErrors
105
107
  ? (
106
108
  <FlexCol padding={2}>
107
- {resolvedError
108
- ? <ErrorRender error={resolvedError} scope="DappWindow" />
109
- : null}
110
- {errors.map((error, index) => (
111
- <ErrorRender key={index} error={error} scope="DappWindowErrors" />
109
+ {resolvedErrors?.map(error => (
110
+ <ErrorRender key={error?.message} error={error} scope="DappWindow" />
112
111
  ))}
113
112
  </FlexCol>
114
113
  )
@@ -1,6 +1,7 @@
1
+ export * from './lib/index.ts'
1
2
  export * from './menu/index.ts'
2
3
  export * from './route/index.ts'
3
- export * from './useDappState.js'
4
+ export * from './useDappMenuResourceValues.tsx'
4
5
  export * from './useDecomposeDappSet.js'
5
6
  export * from './useSkipLoadingScreen.js'
6
7
  export * from './useSyncOsRegisteredAccessInterfaces.js'
@@ -0,0 +1,20 @@
1
+ import type { DappIntent } from '@xyo-network/os-model'
2
+ import { DappIntentTypes } from '@xyo-network/os-model'
3
+
4
+ export interface DappState {
5
+ active: boolean
6
+ closed: boolean
7
+ minimized: boolean
8
+ }
9
+
10
+ export const deriveDappState = (intent?: DappIntent): DappState => {
11
+ const minimized = intent?.intent === DappIntentTypes.Minimize
12
+ const active = intent?.intent === DappIntentTypes.Launch
13
+ const closed = intent?.intent === DappIntentTypes.Close
14
+
15
+ return {
16
+ active,
17
+ closed,
18
+ minimized,
19
+ }
20
+ }
@@ -1 +1,2 @@
1
- export * from './DappPathHelpers.js'
1
+ export * from './DappPathHelpers.ts'
2
+ export * from './deriveDappState.ts'
@@ -6,7 +6,7 @@ import {
6
6
  import { useNavigate, useParams } from 'react-router-dom'
7
7
 
8
8
  import { DappPathHelpers } from '../lib/index.ts'
9
- import { useDappMenuDependencies } from '../useDappMenuResourceValues.js'
9
+ import { useDappMenuDependencies } from '../useDappMenuResourceValues.tsx'
10
10
 
11
11
  /**
12
12
  * Use the passed in dapp Node to resolve menu related modules and return the menu related items
@@ -0,0 +1,7 @@
1
+ # Manage the dapp based off the route params and intent type
2
+
3
+ This hook centralizes the logic for managing the dapp based off the route. It reacts to changes in the route params and performs the following:
4
+
5
+ 1. Launch or close the dapp based off changes to the `dappName` route params
6
+ 1. Update the menu archivist based off changes in the the `path` route param
7
+ 1. Update the dapp archivist with injectable params based off changes in the query params
@@ -1,4 +1,4 @@
1
- export * from './useManageDappInjectableParamsFromRoute.js'
2
- export * from './useManageDappIntentRequest.js'
3
- export * from './useManageDappPathFromRoute.js'
4
- export * from './useManageDappStateFromRoute.js'
1
+ export * from './useManageDappInjectableParamsFromRoute.tsx'
2
+ export * from './useManageDappIntentRequest.tsx'
3
+ export * from './useManageDappPathFromRoute.tsx'
4
+ export * from './useManageDappStateFromRoute.tsx'
@@ -9,7 +9,7 @@ import {
9
9
  useNavigate, useParams, useSearchParams,
10
10
  } from 'react-router-dom'
11
11
 
12
- /** React to change in the query params */
12
+ /** Update the dapp archivist with injectable params based off changes in the query params */
13
13
  export const useManageDappInjectableParamsFromRoute = (context?: XyOsContext | null) => {
14
14
  const [queryParams] = useSearchParams()
15
15
  const params = useParams()
@@ -10,6 +10,8 @@ import { DappPathHelpers } from '../../lib/index.ts'
10
10
  import { useDappMenuDependencies } from '../../useDappMenuResourceValues.js'
11
11
 
12
12
  /**
13
+ * Update the menu archivist based off changes in the the `path` route param
14
+ *
13
15
  * Test Cases:
14
16
  *
15
17
  * 1. Clicking sidebar menu
@@ -2,44 +2,50 @@ import { usePromise } from '@xylabs/react-promise'
2
2
  import type { DappIntent } from '@xyo-network/os-model'
3
3
  import { DappIntentTypes } from '@xyo-network/os-model'
4
4
  import { DappIntentCaller, NameTransforms } from '@xyo-network/os-runtime'
5
- import { useNavigationType, useParams } from 'react-router-dom'
5
+ import { useRef } from 'react'
6
+ import { useParams } from 'react-router-dom'
6
7
 
7
8
  import { useDappIntentCaller, useSendDappIntent } from '../../../../../../../hooks/index.ts'
8
9
 
9
- /** React to changes in `dappName` route param */
10
- export const useManageDappStateFromRoute = (intentPayload?: DappIntent, dappName?: string) => {
10
+ /** Launch or close the dapp based off changes to the `dappName` route param */
11
+ export const useManageDappStateFromRoute = (intentPayload?: DappIntent) => {
11
12
  const params = useParams()
12
13
  const { dappName: dappNameParam } = params
13
14
  const sendIntent = useSendDappIntent()
14
- const navigationType = useNavigationType()
15
15
  const intentCaller = useDappIntentCaller()
16
16
 
17
+ // refs to track the dappName param and the last intent sent
18
+ const dappNameParamRef = useRef<string>()
19
+ const intentRef = useRef<DappIntent>()
20
+
17
21
  // auto-close the dapp if it was launched and the route param goes undefined (i.e. back button clicked)
18
22
  usePromise(async () => {
19
23
  const launched = intentPayload?.intent === DappIntentTypes.Launch
20
- if (launched && dappNameParam === undefined && sendIntent && navigationType === 'POP') {
21
- const closeIntent = DappIntentCaller.buildIntent(DappIntentCaller.OsDappName, DappIntentTypes.Close, dappName)
24
+ const dappNameParamRemoved = !!dappNameParamRef.current && dappNameParam === undefined
25
+ // The last intent was Launch and the dappName param was removed
26
+ if (launched && dappNameParamRemoved && sendIntent) {
27
+ const closeIntent = DappIntentCaller.buildIntent(DappIntentCaller.OsDappName, DappIntentTypes.Close)
22
28
  await sendIntent(closeIntent)
23
29
  }
24
- }, [dappName, dappNameParam, intentPayload, navigationType, sendIntent])
30
+
31
+ // sync back the dappNameParamRef for future checks
32
+ dappNameParamRef.current = dappNameParam
33
+ }, [dappNameParam, intentPayload, sendIntent])
25
34
 
26
35
  // auto-launch the dapp if the route param matches the dapp name
27
36
  usePromise(async () => {
28
- if (dappNameParam && dappName && sendIntent && intentCaller) {
37
+ if (dappNameParam && sendIntent && intentCaller) {
29
38
  const dappNameParamDeSlugged = new NameTransforms(dappNameParam).deSlug()
39
+ // no intents have been sent yet and the dappName param is set so we need to auto launch the dapp
40
+ const autoLaunchNeeded = intentRef.current === undefined && dappNameParam
30
41
 
31
- const notLaunched = intentPayload?.intent !== DappIntentTypes.Launch
32
- const paramMatchesDappName = dappNameParamDeSlugged === dappName
33
-
34
- if (notLaunched && paramMatchesDappName) {
35
- const latestIntent = await intentCaller.latestIntent()
36
- const existing = latestIntent && latestIntent.targetDappId === dappNameParamDeSlugged
37
- if (!existing) {
38
- const launchIntent = DappIntentCaller.buildIntent(DappIntentCaller.OsDappName, DappIntentTypes.Launch, dappNameParamDeSlugged)
39
- await sendIntent(launchIntent)
40
- return
41
- }
42
+ if (autoLaunchNeeded) {
43
+ const launchIntent = DappIntentCaller.buildIntent(DappIntentCaller.OsDappName, DappIntentTypes.Launch, dappNameParamDeSlugged)
44
+ await sendIntent(launchIntent)
45
+ // sync back the intentRef to ensure the auto launch only happens once
46
+ intentRef.current = launchIntent
47
+ return
42
48
  }
43
49
  }
44
- }, [dappNameParam, dappName, sendIntent, intentCaller, intentPayload?.intent])
50
+ }, [dappNameParam, sendIntent, intentCaller, intentPayload?.intent])
45
51
  }
@@ -1,2 +1 @@
1
1
  export * from './helpers/index.ts'
2
- export * from './useManageDappBasedOffRoute.js'
@@ -1,6 +0,0 @@
1
- import type { WidgetTrayLayout } from '@xyo-network/os-model';
2
- /**
3
- * NOTE: Hardcoded widget tray layout and hashes are of the widget config payloads located within the dapp's payloads
4
- */
5
- export declare const UpperWidgetTrayLayout: WidgetTrayLayout;
6
- //# sourceMappingURL=UpperWidgetTrayLayout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UpperWidgetTrayLayout.d.ts","sourceRoot":"","sources":["../../../../src/helpers/widgets/UpperWidgetTrayLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D;;GAEG;AAEH,eAAO,MAAM,qBAAqB,EAAE,gBAYnC,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './UpperWidgetTrayLayout.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/helpers/widgets/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
@@ -1,19 +0,0 @@
1
- import type { DappIntent, XyOsContext } from '@xyo-network/os-model';
2
- /**
3
- * Manage the dapp based off the route params and intent type
4
- *
5
- * This hook centralizes the logic for managing the dapp based off the route.
6
- *
7
- * It reacts to changes in the route params and performs the following:
8
- *
9
- * 1. Launch or close the dapp based off changes to the `dappName` route params
10
- * 2. Update the menu archivist based off changes in the the `path` route param
11
- * 3. Update the dapp archivist with injectable params based off changes in the query params
12
- *
13
- * @param intentPayload - The intent type of the dapp
14
- * @param dappName - The name of the dapp
15
- * @param dappNode - The node instance of the dapp
16
- * @param context - The context of the dapp
17
- */
18
- export declare const useManageDappBasedOffRoute: (intentPayload?: DappIntent, dappName?: string, context?: XyOsContext | null) => (Error | undefined)[];
19
- //# sourceMappingURL=useManageDappBasedOffRoute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useManageDappBasedOffRoute.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/useManageDappBasedOffRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AASpE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,mBAAoB,UAAU,aAAa,MAAM,YAAY,WAAW,GAAG,IAAI,0BAOrH,CAAA"}
@@ -1,8 +0,0 @@
1
- import type { XyOsContext } from '@xyo-network/os-model';
2
- import { DappIntentTypes } from '@xyo-network/os-model';
3
- export declare const dappState: (intentType?: DappIntentTypes, context?: XyOsContext | null) => {
4
- active: boolean | null | undefined;
5
- minimized: boolean;
6
- open: boolean;
7
- };
8
- //# sourceMappingURL=useDappState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDappState.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/Dapp/modules/Window/hooks/useDappState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,SAAS,gBAAiB,eAAe,YAAY,WAAW,GAAG,IAAI;;;;CAUnF,CAAA"}
@@ -1,20 +0,0 @@
1
- import type { WidgetTrayLayout } from '@xyo-network/os-model'
2
- import { WidgetTrayLayoutSchema } from '@xyo-network/os-model'
3
-
4
- /**
5
- * NOTE: Hardcoded widget tray layout and hashes are of the widget config payloads located within the dapp's payloads
6
- */
7
-
8
- export const UpperWidgetTrayLayout: WidgetTrayLayout = {
9
- label: 'Lower Widget Tray Layout',
10
- layout: [
11
- { dappId: 'TimeClock', mode: 'FlatClock' },
12
- {
13
- configHash: 'bb0ea5701c20e86d77b1a369f77d17658df62572d54f1f1aafdf15e3c29e3b3b', dappId: 'Markets', mode: 'PriceWidget',
14
- },
15
- {
16
- configHash: 'ea8afca9d4a9b0843035e3722d9f6400058a1eab71996b8e4e20e2449662e2bf', dappId: 'Markets', mode: 'PriceWidget',
17
- },
18
- ],
19
- schema: WidgetTrayLayoutSchema,
20
- }
@@ -1 +0,0 @@
1
- export * from './UpperWidgetTrayLayout.js'
@@ -1,33 +0,0 @@
1
- import type { DappIntent, XyOsContext } from '@xyo-network/os-model'
2
-
3
- import {
4
- useManageDappInjectableParamsFromRoute,
5
- useManageDappIntentRequest,
6
- useManageDappPathFromRoute,
7
- useManageDappStateFromRoute,
8
- } from './helpers/index.ts'
9
-
10
- /**
11
- * Manage the dapp based off the route params and intent type
12
- *
13
- * This hook centralizes the logic for managing the dapp based off the route.
14
- *
15
- * It reacts to changes in the route params and performs the following:
16
- *
17
- * 1. Launch or close the dapp based off changes to the `dappName` route params
18
- * 2. Update the menu archivist based off changes in the the `path` route param
19
- * 3. Update the dapp archivist with injectable params based off changes in the query params
20
- *
21
- * @param intentPayload - The intent type of the dapp
22
- * @param dappName - The name of the dapp
23
- * @param dappNode - The node instance of the dapp
24
- * @param context - The context of the dapp
25
- */
26
- export const useManageDappBasedOffRoute = (intentPayload?: DappIntent, dappName?: string, context?: XyOsContext | null) => {
27
- const handleIntentError = useManageDappIntentRequest(context, dappName)
28
- useManageDappStateFromRoute(intentPayload, dappName)
29
- useManageDappPathFromRoute(context, dappName)
30
- const injectableErrors = useManageDappInjectableParamsFromRoute(context)
31
-
32
- return [...injectableErrors, handleIntentError]
33
- }
@@ -1,14 +0,0 @@
1
- import type { XyOsContext } from '@xyo-network/os-model'
2
- import { DappIntentTypes } from '@xyo-network/os-model'
3
-
4
- export const dappState = (intentType?: DappIntentTypes, context?: XyOsContext | null) => {
5
- const minimized = intentType === DappIntentTypes.Minimize
6
- const open = intentType === DappIntentTypes.Launch
7
- const active = context && open
8
-
9
- return {
10
- active,
11
- minimized,
12
- open,
13
- }
14
- }