@xyo-network/os-react-runtime 4.1.4 → 4.2.0-rc.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.
Files changed (42) hide show
  1. package/dist/browser/helpers/BridgeActivityHelper.d.ts +10 -10
  2. package/dist/browser/helpers/index.d.ts +0 -1
  3. package/dist/browser/helpers/index.d.ts.map +1 -1
  4. package/dist/browser/hooks/intent/useDappIntentListener.d.ts.map +1 -1
  5. package/dist/browser/hooks/os/useDappContextCreator.d.ts +2 -2
  6. package/dist/browser/hooks/os/useDappContextCreator.d.ts.map +1 -1
  7. package/dist/browser/hooks/useAccountArchivist.d.ts +10 -10
  8. package/dist/browser/index.mjs +411 -417
  9. package/dist/browser/index.mjs.map +1 -1
  10. package/dist/browser/modules/Dapp/Button/IconEx.d.ts +4 -2
  11. package/dist/browser/modules/Dapp/Button/IconEx.d.ts.map +1 -1
  12. package/dist/browser/modules/Dapp/Container.d.ts +3 -0
  13. package/dist/browser/modules/Dapp/Container.d.ts.map +1 -1
  14. package/dist/browser/modules/Dapp/Page/Row.d.ts.map +1 -1
  15. package/dist/browser/modules/Dapp/modules/Window/DappWindow.d.ts +8 -2
  16. package/dist/browser/modules/Dapp/modules/Window/DappWindow.d.ts.map +1 -1
  17. package/dist/browser/modules/Dapp/modules/Window/hooks/index.d.ts +1 -1
  18. package/dist/browser/modules/Dapp/modules/Window/hooks/index.d.ts.map +1 -1
  19. package/dist/browser/modules/Dapp/modules/Window/hooks/lib/deriveDappState.d.ts +8 -0
  20. package/dist/browser/modules/Dapp/modules/Window/hooks/lib/deriveDappState.d.ts.map +1 -0
  21. package/dist/browser/modules/Dapp/modules/Window/hooks/lib/index.d.ts +2 -1
  22. package/dist/browser/modules/Dapp/modules/Window/hooks/lib/index.d.ts.map +1 -1
  23. package/package.json +11 -10
  24. package/src/helpers/index.ts +0 -1
  25. package/src/hooks/intent/useDappIntentListener.tsx +3 -1
  26. package/src/hooks/os/useDappContextCreator.tsx +25 -19
  27. package/src/modules/Dapp/Button/IconEx.tsx +16 -13
  28. package/src/modules/Dapp/Container.tsx +33 -5
  29. package/src/modules/Dapp/Page/Row.tsx +13 -2
  30. package/src/modules/Dapp/modules/Window/DappWindow.tsx +16 -13
  31. package/src/modules/Dapp/modules/Window/hooks/index.ts +1 -1
  32. package/src/modules/Dapp/modules/Window/hooks/lib/deriveDappState.ts +20 -0
  33. package/src/modules/Dapp/modules/Window/hooks/lib/index.ts +2 -1
  34. package/dist/browser/helpers/widgets/UpperWidgetTrayLayout.d.ts +0 -6
  35. package/dist/browser/helpers/widgets/UpperWidgetTrayLayout.d.ts.map +0 -1
  36. package/dist/browser/helpers/widgets/index.d.ts +0 -2
  37. package/dist/browser/helpers/widgets/index.d.ts.map +0 -1
  38. package/dist/browser/modules/Dapp/modules/Window/hooks/useDappState.d.ts +0 -8
  39. package/dist/browser/modules/Dapp/modules/Window/hooks/useDappState.d.ts.map +0 -1
  40. package/src/helpers/widgets/UpperWidgetTrayLayout.ts +0 -20
  41. package/src/helpers/widgets/index.ts +0 -1
  42. package/src/modules/Dapp/modules/Window/hooks/useDappState.tsx +0 -14
@@ -1,10 +1,12 @@
1
1
  import type { ButtonExProps } from '@xylabs/react-button';
2
2
  import type { DappIcon, DappName } from '@xyo-network/os-model';
3
3
  import React from 'react';
