@xyo-network/os-react-runtime 4.2.0-rc.5 → 4.2.0-rc.7

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 (26) hide show
  1. package/dist/browser/index.mjs +21 -37
  2. package/dist/browser/index.mjs.map +1 -1
  3. package/dist/browser/modules/Dapp/modules/Window/DappWindow.d.ts +3 -3
  4. package/dist/browser/modules/Dapp/modules/Window/DappWindow.d.ts.map +1 -1
  5. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/index.d.ts +4 -4
  6. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/index.d.ts.map +1 -1
  7. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappInjectableParamsFromRoute.d.ts +1 -1
  8. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappInjectableParamsFromRoute.d.ts.map +1 -1
  9. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappPathFromRoute.d.ts +2 -0
  10. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappPathFromRoute.d.ts.map +1 -1
  11. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappStateFromRoute.d.ts +2 -2
  12. package/dist/browser/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappStateFromRoute.d.ts.map +1 -1
  13. package/dist/browser/modules/Dapp/modules/Window/hooks/route/index.d.ts +0 -1
  14. package/dist/browser/modules/Dapp/modules/Window/hooks/route/index.d.ts.map +1 -1
  15. package/package.json +9 -9
  16. package/src/hooks/os/useWidgetDapps.tsx +1 -1
  17. package/src/modules/Dapp/modules/Window/DappWindow.tsx +7 -8
  18. package/src/modules/Dapp/modules/Window/hooks/route/helpers/RoutingNodes.md +7 -0
  19. package/src/modules/Dapp/modules/Window/hooks/route/helpers/index.ts +4 -4
  20. package/src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappInjectableParamsFromRoute.tsx +1 -1
  21. package/src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappPathFromRoute.tsx +2 -0
  22. package/src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappStateFromRoute.tsx +26 -20
  23. package/src/modules/Dapp/modules/Window/hooks/route/index.ts +0 -1
  24. package/dist/browser/modules/Dapp/modules/Window/hooks/route/useManageDappBasedOffRoute.d.ts +0 -19
  25. package/dist/browser/modules/Dapp/modules/Window/hooks/route/useManageDappBasedOffRoute.d.ts.map +0 -1
  26. package/src/modules/Dapp/modules/Window/hooks/route/useManageDappBasedOffRoute.tsx +0 -33
@@ -1,10 +1,10 @@
1
- import type { DappIntent, XyOsContext } from '@xyo-network/os-model';
2
- import type { RegisteredReactDappSet } from '@xyo-network/os-react-model';
1
+ import type { DappIntent } from '@xyo-network/os-model';
2
+ import type { RegisteredReactDappSet, XyOsUiContext } from '@xyo-network/os-react-model';
3
3
  import type { WalletInstance } from '@xyo-network/wallet-model';
4
4
  import React from 'react';
5
5
  import type { DappState } from './hooks/index.ts';