4
- export type DappProps = ButtonExProps & {
4
+ import type { DappState } from '../modules/index.ts';
5
+ export type DappIconButtonProps = ButtonExProps & {
5
6
  dappIcon?: DappIcon;
6
7
  dappIconSvg?: string;
7
8
  dappName?: DappName;
9
+ dappState?: DappState;
8
10
  };
9
- export declare const DappIconButton: React.FC<DappProps>;
11
+ export declare const DappIconButton: React.FC<DappIconButtonProps>;
10
12
  //# sourceMappingURL=IconEx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IconEx.d.ts","sourceRoot":"","sources":["../../../../../src/modules/Dapp/Button/IconEx.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAG/D,OAAO,KAAiB,MAAM,OAAO,CAAA;AAYrC,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG;IACtC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAmE9C,CAAA"}
1
+ {"version":3,"file":"IconEx.d.ts","sourceRoot":"","sources":["../../../../../src/modules/Dapp/Button/IconEx.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACT,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAiB,MAAM,OAAO,CAAA;AAKrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAQpD,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAiExD,CAAA"}
@@ -1,9 +1,12 @@
1
+ import type { DappIntent } from '@xyo-network/os-model';
1
2
  import type { RegisteredReactDappSet } from '@xyo-network/os-react-model';
2
3
  import React from 'react';
3
4
  export interface DappContainerProps {
5
+ currentIntent?: DappIntent;
4
6
  dappSet: RegisteredReactDappSet;
5
7
  xnsNetwork: string | undefined;
6
8
  xnsNodeUrl: string | undefined;
7
9
  }
8
10
  export declare const DappContainer: React.FC<DappContainerProps>;
11
+ export declare const DappContainerMemo: React.NamedExoticComponent<DappContainerProps>;
9
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,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,WAAW,kBAAkB;IACjC,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,CAStD,CAAA"}
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":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,KAAkB,MAAM,OAAO,CAAA;AAMtC,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,CA6B5C,CAAA;AAED,eAAO,MAAM,mBAAmB,ySAQ7B,CAAA"}
1
+ {"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../../../src/modules/Dapp/Page/Row.tsx"],"names":[],"mappings":"AAIA,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,9 +1,15 @@
1
+ import type { DappIntent, XyOsContext } from '@xyo-network/os-model';
1
2
  import type { RegisteredReactDappSet } from '@xyo-network/os-react-model';
3
+ import type { WalletInstance } from '@xyo-network/wallet-model';
2
4
  import React from 'react';
5
+ import type { DappState } from './hooks/index.ts';
3
6
  export interface DappWindowProps {
7
+ context?: XyOsContext | null;
4
8
  dappSet?: RegisteredReactDappSet;
5
- xnsNetwork: string | undefined;
6
- xnsNodeUrl: string | undefined;
9
+ dappState?: DappState;
10
+ dappWallet?: WalletInstance;
11
+ intent?: DappIntent;
12
+ nodeCreateError?: Error;
7
13
  }
8
14
  /** A component that can load immediately, but delays node loading and dapp mounting till corresponding launch intent arrives */
9
15
  export declare const DappWindow: React.FC<DappWindowProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"DappWindow.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/Dapp/modules/Window/DappWindow.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAIzE,OAAO,KAAkB,MAAM,OAAO,CAAA;AActC,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,sBAAsB,CAAA;IAChC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B;AAED,gIAAgI;AAChI,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA0HhD,CAAA"}
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,CAwHhD,CAAA"}
@@ -1,6 +1,6 @@
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
4
  export * from './useDecomposeDappSet.js';
5
5
  export * from './useSkipLoadingScreen.js';
6
6
  export * from './useSyncOsRegisteredAccessInterfaces.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/Dapp/modules/Window/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0CAA0C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/Dapp/modules/Window/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0CAA0C,CAAA"}