6
6
  export interface DappWindowProps {
7
- context?: XyOsContext | null;
7
+ context?: XyOsUiContext | null;
8
8
  dappSet?: RegisteredReactDappSet;
9
9
  dappState?: DappState;
10
10
  dappWallet?: WalletInstance;
@@ -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,KAAK,EAAE,CAAA;IAChB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,eAAe,CAAC,EAAE,KAAK,CAAA;CACxB;AAED,gIAAgI;AAChI,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoHhD,CAAA"}
1
+ {"version":3,"file":"DappWindow.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/Dapp/modules/Window/DappWindow.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAIxF,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,aAAa,GAAG,IAAI,CAAA;IAC9B,OAAO,CAAC,EAAE,sBAAsB,CAAA;IAChC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,eAAe,CAAC,EAAE,KAAK,CAAA;CACxB;AAED,gIAAgI;AAChI,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoHhD,CAAA"}
@@ -1,5 +1,5 @@
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';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAA;AAC3D,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,kCAAkC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAA;AAC5D,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,mCAAmC,CAAA"}
@@ -1,4 +1,4 @@
1
1
  import type { XyOsContext } from '@xyo-network/os-model';
2
- /** React to change in the query params */
2
+ /** Update the dapp archivist with injectable params based off changes in the query params */
3
3
  export declare const useManageDappInjectableParamsFromRoute: (context?: XyOsContext | null) => (Error | undefined)[];
4
4
  //# sourceMappingURL=useManageDappInjectableParamsFromRoute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useManageDappInjectableParamsFromRoute.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappInjectableParamsFromRoute.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAOxD,0CAA0C;AAC1C,eAAO,MAAM,sCAAsC,aAAc,WAAW,GAAG,IAAI,0BA8ClF,CAAA"}
1
+ {"version":3,"file":"useManageDappInjectableParamsFromRoute.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappInjectableParamsFromRoute.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAOxD,6FAA6F;AAC7F,eAAO,MAAM,sCAAsC,aAAc,WAAW,GAAG,IAAI,0BA8ClF,CAAA"}
@@ -1,5 +1,7 @@
1
1
  import type { XyOsContext } from '@xyo-network/os-model';
2
2
  /**
3
+ * Update the menu archivist based off changes in the the `path` route param
4
+ *
3
5
  * Test Cases:
4
6
  *
5
7
  * 1. Clicking sidebar menu
@@ -1 +1 @@
1
- {"version":3,"file":"useManageDappPathFromRoute.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappPathFromRoute.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAUxD;;;;;;;;GAQG;AAEH,iDAAiD;AACjD,eAAO,MAAM,0BAA0B,aAAc,WAAW,GAAG,IAAI,aAAa,MAAM,SAiDzF,CAAA"}
1
+ {"version":3,"file":"useManageDappPathFromRoute.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappPathFromRoute.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAUxD;;;;;;;;;;GAUG;AAEH,iDAAiD;AACjD,eAAO,MAAM,0BAA0B,aAAc,WAAW,GAAG,IAAI,aAAa,MAAM,SAiDzF,CAAA"}
@@ -1,4 +1,4 @@
1
1
  import type { DappIntent } from '@xyo-network/os-model';
2
- /** React to changes in `dappName` route param */
3
- export declare const useManageDappStateFromRoute: (intentPayload?: DappIntent, dappName?: string) => void;
2
+ /** Launch or close the dapp based off changes to the `dappName` route param */
3
+ export declare const useManageDappStateFromRoute: (intentPayload?: DappIntent) => void;
4
4
  //# sourceMappingURL=useManageDappStateFromRoute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useManageDappStateFromRoute.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappStateFromRoute.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAOvD,iDAAiD;AACjD,eAAO,MAAM,2BAA2B,mBAAoB,UAAU,aAAa,MAAM,SAmCxF,CAAA"}
1
+ {"version":3,"file":"useManageDappStateFromRoute.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/helpers/useManageDappStateFromRoute.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAQvD,+EAA+E;AAC/E,eAAO,MAAM,2BAA2B,mBAAoB,UAAU,SAwCrE,CAAA"}
@@ -1,3 +1,2 @@
1
1
  export * from './helpers/index.ts';
2
- export * from './useManageDappBasedOffRoute.js';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,iCAAiC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/Dapp/modules/Window/hooks/route/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,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.5",
3
+ "version": "4.2.0-rc.7",
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.5",
52
- "@xyo-network/bios-model": "^4.2.0-rc.5",
51
+ "@xyo-network/bios-browser": "^4.2.0-rc.7",
52
+ "@xyo-network/bios-model": "^4.2.0-rc.7",
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.5",
59
- "@xyo-network/kernel-model": "^4.2.0-rc.5",
58
+ "@xyo-network/kernel": "^4.2.0-rc.7",
59
+ "@xyo-network/kernel-model": "^4.2.0-rc.7",
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.5",
65
- "@xyo-network/os-react-debug": "^4.2.0-rc.5",
66
- "@xyo-network/os-react-model": "^4.2.0-rc.5",
67
- "@xyo-network/os-runtime": "^4.2.0-rc.5",
64
+ "@xyo-network/os-model": "^4.2.0-rc.7",
65
+ "@xyo-network/os-react-debug": "^4.2.0-rc.7",
66
+ "@xyo-network/os-react-model": "^4.2.0-rc.7",
67
+ "@xyo-network/os-runtime": "^4.2.0-rc.7",
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",
@@ -15,7 +15,7 @@ export const useWidgetDapps = (
15
15
  ): [WidgetResults, Error | undefined, UsePromiseState | undefined] => {
16
16
  const context = useXyOsUiContext()
17
17
  return usePromise(async () => {
18
- if (registeredDapps && context && widgetTrayLayout) {
18
+ if (registeredDapps && registeredDapps.length > 0 && context && widgetTrayLayout) {
19
19
  const caller = new WidgetCaller(context, registeredDapps, widgetTrayLayout)
20
20
  return await caller.buildWidgetComponents()
21
21
  }
@@ -1,8 +1,7 @@
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 { DappIntent, XyOsContext } from '@xyo-network/os-model'
5
- 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'
6
5
  import { NameTransforms } from '@xyo-network/os-runtime'
7
6
  import { NodeProvider } from '@xyo-network/react-node'
8
7
  import { WalletProvider } from '@xyo-network/react-wallet'
@@ -22,7 +21,7 @@ import { DappLoadingFlexbox } from './LoadingFlexbox.js'
22
21
  import { DappBottomNavigation, DappMenuDrawer } from './menu/index.ts'
23
22
 
24
23
  export interface DappWindowProps {
25
- context?: XyOsContext | null
24
+ context?: XyOsUiContext | null
26
25
  dappSet?: RegisteredReactDappSet
27
26
  dappState?: DappState
28
27
  dappWallet?: WalletInstance
@@ -81,7 +80,7 @@ export const DappWindow: React.FC<DappWindowProps> = ({
81
80
  )}
82
81
  height="100dvh"
83
82
  width="100dvw"
84
- largeScreenMenu={(
83
+ largeScreenMenu={active && (
85
84
  <DappMenuDrawer
86
85
  context={context}
87
86
  name={name}
@@ -92,7 +91,7 @@ export const DappWindow: React.FC<DappWindowProps> = ({
92
91
  menuItems={menuItemsVisible}
93
92
  />
94
93
  )}
95
- smallScreenMenu={(
94
+ smallScreenMenu={active && (
96
95
  <DappBottomNavigation
97
96
  activePath={activePath}
98
97
  onPathChange={onPathChange}
@@ -107,8 +106,8 @@ export const DappWindow: React.FC<DappWindowProps> = ({
107
106
  {hasErrors
108
107
  ? (
109
108
  <FlexCol padding={2}>
110
- {resolvedErrors?.map((error, index) => (
111
- <ErrorRender key={index} error={error} scope="DappWindow" />
109
+ {resolvedErrors?.map(error => (
110
+ <ErrorRender key={error?.message} error={error} scope="DappWindow" />
112
111
  ))}
113
112
  </FlexCol>
114
113
  )
@@ -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,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,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
- }