@@ -0,0 +1,8 @@
1
+ import type { DappIntent, XyOsContext } from '@xyo-network/os-model';
2
+ export interface DappState {
3
+ active: boolean;
4
+ minimized: boolean;
5
+ open: boolean;
6
+ }
7
+ export declare const deriveDappState: (intent?: DappIntent, context?: XyOsContext | null) => DappState;
8
+ //# sourceMappingURL=deriveDappState.d.ts.map
@@ -0,0 +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,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGpE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,OAAO,CAAA;CACd;AAED,eAAO,MAAM,eAAe,YAAa,UAAU,YAAY,WAAW,GAAG,IAAI,KAAG,SAUnF,CAAA"}
@@ -1,2 +1,3 @@
1
- export * from './DappPathHelpers.js';
1
+ export * from './DappPathHelpers.ts';
2
+ export * from './deriveDappState.ts';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/Dapp/modules/Window/hooks/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/Dapp/modules/Window/hooks/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/os-react-runtime",
3
- "version": "4.1.4",
3
+ "version": "4.2.0-rc.2",
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.1.4",
52
- "@xyo-network/bios-model": "^4.1.4",
51
+ "@xyo-network/bios-browser": "^4.2.0-rc.2",
52
+ "@xyo-network/bios-model": "^4.2.0-rc.2",
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.1.4",
59
- "@xyo-network/kernel-model": "^4.1.4",
58
+ "@xyo-network/kernel": "^4.2.0-rc.2",
59
+ "@xyo-network/kernel-model": "^4.2.0-rc.2",
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.1.4",
65
- "@xyo-network/os-react-debug": "^4.1.4",
66
- "@xyo-network/os-react-model": "^4.1.4",
67
- "@xyo-network/os-runtime": "^4.1.4",
64
+ "@xyo-network/os-model": "^4.2.0-rc.2",
65
+ "@xyo-network/os-react-debug": "^4.2.0-rc.2",
66
+ "@xyo-network/os-react-model": "^4.2.0-rc.2",
67
+ "@xyo-network/os-runtime": "^4.2.0-rc.2",
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",
@@ -112,5 +112,6 @@
112
112
  },
113
113
  "publishConfig": {
114
114
  "access": "public"
115
- }
115
+ },
116
+ "stableVersion": "4.1.4"
116
117
  }
@@ -3,4 +3,3 @@ export * from './BrowserLocator.js'
3
3
  export * from './monitor/index.ts'
4
4
  export * from './NodePalettes.js'
5
5
  export * from './widget/index.ts'
6
- export * from './widgets/index.ts'
@@ -16,7 +16,9 @@ export const useDappIntentListener = (dappName?: string | null, targetMode = Dap
16
16
  const listener = ({ payloads }: ArchivistModuleEventData['inserted']) => {
17
17
  const filteredPayloads = payloads.filter(isDappIntentWithMeta)
18
18
  for (const payload of filteredPayloads) {
19
- if (payload.targetDappId === dappName && payload.targetMode === targetMode) {
19
+ const allDapps = dappName === null && payload.targetMode === targetMode
20
+ const targetDapps = dappName === payload.targetDappId && payload.targetMode === targetMode
21
+ if (allDapps || targetDapps) {
20
22
  setIntentPayload(payload)
21
23
  switch (payload.intent) {
22
24
  case DappIntentTypes.Close: {
@@ -1,5 +1,7 @@
1
1
  import { useAsyncEffect } from '@xylabs/react-async-effect'
2
- import type { RegisteredDapp, WindowDappNodeSet } from '@xyo-network/os-model'
2
+ import type {
3
+ DappIntent, RegisteredDapp, WindowDappNodeSet,
4
+ } from '@xyo-network/os-model'
3
5
  import { DappIntentTypes } from '@xyo-network/os-model'
4
6
  import { DappContextCreator, RunningDappCache } from '@xyo-network/os-runtime'
5
7
  import {
@@ -7,7 +9,6 @@ import {
7
9
  } from 'react'
8
10
 
9
11
  import { useXyOsUiContext } from '../../modules/index.ts'
10
- import { useDappIntentListener } from '../intent/index.ts'
11
12
 
12
13
  /**
13
14
  * Creates a dapp node for the provided dapp and name
@@ -18,6 +19,7 @@ export const useDappContextCreator = (
18
19
  xnsNodeUrl: string | undefined,
19
20
  xnsNetwork: string | undefined,
20
21
  dapp?: RegisteredDapp,
22
+ currentIntent?: DappIntent,
21
23
  allowedNames?: string[],
22
24
  createOnMount = false,
23
25
  ): WindowDappNodeSet & {
@@ -26,7 +28,8 @@ export const useDappContextCreator = (
26
28
  const context = useXyOsUiContext()
27
29
  const [windowDappNodeSet, setWindowDappNodeSet] = useState<WindowDappNodeSet>({ context: undefined, dappWallet: undefined })
28
30
  const [dappWindowNodeError, setDappWindowNodeError] = useState<Error>()
29
- const { dappIntentType: intentType } = useDappIntentListener(dapp?.config.name)
31
+ // ensure the dapp is targeted by the current intent
32
+ const targetedDapp = !!(dapp && context && currentIntent?.targetDappId === dapp?.config.name)
30
33
 
31
34
  // Keep a ref of the windowDappNodeSet to use in effect hooks without needing it as a dependency
32
35
  const windowDappNodeSetRef = useRef<WindowDappNodeSet>(windowDappNodeSet)
@@ -35,7 +38,7 @@ export const useDappContextCreator = (
35
38
  }, [windowDappNodeSet])
36
39
 
37
40
  const createNode = useCallback(async () => {
38
- if (dapp && context) {
41
+ if (targetedDapp) {
39
42
  try {
40
43
  const windowDappNodeSet = await RunningDappCache.findOrCreate(dapp, context, allowedNames ?? [], xnsNodeUrl, xnsNetwork)
41
44
  setWindowDappNodeSet(windowDappNodeSet)
@@ -43,7 +46,7 @@ export const useDappContextCreator = (
43
46
  setDappWindowNodeError(e as Error)
44
47
  }
45
48
  }
46
- }, [dapp, context, allowedNames])
49
+ }, [dapp, currentIntent, context, allowedNames])
47
50
 
48
51
  useEffect(() => {
49
52
  if (createOnMount) {
@@ -57,24 +60,27 @@ export const useDappContextCreator = (
57
60
  useAsyncEffect(
58
61
 
59
62
  async () => {
60
- switch (intentType) {
61
- case DappIntentTypes.Launch: {
62
- await createNode()
63
- break
64
- }
65
- case DappIntentTypes.Close: {
66
- if (windowDappNodeSetRef.current.context) {
67
- // In case a cached dapp was closed, clear its Dapp Archivist to allow for a fresh start upon next launch
68
- await DappContextCreator.resetDappArchivist(windowDappNodeSetRef.current.context)
69
- setWindowDappNodeSet({ context: null, dappWallet: undefined })
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
70
77
  }
71
- break
78
+ case DappIntentTypes.Minimize:
79
+ // do nothing
72
80
  }
73
- case DappIntentTypes.Minimize:
74
- // do nothing
75
81
  }
76
82
  },
77
- [createNode, intentType],
83
+ [createNode, currentIntent],
78
84
  )
79
85
 
80
86
  return {
@@ -2,14 +2,18 @@
2
2
  import { Circle } from '@mui/icons-material'
3
3
  import type { ButtonExProps } from '@xylabs/react-button'
4
4
  import { FlexCol } from '@xylabs/react-flexbox'
5
- import type { DappIcon, DappName } from '@xyo-network/os-model'
5
+ import type {
6
+ DappIcon,
7
+ DappName,
8
+ } from '@xyo-network/os-model'
6
9
  import { DappIntentTypes } from '@xyo-network/os-model'
7
10
  import { DappIntentCaller, XyOsMonitor } from '@xyo-network/os-runtime'
8
11
  import React, { useRef } from 'react'
9
12
 
10
13
  import { RenderHtml } from '../../../components/index.ts'
11
- import { useDappIntentListener, useSendDappIntent } from '../../../hooks/index.ts'
14
+ import { useSendDappIntent } from '../../../hooks/index.ts'
12
15
  import { DEFAULT_ICON_SIZE } from '../lib/index.ts'
16
+ import type { DappState } from '../modules/index.ts'
13
17
  import { useLaunchPoint } from './hooks/index.ts'
14
18
  import { DappLaunchFrame } from './LaunchFrame.js'
15
19
  import { decomposeProps } from './lib/index.ts'
@@ -17,36 +21,35 @@ import {
17
21
  StyledDappIconButtonEx, StyledDappName, StyledDefaultDappIcon,
18
22
  } from './StyledComponents.js'
19
23
 
20
- export type DappProps = ButtonExProps & {
24
+ export type DappIconButtonProps = ButtonExProps & {
21
25
  dappIcon?: DappIcon
22
26
  dappIconSvg?: string
23
27
  dappName?: DappName
28
+ dappState?: DappState
24
29
  }
25
30
 
26
- export const DappIconButton: React.FC<DappProps> = ({
27
- children, dappIcon, dappIconSvg, dappName, ...props
31
+ export const DappIconButton: React.FC<DappIconButtonProps> = ({
32
+ children, dappIcon, dappIconSvg, dappName, dappState, ...props
28
33
  }) => {
29
34
  const {
30
35
  DappIconSize, color, nonSxProps, sx,
31
36
  } = decomposeProps(dappIcon, props)
32
37
  const iconSize = DEFAULT_ICON_SIZE
33
38
 
39
+ const { active, minimized } = dappState ?? {}
40
+
34
41
  // Functions to invoke Dapp intents
35
42
  const sendIntent = useSendDappIntent()
36
43
 
37
- // Current state of the dapp based off intents
38
- const { dappIntentType: intentType } = useDappIntentListener(dappName)
39
-
40
44
  // Use the DappIconButton to calculate the launch point for the DappWindow
41
45
  const iconButtonRef = useRef<HTMLSpanElement>(null)
42
46
  const { left: launchLeft, top: launchTop } = useLaunchPoint(iconButtonRef)
43
47
 
44
- const minimized = intentType === DappIntentTypes.Minimize
45
48
  const MiddleEllipsisFunction = (str: DappName | undefined) => {
46
49
  if (str && str.length > 25) {
47
- console.log(str)
48
- console.log(str.slice(0, 15))
49
- console.log(str.slice(-10, str.length - 10 + str.length))
50
+ // console.log(str)
51
+ // console.log(str.slice(0, 15))
52
+ // console.log(str.slice(-10, str.length - 10 + str.length))
50
53
  return str.slice(0, 15) + '...' + str.slice(-7, str.length - 7 + str.length)
51
54
  }
52
55
  return str
@@ -59,7 +62,7 @@ export const DappIconButton: React.FC<DappProps> = ({
59
62
 
60
63
  return (
61
64
  <FlexCol alignItems="stretch" justifyContent="stretch">
62
- <DappLaunchFrame id="dapp-launch-frame" open={intentType === DappIntentTypes.Launch} launchLeft={launchLeft} launchTop={launchTop}>
65
+ <DappLaunchFrame id="dapp-launch-frame" open={!!active} launchLeft={launchLeft} launchTop={launchTop}>
63
66
  {children}
64
67
  </DappLaunchFrame>
65
68
  <span
@@ -1,22 +1,50 @@
1
+ import type { DappIntent } from '@xyo-network/os-model'
1
2
  import type { RegisteredReactDappSet } from '@xyo-network/os-react-model'
2
- import React from 'react'
3
+ import React, { memo, useMemo } from 'react'
3
4
 
5
+ import { useDappContextCreator } from '../../hooks/index.ts'
4
6
  import { DappIconButton } from './Button/index.ts'
5
- import { DappWindow } from './modules/Window/index.ts'
7
+ import { DappWindow, deriveDappState } from './modules/index.ts'
6
8
 
7
9
  export interface DappContainerProps {
10
+ currentIntent?: DappIntent
8
11
  dappSet: RegisteredReactDappSet
9
12
  xnsNetwork: string | undefined
10
13
  xnsNodeUrl: string | undefined
11
14
  }
12
15
 
13
16
  export const DappContainer: React.FC<DappContainerProps> = ({
14
- dappSet, xnsNodeUrl, xnsNetwork,
17
+ currentIntent, dappSet, xnsNodeUrl, xnsNetwork,
15
18
  }) => {
16
19
  const { dapp, dappIcon } = dappSet
20
+
21
+ const {
22
+ dappWallet, context, nodeCreateError,
23
+ } = useDappContextCreator(xnsNodeUrl, xnsNetwork, dapp, currentIntent)
24
+
25
+ const dappState = useMemo(() => {
26
+ if (currentIntent?.targetDappId === dapp.config.name) {
27
+ return deriveDappState(currentIntent, context)
28
+ }
29
+ }, [currentIntent, context, dapp])
30
+
17
31
  return (
18
- <DappIconButton dappIcon={dappIcon} dappIconSvg={dapp.params.iconSvg} dappName={dapp?.config.name}>
19
- <DappWindow dappSet={dappSet} xnsNodeUrl={xnsNodeUrl} xnsNetwork={xnsNetwork} />
32
+ <DappIconButton
33
+ dappIcon={dappIcon}
34
+ dappIconSvg={dapp.params.iconSvg}
35
+ dappName={dapp?.config.name}
36
+ dappState={dappState}
37
+ >
38
+ <DappWindow
39
+ context={context}
40
+ dappSet={dappSet}
41
+ dappState={dappState}
42
+ dappWallet={dappWallet}
43
+ intent={currentIntent}
44
+ nodeCreateError={nodeCreateError}
45
+ />
20
46
  </DappIconButton>
21
47
  )
22
48
  }
49
+
50
+ export const DappContainerMemo = memo(DappContainer)
@@ -6,8 +6,9 @@ import type { InstallationType } from '@xyo-network/os-model'
6
6
  import type { RegisteredReactDappSet } from '@xyo-network/os-react-model'
7
7
  import React, { useMemo } from 'react'
8
8
 
9
+ import { useDappIntentListener } from '../../../hooks/index.ts'
9
10
  import { DappInstallTypeFilters } from '../../../utils/index.ts'
10
- import { DappContainer } from '../Container.js'
11
+ import { DappContainerMemo } from '../Container.tsx'
11
12
  import { DividerChip } from './DividerChip.js'
12
13
 
13
14
  export interface DappsRowProps {
@@ -22,6 +23,8 @@ export const DappsRow: React.FC<DappsRowProps> = ({
22
23
  chipLabel, installType, registeredDappsSet, xnsNetwork, xnsNodeUrl,
23
24
  }) => {
24
25
  const filteredRegisteredDappSets = useMemo(() => DappInstallTypeFilters[installType](registeredDappsSet), [installType, registeredDappsSet])
26
+ const { intentPayload } = useDappIntentListener(null)
27
+
25
28
  return (
26
29
  <>
27
30
  <Divider
@@ -39,7 +42,15 @@ export const DappsRow: React.FC<DappsRowProps> = ({
39
42
  <Fade in={!!filteredRegisteredDappSets?.length} timeout={1000}>
40
43
  <StyledGridContainer>
41
44
  {filteredRegisteredDappSets?.map(
42
- (dappSet, index) => <DappContainer key={index} dappSet={dappSet as RegisteredReactDappSet} xnsNodeUrl={xnsNodeUrl} xnsNetwork={xnsNetwork} />,
45
+ (dappSet, index) => (
46
+ <DappContainerMemo
47
+ currentIntent={intentPayload}
48
+ key={index}
49
+ dappSet={dappSet as RegisteredReactDappSet}
50
+ xnsNodeUrl={xnsNodeUrl}
51
+ xnsNetwork={xnsNetwork}
52
+ />
53
+ ),
43
54
  )}
44
55
  </StyledGridContainer>
45
56
  </Fade>
@@ -1,50 +1,53 @@
1
1
  /* eslint-disable @eslint-react/no-array-index-key */
2
2
  import { ErrorBoundary, ErrorRender } from '@xylabs/react-error'
3
3
  import { FlexCol } from '@xylabs/react-flexbox'
4
+ import type { DappIntent, XyOsContext } from '@xyo-network/os-model'
4
5
  import type { RegisteredReactDappSet } from '@xyo-network/os-react-model'
5
6
  import { NameTransforms } from '@xyo-network/os-runtime'
6
7
  import { NodeProvider } from '@xyo-network/react-node'
7
8
  import { WalletProvider } from '@xyo-network/react-wallet'
9
+ import type { WalletInstance } from '@xyo-network/wallet-model'
8
10
  import React, { useMemo } from 'react'
9
11
  import { Helmet } from 'react-helmet'
10
12
 
11
- import { useDappContextCreator, useDappIntentListener } from '../../../../hooks/index.ts'
12
13
  import { XyOsUiContextProvider } from '../../../XyOsUi/index.ts'
13
14
  import { DappAccessFlexbox } from '../access-interface/index.ts'
14
15
  import { DappBar } from './AppBar.js'
15
16
  import { DappChrome } from './Chrome.js'
17
+ import type { DappState } from './hooks/index.ts'
16
18
  import {
17
- dappState, decomposeDappSet, useDappMenu, useManageDappBasedOffRoute, useSyncOsRegisteredAccessInterfaces,
19
+ decomposeDappSet, useDappMenu, useManageDappBasedOffRoute, useSyncOsRegisteredAccessInterfaces,
18
20
  } from './hooks/index.ts'
19
21
  import { DappLoadingFlexbox } from './LoadingFlexbox.js'
20
22
  import { DappBottomNavigation, DappMenuDrawer } from './menu/index.ts'
21
23
 
22
24
  export interface DappWindowProps {
25
+ context?: XyOsContext | null
23
26
  dappSet?: RegisteredReactDappSet
24
- xnsNetwork: string | undefined
25
- xnsNodeUrl: string | undefined
27
+ dappState?: DappState
28
+ dappWallet?: WalletInstance
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, intent, 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)
40
+
39
41
  const {
40
42
  active, minimized, open,
41
- } = dappState(intentType, context)
43
+ } = dappState ?? {}
42
44
 
43
45
  const TypedDappComponent = useMemo(() => DappComponent as React.FC<{
44
46
  name?: string
45
47
  }>, [])
46
48
 
47
- const errors = useManageDappBasedOffRoute(intentPayload, name, context)
49
+ // TODO - see if we can move this outside of the DappWindow component
50
+ const errors = useManageDappBasedOffRoute(intent, name, context)
48
51
  useSyncOsRegisteredAccessInterfaces(context)
49
52
 
50
53
  const {
@@ -99,7 +102,7 @@ export const DappWindow: React.FC<DappWindowProps> = ({
99
102
  />
100
103
  )}
101
104
  /* Ensure that loading goes away when error occurs */
102
- splashScreen={resolvedError ? null : <DappLoadingFlexbox minimize={minimized} name={name} open={open} />}
105
+ splashScreen={resolvedError ? null : <DappLoadingFlexbox minimize={!!minimized} name={name} open={!!open} />}
103
106
  >
104
107
  {resolvedError || errors?.length > 0
105
108
  ? (
@@ -1,6 +1,6 @@
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
4
  export * from './useDecomposeDappSet.js'
5
5
  export * from './useSkipLoadingScreen.js'
6
6
  export * from './useSyncOsRegisteredAccessInterfaces.js'
@@ -0,0 +1,20 @@
1
+ import type { DappIntent, XyOsContext } from '@xyo-network/os-model'
2
+ import { DappIntentTypes } from '@xyo-network/os-model'
3
+
4
+ export interface DappState {
5
+ active: boolean
6
+ minimized: boolean
7
+ open: boolean
8
+ }
9
+
10
+ export const deriveDappState = (intent?: DappIntent, context?: XyOsContext | null): DappState => {
11
+ const minimized = intent?.intent === DappIntentTypes.Minimize
12
+ const open = intent?.intent === DappIntentTypes.Launch
13
+ const active = !!(context && open)
14
+
15
+ return {
16
+ active,
17
+ minimized,
18
+ open,
19
+ }
20
+ }
@@ -1 +1,2 @@
1
- export * from './DappPathHelpers.js'
1
+ export * from './DappPathHelpers.ts'
2
+ export * from './deriveDappState.ts'
@@ -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,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,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
- }