@tuwaio/satellite-react 1.0.0-fix-packages-alpha.1.bd0ce80 → 1.0.0-fix-packages-alpha.3.bf8071b
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/{chunk-YC7F3NGW.cjs → chunk-BKNDP4VE.cjs} +2 -2
- package/dist/chunk-BKNDP4VE.cjs.map +1 -0
- package/dist/{chunk-3WMGCMYX.js → chunk-VXHPTE35.js} +2 -2
- package/dist/chunk-VXHPTE35.js.map +1 -0
- package/dist/evm/index.cjs +1 -1
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.js +1 -1
- package/dist/evm/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/solana/index.cjs +1 -1
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.js +1 -1
- package/dist/solana/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-3WMGCMYX.js.map +0 -1
- package/dist/chunk-YC7F3NGW.cjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var react=require('react'),zustand=require('zustand'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var r=react.createContext(null),A=e=>{let t=react.useContext(r);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return zustand.useStore(t,e)};var i=({initializeAutoConnect:e,onError:t})=>{react.useEffect(()=>{(async()=>{try{await e();}catch(o){(t??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...n}),[]);return react.useEffect(()=>{o.getState().disconnectAll();},[]),i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsxRuntime.jsx(r.Provider,{value:o,children:e})}exports.a=r;exports.b=A;exports.c=i;exports.d=b;//# sourceMappingURL=chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var react=require('react'),zustand=require('zustand'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var r=react.createContext(null),A=e=>{let t=react.useContext(r);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return zustand.useStore(t,e)};var i=({initializeAutoConnect:e,onError:t})=>{react.useEffect(()=>{(async()=>{try{await e();}catch(o){(t??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...n}),[]);return react.useEffect(()=>{o.getState().disconnectAll();},[]),i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsxRuntime.jsx(r.Provider,{value:o,children:e})}exports.a=r;exports.b=A;exports.c=i;exports.d=b;//# sourceMappingURL=chunk-BKNDP4VE.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-BKNDP4VE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/satteliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"+JAUaA,CAAAA,CAAwBC,mBAAAA,CAA0E,IAAI,CAAA,CAqBtGC,EAA+BC,CAAAA,EAAyE,CAEnH,IAAMC,CAAAA,CAAQC,gBAAAA,CAAWL,CAAqB,CAAA,CAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,gBAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECDO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,eAAAA,CAAU,IAAM,EACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,EAEOF,CAAAA,GAAaG,CAAAA,EAAa,OAAA,CAAQ,KAAA,CAAM,qCAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,SAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,CAAA,CAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,cAAQ,IACbC,yCAAAA,CAA+C,CACpD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAGL,OAAAN,eAAAA,CAAU,IAAM,CACdN,CAAAA,CAAM,QAAA,EAAS,CAAE,aAAA,GAEnB,CAAA,CAAG,EAAE,CAAA,CAELG,EAAyB,CACvB,qBAAA,CAAuB,IAAMH,CAAAA,CAAM,UAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,cAAAA,CAACnB,CAAAA,CAAsB,SAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-BKNDP4VE.cjs","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connector, Wallet } from '../types';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore<Connector, Wallet>> | null>(null);\n\n/**\n * Custom hook for accessing the Satellite Connect store state\n *\n * @remarks\n * This hook provides type-safe access to the Satellite store state and must be used\n * within a component that is wrapped by SatelliteConnectProvider.\n *\n * @typeParam T - The type of the selected state slice\n * @param selector - Function that selects a slice of the store state\n * @returns Selected state slice\n *\n * @throws Error if used outside of SatelliteConnectProvider\n *\n * @example\n * ```tsx\n * // Get the active connection\n * const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);\n * ```\n */\nexport const useSatelliteConnectStore = <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T): T => {\n // Get store instance from context\n const store = useContext(SatelliteStoreContext);\n\n // Ensure hook is used within provider\n if (!store) {\n throw new Error('useSatelliteConnectStore must be used within a SatelliteConnectProvider');\n }\n\n // Return selected state using Zustand's useStore\n return useStore(store, selector);\n};\n","import { useEffect } from 'react';\n\n/**\n * Props for the useInitializeAutoConnect hook.\n */\ninterface InitializeAutoConnectProps {\n /** Function to initialize auto connect logic */\n initializeAutoConnect: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing wallet auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected wallet) when a component mounts.\n * It provides default error handling with console.error if no custom handler is provided.\n * The initialization runs only once when the component mounts.\n *\n * @param props - Hook configuration\n * @param props.initializeAutoConnect - Async function that executes the auto-connect logic\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect\n * });\n *\n * // With custom error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect,\n * onError: (error) => {\n * toast.error(`Failed to auto-connect: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAutoConnect = ({ initializeAutoConnect, onError }: InitializeAutoConnectProps): void => {\n useEffect(() => {\n const initializeAutoConnectLocal = async () => {\n try {\n await initializeAutoConnect();\n } catch (error) {\n // Use provided error handler or fallback to default console.error\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize auto connect:', e));\n errorHandler(error as Error);\n }\n };\n // Initialize auto connect when component mounts\n initializeAutoConnectLocal();\n }, []); // Empty dependency array ensures single execution\n};\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useEffect, useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satteliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connector, Wallet } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used wallet */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages wallet connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles wallet connections, state management, and automatic reconnection functionality.\n * The store is memoized to ensure stable reference across renders.\n *\n * @param props - Component properties including store parameters and children\n * @param props.children - Child components that will have access to the store\n * @param props.autoConnect - Optional flag to enable automatic wallet reconnection\n * @param props.adapter - Blockchain adapter(s) for wallet interactions\n * @param props.callbackAfterConnected - Optional callback for successful connections\n *\n * @example\n * ```tsx\n * // Basic usage with single adapter\n * <SatelliteConnectProvider adapter={solanaAdapter}>\n * <App />\n * </SatelliteConnectProvider>\n *\n * // With auto-connect and multiple adapters\n * <SatelliteConnectProvider\n * adapter={[solanaAdapter, evmAdapter]}\n * autoConnect={true}\n * callbackAfterConnected={(wallet) => {\n * console.log('Wallet connected:', wallet.address);\n * }}\n * >\n * <App />\n * </SatelliteConnectProvider>\n * ```\n */\nexport function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps) {\n // Create and memoize the store instance\n const store = useMemo(() => {\n return createSatelliteConnectStore<Connector, Wallet>({\n ...parameters,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Empty dependency array as store should be created only once\n\n // Disconnect from any existing wallets on mount\n useEffect(() => {\n store.getState().disconnectAll();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {createContext,useContext,useEffect,useMemo}from'react';import {useStore}from'zustand';import {createSatelliteConnectStore}from'@tuwaio/satellite-core';import {jsx}from'react/jsx-runtime';var r=createContext(null),A=e=>{let t=useContext(r);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return useStore(t,e)};var i=({initializeAutoConnect:e,onError:t})=>{useEffect(()=>{(async()=>{try{await e();}catch(o){(t??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=useMemo(()=>createSatelliteConnectStore({...n}),[]);return useEffect(()=>{o.getState().disconnectAll();},[]),i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsx(r.Provider,{value:o,children:e})}export{r as a,A as b,i as c,b as d};//# sourceMappingURL=chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {createContext,useContext,useEffect,useMemo}from'react';import {useStore}from'zustand';import {createSatelliteConnectStore}from'@tuwaio/satellite-core';import {jsx}from'react/jsx-runtime';var r=createContext(null),A=e=>{let t=useContext(r);if(!t)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return useStore(t,e)};var i=({initializeAutoConnect:e,onError:t})=>{useEffect(()=>{(async()=>{try{await e();}catch(o){(t??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=useMemo(()=>createSatelliteConnectStore({...n}),[]);return useEffect(()=>{o.getState().disconnectAll();},[]),i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsx(r.Provider,{value:o,children:e})}export{r as a,A as b,i as c,b as d};//# sourceMappingURL=chunk-VXHPTE35.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-VXHPTE35.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/satteliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"uMAUaA,CAAAA,CAAwBC,aAAAA,CAA0E,IAAI,CAAA,CAqBtGC,EAA+BC,CAAAA,EAAyE,CAEnH,IAAMC,CAAAA,CAAQC,UAAAA,CAAWL,CAAqB,CAAA,CAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,QAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECDO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,SAAAA,CAAU,IAAM,EACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,EAEOF,CAAAA,GAAaG,CAAAA,EAAa,OAAA,CAAQ,KAAA,CAAM,qCAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,SAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,CAAA,CAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,QAAQ,IACbC,2BAAAA,CAA+C,CACpD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAGL,OAAAN,SAAAA,CAAU,IAAM,CACdN,CAAAA,CAAM,QAAA,EAAS,CAAE,aAAA,GAEnB,CAAA,CAAG,EAAE,CAAA,CAELG,EAAyB,CACvB,qBAAA,CAAuB,IAAMH,CAAAA,CAAM,UAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,GAAAA,CAACnB,CAAAA,CAAsB,SAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-VXHPTE35.js","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connector, Wallet } from '../types';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore<Connector, Wallet>> | null>(null);\n\n/**\n * Custom hook for accessing the Satellite Connect store state\n *\n * @remarks\n * This hook provides type-safe access to the Satellite store state and must be used\n * within a component that is wrapped by SatelliteConnectProvider.\n *\n * @typeParam T - The type of the selected state slice\n * @param selector - Function that selects a slice of the store state\n * @returns Selected state slice\n *\n * @throws Error if used outside of SatelliteConnectProvider\n *\n * @example\n * ```tsx\n * // Get the active connection\n * const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);\n * ```\n */\nexport const useSatelliteConnectStore = <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T): T => {\n // Get store instance from context\n const store = useContext(SatelliteStoreContext);\n\n // Ensure hook is used within provider\n if (!store) {\n throw new Error('useSatelliteConnectStore must be used within a SatelliteConnectProvider');\n }\n\n // Return selected state using Zustand's useStore\n return useStore(store, selector);\n};\n","import { useEffect } from 'react';\n\n/**\n * Props for the useInitializeAutoConnect hook.\n */\ninterface InitializeAutoConnectProps {\n /** Function to initialize auto connect logic */\n initializeAutoConnect: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing wallet auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected wallet) when a component mounts.\n * It provides default error handling with console.error if no custom handler is provided.\n * The initialization runs only once when the component mounts.\n *\n * @param props - Hook configuration\n * @param props.initializeAutoConnect - Async function that executes the auto-connect logic\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect\n * });\n *\n * // With custom error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect,\n * onError: (error) => {\n * toast.error(`Failed to auto-connect: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAutoConnect = ({ initializeAutoConnect, onError }: InitializeAutoConnectProps): void => {\n useEffect(() => {\n const initializeAutoConnectLocal = async () => {\n try {\n await initializeAutoConnect();\n } catch (error) {\n // Use provided error handler or fallback to default console.error\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize auto connect:', e));\n errorHandler(error as Error);\n }\n };\n // Initialize auto connect when component mounts\n initializeAutoConnectLocal();\n }, []); // Empty dependency array ensures single execution\n};\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useEffect, useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satteliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connector, Wallet } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used wallet */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages wallet connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles wallet connections, state management, and automatic reconnection functionality.\n * The store is memoized to ensure stable reference across renders.\n *\n * @param props - Component properties including store parameters and children\n * @param props.children - Child components that will have access to the store\n * @param props.autoConnect - Optional flag to enable automatic wallet reconnection\n * @param props.adapter - Blockchain adapter(s) for wallet interactions\n * @param props.callbackAfterConnected - Optional callback for successful connections\n *\n * @example\n * ```tsx\n * // Basic usage with single adapter\n * <SatelliteConnectProvider adapter={solanaAdapter}>\n * <App />\n * </SatelliteConnectProvider>\n *\n * // With auto-connect and multiple adapters\n * <SatelliteConnectProvider\n * adapter={[solanaAdapter, evmAdapter]}\n * autoConnect={true}\n * callbackAfterConnected={(wallet) => {\n * console.log('Wallet connected:', wallet.address);\n * }}\n * >\n * <App />\n * </SatelliteConnectProvider>\n * ```\n */\nexport function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps) {\n // Create and memoize the store instance\n const store = useMemo(() => {\n return createSatelliteConnectStore<Connector, Wallet>({\n ...parameters,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Empty dependency array as store should be created only once\n\n // Disconnect from any existing wallets on mount\n useEffect(() => {\n store.getState().disconnectAll();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}
|
package/dist/evm/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkBKNDP4VE_cjs=require('../chunk-BKNDP4VE.cjs'),orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react');function S({wagmiConfig:r,siwe:n}){let e=chunkBKNDP4VE_cjs.b(t=>t.activeConnection),a=chunkBKNDP4VE_cjs.b(t=>t.disconnect),p=chunkBKNDP4VE_cjs.b(t=>t.walletConnectionError),m=chunkBKNDP4VE_cjs.b(t=>t.updateActiveConnection);return react.useEffect(()=>{n?.enabled&&!n?.isSignedIn&&n?.isRejected&&e&&a(e.walletType);},[n,a,e]),react.useEffect(()=>core.watchConnections(r,{onChange:l=>{if(e&&orbitCore.getAdapterFromWalletType(e.walletType)!==orbitCore.OrbitAdapter.EVM)return;if(l.length===0){e&&a(e.walletType);return}let i=r.state.current?l.find(c=>c.connector.uid===r.state.current):l[0];if(!i){e&&a(e.walletType);return}let s=i.accounts[0],d=i.chainId;if(e&&orbitCore.getAdapterFromWalletType(e.walletType)!==orbitCore.OrbitAdapter.EVM||!s||p)return;if(n?.enabled?n.isSignedIn:true){let c=e?.walletType,u=r.chains.find(E=>E.id===d)?.rpcUrls.default.http[0];m(c?{walletType:c,address:s,chainId:d,rpcURL:u,isConnected:true}:{address:s,chainId:d,rpcURL:u,isConnected:true});}}}),[e?.walletType,n,p]),null}exports.EVMWalletsWatcher=S;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/evm/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","
|
|
1
|
+
{"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","activeConnection","useSatelliteConnectStore","store","disconnect","walletConnectionError","updateActiveConnection","useEffect","watchConnections","connections","getAdapterFromWalletType","OrbitAdapter","currentConnection","primaryAccount","chainId","walletType","rpcURL","c"],"mappings":"+JAiDO,SAASA,EAAkB,CAAE,WAAA,CAAAC,EAAa,IAAA,CAAAC,CAAK,CAAA,CAA2B,CAU/E,IAAMC,CAAAA,CAAmBC,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CAI7EC,CAAAA,CAAaF,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,CAAAA,CAAwBH,mBAAAA,CAA0BC,GAAUA,CAAAA,CAAM,qBAAqB,CAAA,CAIvFG,CAAAA,CAAyBJ,mBAAAA,CAA0BC,CAAAA,EAAUA,EAAM,sBAAsB,CAAA,CAY/F,OAAAI,eAAAA,CAAU,IAAM,CACVP,GAAM,OAAA,EAAW,CAACA,GAAM,UAAA,EAAcA,CAAAA,EAAM,YAC1CC,CAAAA,EACFG,CAAAA,CAAWH,CAAAA,CAAiB,UAAU,EAG5C,CAAA,CAAG,CAACD,CAAAA,CAAMI,CAAAA,CAAYH,CAAgB,CAAC,CAAA,CASvCM,eAAAA,CAAU,IA8FQC,qBAAAA,CAAiBT,CAAAA,CAAa,CAAE,QAAA,CAvFyBU,CAAAA,EAAgB,CAEvF,GAAIR,CAAAA,EAAoBS,kCAAAA,CAAyBT,EAAiB,UAAU,CAAA,GAAMU,uBAAa,GAAA,CAC7F,OAIF,GAAIF,CAAAA,CAAY,MAAA,GAAW,CAAA,CAAG,CACxBR,CAAAA,EACFG,CAAAA,CAAWH,CAAAA,CAAiB,UAAU,CAAA,CAExC,MACF,CAIA,IAAMW,CAAAA,CAAoBb,CAAAA,CAAY,KAAA,CAAM,OAAA,CACxCU,CAAAA,CAAY,KAAM,CAAA,EAAM,CAAA,CAAE,UAAU,GAAA,GAAQV,CAAAA,CAAY,MAAM,OAAO,CAAA,CACrEU,CAAAA,CAAY,CAAC,CAAA,CAGjB,GAAI,CAACG,CAAAA,CAAmB,CAClBX,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,UAAU,CAAA,CAExC,MACF,CAGA,IAAMY,CAAAA,CAAiBD,CAAAA,CAAkB,SAAS,CAAC,CAAA,CAC7CE,EAAUF,CAAAA,CAAkB,OAAA,CAQlC,GACGX,CAAAA,EAAoBS,kCAAAA,CAAyBT,CAAAA,CAAiB,UAAU,CAAA,GAAMU,sBAAAA,CAAa,KAC5F,CAACE,CAAAA,EACDR,CAAAA,CAEA,OAUF,GAFqBL,CAAAA,EAAM,QAAUA,CAAAA,CAAK,UAAA,CAAa,IAAA,CAErC,CAEhB,IAAMe,CAAAA,CAAad,GAAkB,UAAA,CAI/Be,CAAAA,CADQjB,EAAY,MAAA,CAAO,IAAA,CAAMkB,GAAMA,CAAAA,CAAE,EAAA,GAAOH,CAAO,CAAA,EACvC,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAC,CAAA,CAuB5CR,CAAAA,CAlBqBS,CAAAA,CACjB,CAEE,UAAA,CAAAA,EACA,OAAA,CAASF,CAAAA,CACT,OAAA,CAAAC,CAAAA,CACA,MAAA,CAAAE,CAAAA,CACA,YAAa,IACf,CAAA,CACA,CAEE,OAAA,CAASH,CAAAA,CACT,QAAAC,CAAAA,CACA,MAAA,CAAAE,CAAAA,CACA,WAAA,CAAa,IACf,CAG+B,EACrC,CACF,CAGkF,CAAC,CAAA,CAOlF,CAACf,CAAAA,EAAkB,WAAYD,CAAAA,CAAMK,CAAqB,CAAC,CAAA,CAGvD,IACT","file":"index.cjs","sourcesContent":["import { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMWalletsWatcher} component.\n */\ninterface EVMWalletsWatcherProps {\n /**\n * The configuration object from `@wagmi/core`.\n * This is required to initialize the account watcher.\n */\n wagmiConfig: Config;\n\n /**\n * Optional object representing the Sign-In With Ethereum (SIWE) state.\n * If provided, the watcher will use this state to manage updates\n * and disconnections based on SIWE status.\n */\n siwe?: {\n /**\n * Flag indicating if the SIWE authentication request was rejected by the user.\n */\n isRejected: boolean;\n /**\n * Flag indicating if the user is successfully signed in via SIWE.\n */\n isSignedIn: boolean;\n /**\n * Flag indicating if the SIWE flow is enabled.\n */\n enabled?: boolean;\n };\n}\n\n/**\n * A headless React component (renders `null`) that synchronizes the EVM wallet\n * state from `@wagmi/core` with the global `useSatelliteConnectStore`.\n *\n * It is responsible for:\n * 1. Automatically disconnecting if a SIWE (Sign-In With Ethereum) request is rejected.\n * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)\n * from `wagmi` and updating the global store accordingly.\n *\n * @param props - The component's props. See {@link EVMWalletsWatcherProps}.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMWalletsWatcher({ wagmiConfig, siwe }: EVMWalletsWatcherProps) {\n // --- Global Store State ---\n // Subscribes to parts of the global Zustand store.\n\n /**\n * The currently active wallet object from the global store.\n */\n /**\n * The currently active wallet object from the global store.\n */\n const activeConnection = useSatelliteConnectStore((store) => store.activeConnection);\n /**\n * The global function to trigger a wallet disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n /**\n * The global function to update the active wallet's details.\n */\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n\n // --- Effects ---\n\n /**\n * Effect: Handles SIWE rejection.\n *\n * If the SIWE flow is enabled (`siwe.enabled`), the user is not yet\n * signed in (`!siwe.isSignedIn`), and they have explicitly rejected\n * the SIWE signature request (`siwe.isRejected`), this effect\n * will call the global `disconnect` function.\n */\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n if (activeConnection) {\n disconnect(activeConnection.walletType);\n }\n }\n }, [siwe, disconnect, activeConnection]);\n\n /**\n * Effect: Subscribes to wagmi connection changes.\n *\n * This effect initializes `watchConnections` from `@wagmi/core` to listen for\n * any changes in the connected wallets' state (like switching accounts,\n * changing networks, or disconnecting). Supports multiple simultaneous connections.\n */\n useEffect(() => {\n /**\n * Callback function triggered by `watchConnections` whenever the\n * wagmi connections state changes.\n *\n * @param connections - Array of all active connections from wagmi.\n */\n const handleConnectionsChange: WatchConnectionsParameters['onChange'] = (connections) => {\n // Guard: If active connection is not EVM, ignore changes\n if (activeConnection && getAdapterFromWalletType(activeConnection.walletType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Case 1: No connections means all wallets were disconnected\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.walletType);\n }\n return;\n }\n\n // Get the current connection from wagmi config state\n // The \"current\" connection is typically the most recently used/active one\n const currentConnection = wagmiConfig.state.current\n ? connections.find((c) => c.connector.uid === wagmiConfig.state.current)\n : connections[0]; // Fallback to first connection if no current is set\n\n // If no valid connection is found, disconnect\n if (!currentConnection) {\n if (activeConnection) {\n disconnect(activeConnection.walletType);\n }\n return;\n }\n\n // Extract the primary account from the current connection\n const primaryAccount = currentConnection.accounts[0];\n const chainId = currentConnection.chainId;\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active wallet in our store is NOT an EVM wallet\n // (we don't want this watcher to override a non-EVM wallet).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeConnection && getAdapterFromWalletType(activeConnection.walletType) !== OrbitAdapter.EVM) ||\n !primaryAccount ||\n walletConnectionError\n ) {\n return;\n }\n\n /**\n * Determines if the global store *should* be updated.\n * - If SIWE is enabled, we only update the store if the user is signed in.\n * - If SIWE is not enabled, we always update the store.\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n // Preserve the `walletType` if it already exists in the active wallet.\n const walletType = activeConnection?.walletType;\n\n // Get the chain information for RPC URL\n const chain = wagmiConfig.chains.find((c) => c.id === chainId);\n const rpcURL = chain?.rpcUrls.default.http[0];\n\n /**\n * The payload to send to the global store update function.\n */\n const walletUpdate = walletType\n ? {\n // Preserve the walletType (e.g., 'metamask', 'walletconnect')\n walletType,\n address: primaryAccount,\n chainId,\n rpcURL,\n isConnected: true,\n }\n : {\n // Fallback if activeConnection was null or had no type\n address: primaryAccount,\n chainId,\n rpcURL,\n isConnected: true,\n };\n\n // Update the global store with the new wallet state.\n updateActiveConnection(walletUpdate);\n }\n };\n\n // Activate the watcher\n const unwatch = watchConnections(wagmiConfig, { onChange: handleConnectionsChange });\n\n // Return the cleanup function.\n // This `unwatch` function will be called when the component unmounts\n // or when the dependencies in the array change, preventing memory leaks.\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnection?.walletType, siwe, walletConnectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
|
package/dist/evm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {b}from'../chunk-
|
|
1
|
+
import {b}from'../chunk-VXHPTE35.js';import {getAdapterFromWalletType,OrbitAdapter}from'@tuwaio/orbit-core';import {watchConnections}from'@wagmi/core';import {useEffect}from'react';function S({wagmiConfig:r,siwe:n}){let e=b(t=>t.activeConnection),a=b(t=>t.disconnect),p=b(t=>t.walletConnectionError),m=b(t=>t.updateActiveConnection);return useEffect(()=>{n?.enabled&&!n?.isSignedIn&&n?.isRejected&&e&&a(e.walletType);},[n,a,e]),useEffect(()=>watchConnections(r,{onChange:l=>{if(e&&getAdapterFromWalletType(e.walletType)!==OrbitAdapter.EVM)return;if(l.length===0){e&&a(e.walletType);return}let i=r.state.current?l.find(c=>c.connector.uid===r.state.current):l[0];if(!i){e&&a(e.walletType);return}let s=i.accounts[0],d=i.chainId;if(e&&getAdapterFromWalletType(e.walletType)!==OrbitAdapter.EVM||!s||p)return;if(n?.enabled?n.isSignedIn:true){let c=e?.walletType,u=r.chains.find(E=>E.id===d)?.rpcUrls.default.http[0];m(c?{walletType:c,address:s,chainId:d,rpcURL:u,isConnected:true}:{address:s,chainId:d,rpcURL:u,isConnected:true});}}}),[e?.walletType,n,p]),null}export{S as EVMWalletsWatcher};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/evm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","
|
|
1
|
+
{"version":3,"sources":["../../src/evm/EVMWalletsWatcher.tsx"],"names":["EVMWalletsWatcher","wagmiConfig","siwe","activeConnection","useSatelliteConnectStore","store","disconnect","walletConnectionError","updateActiveConnection","useEffect","watchConnections","connections","getAdapterFromWalletType","OrbitAdapter","currentConnection","primaryAccount","chainId","walletType","rpcURL","c"],"mappings":"qLAiDO,SAASA,EAAkB,CAAE,WAAA,CAAAC,EAAa,IAAA,CAAAC,CAAK,CAAA,CAA2B,CAU/E,IAAMC,CAAAA,CAAmBC,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CAI7EC,CAAAA,CAAaF,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,CAAAA,CAAwBH,CAAAA,CAA0BC,GAAUA,CAAAA,CAAM,qBAAqB,CAAA,CAIvFG,CAAAA,CAAyBJ,CAAAA,CAA0BC,CAAAA,EAAUA,EAAM,sBAAsB,CAAA,CAY/F,OAAAI,SAAAA,CAAU,IAAM,CACVP,GAAM,OAAA,EAAW,CAACA,GAAM,UAAA,EAAcA,CAAAA,EAAM,YAC1CC,CAAAA,EACFG,CAAAA,CAAWH,CAAAA,CAAiB,UAAU,EAG5C,CAAA,CAAG,CAACD,CAAAA,CAAMI,CAAAA,CAAYH,CAAgB,CAAC,CAAA,CASvCM,SAAAA,CAAU,IA8FQC,gBAAAA,CAAiBT,CAAAA,CAAa,CAAE,QAAA,CAvFyBU,CAAAA,EAAgB,CAEvF,GAAIR,CAAAA,EAAoBS,wBAAAA,CAAyBT,EAAiB,UAAU,CAAA,GAAMU,aAAa,GAAA,CAC7F,OAIF,GAAIF,CAAAA,CAAY,MAAA,GAAW,CAAA,CAAG,CACxBR,CAAAA,EACFG,CAAAA,CAAWH,CAAAA,CAAiB,UAAU,CAAA,CAExC,MACF,CAIA,IAAMW,CAAAA,CAAoBb,CAAAA,CAAY,KAAA,CAAM,OAAA,CACxCU,CAAAA,CAAY,KAAM,CAAA,EAAM,CAAA,CAAE,UAAU,GAAA,GAAQV,CAAAA,CAAY,MAAM,OAAO,CAAA,CACrEU,CAAAA,CAAY,CAAC,CAAA,CAGjB,GAAI,CAACG,CAAAA,CAAmB,CAClBX,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,UAAU,CAAA,CAExC,MACF,CAGA,IAAMY,CAAAA,CAAiBD,CAAAA,CAAkB,SAAS,CAAC,CAAA,CAC7CE,EAAUF,CAAAA,CAAkB,OAAA,CAQlC,GACGX,CAAAA,EAAoBS,wBAAAA,CAAyBT,CAAAA,CAAiB,UAAU,CAAA,GAAMU,YAAAA,CAAa,KAC5F,CAACE,CAAAA,EACDR,CAAAA,CAEA,OAUF,GAFqBL,CAAAA,EAAM,QAAUA,CAAAA,CAAK,UAAA,CAAa,IAAA,CAErC,CAEhB,IAAMe,CAAAA,CAAad,GAAkB,UAAA,CAI/Be,CAAAA,CADQjB,EAAY,MAAA,CAAO,IAAA,CAAMkB,GAAMA,CAAAA,CAAE,EAAA,GAAOH,CAAO,CAAA,EACvC,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAC,CAAA,CAuB5CR,CAAAA,CAlBqBS,CAAAA,CACjB,CAEE,UAAA,CAAAA,EACA,OAAA,CAASF,CAAAA,CACT,OAAA,CAAAC,CAAAA,CACA,MAAA,CAAAE,CAAAA,CACA,YAAa,IACf,CAAA,CACA,CAEE,OAAA,CAASH,CAAAA,CACT,QAAAC,CAAAA,CACA,MAAA,CAAAE,CAAAA,CACA,WAAA,CAAa,IACf,CAG+B,EACrC,CACF,CAGkF,CAAC,CAAA,CAOlF,CAACf,CAAAA,EAAkB,WAAYD,CAAAA,CAAMK,CAAqB,CAAC,CAAA,CAGvD,IACT","file":"index.js","sourcesContent":["import { getAdapterFromWalletType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMWalletsWatcher} component.\n */\ninterface EVMWalletsWatcherProps {\n /**\n * The configuration object from `@wagmi/core`.\n * This is required to initialize the account watcher.\n */\n wagmiConfig: Config;\n\n /**\n * Optional object representing the Sign-In With Ethereum (SIWE) state.\n * If provided, the watcher will use this state to manage updates\n * and disconnections based on SIWE status.\n */\n siwe?: {\n /**\n * Flag indicating if the SIWE authentication request was rejected by the user.\n */\n isRejected: boolean;\n /**\n * Flag indicating if the user is successfully signed in via SIWE.\n */\n isSignedIn: boolean;\n /**\n * Flag indicating if the SIWE flow is enabled.\n */\n enabled?: boolean;\n };\n}\n\n/**\n * A headless React component (renders `null`) that synchronizes the EVM wallet\n * state from `@wagmi/core` with the global `useSatelliteConnectStore`.\n *\n * It is responsible for:\n * 1. Automatically disconnecting if a SIWE (Sign-In With Ethereum) request is rejected.\n * 2. Listening for account changes (e.g., account switch, chain switch, disconnect)\n * from `wagmi` and updating the global store accordingly.\n *\n * @param props - The component's props. See {@link EVMWalletsWatcherProps}.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMWalletsWatcher({ wagmiConfig, siwe }: EVMWalletsWatcherProps) {\n // --- Global Store State ---\n // Subscribes to parts of the global Zustand store.\n\n /**\n * The currently active wallet object from the global store.\n */\n /**\n * The currently active wallet object from the global store.\n */\n const activeConnection = useSatelliteConnectStore((store) => store.activeConnection);\n /**\n * The global function to trigger a wallet disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n /**\n * The global function to update the active wallet's details.\n */\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n\n // --- Effects ---\n\n /**\n * Effect: Handles SIWE rejection.\n *\n * If the SIWE flow is enabled (`siwe.enabled`), the user is not yet\n * signed in (`!siwe.isSignedIn`), and they have explicitly rejected\n * the SIWE signature request (`siwe.isRejected`), this effect\n * will call the global `disconnect` function.\n */\n useEffect(() => {\n if (siwe?.enabled && !siwe?.isSignedIn && siwe?.isRejected) {\n if (activeConnection) {\n disconnect(activeConnection.walletType);\n }\n }\n }, [siwe, disconnect, activeConnection]);\n\n /**\n * Effect: Subscribes to wagmi connection changes.\n *\n * This effect initializes `watchConnections` from `@wagmi/core` to listen for\n * any changes in the connected wallets' state (like switching accounts,\n * changing networks, or disconnecting). Supports multiple simultaneous connections.\n */\n useEffect(() => {\n /**\n * Callback function triggered by `watchConnections` whenever the\n * wagmi connections state changes.\n *\n * @param connections - Array of all active connections from wagmi.\n */\n const handleConnectionsChange: WatchConnectionsParameters['onChange'] = (connections) => {\n // Guard: If active connection is not EVM, ignore changes\n if (activeConnection && getAdapterFromWalletType(activeConnection.walletType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Case 1: No connections means all wallets were disconnected\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.walletType);\n }\n return;\n }\n\n // Get the current connection from wagmi config state\n // The \"current\" connection is typically the most recently used/active one\n const currentConnection = wagmiConfig.state.current\n ? connections.find((c) => c.connector.uid === wagmiConfig.state.current)\n : connections[0]; // Fallback to first connection if no current is set\n\n // If no valid connection is found, disconnect\n if (!currentConnection) {\n if (activeConnection) {\n disconnect(activeConnection.walletType);\n }\n return;\n }\n\n // Extract the primary account from the current connection\n const primaryAccount = currentConnection.accounts[0];\n const chainId = currentConnection.chainId;\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active wallet in our store is NOT an EVM wallet\n // (we don't want this watcher to override a non-EVM wallet).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeConnection && getAdapterFromWalletType(activeConnection.walletType) !== OrbitAdapter.EVM) ||\n !primaryAccount ||\n walletConnectionError\n ) {\n return;\n }\n\n /**\n * Determines if the global store *should* be updated.\n * - If SIWE is enabled, we only update the store if the user is signed in.\n * - If SIWE is not enabled, we always update the store.\n */\n const shouldUpdate = siwe?.enabled ? siwe.isSignedIn : true;\n\n if (shouldUpdate) {\n // Preserve the `walletType` if it already exists in the active wallet.\n const walletType = activeConnection?.walletType;\n\n // Get the chain information for RPC URL\n const chain = wagmiConfig.chains.find((c) => c.id === chainId);\n const rpcURL = chain?.rpcUrls.default.http[0];\n\n /**\n * The payload to send to the global store update function.\n */\n const walletUpdate = walletType\n ? {\n // Preserve the walletType (e.g., 'metamask', 'walletconnect')\n walletType,\n address: primaryAccount,\n chainId,\n rpcURL,\n isConnected: true,\n }\n : {\n // Fallback if activeConnection was null or had no type\n address: primaryAccount,\n chainId,\n rpcURL,\n isConnected: true,\n };\n\n // Update the global store with the new wallet state.\n updateActiveConnection(walletUpdate);\n }\n };\n\n // Activate the watcher\n const unwatch = watchConnections(wagmiConfig, { onChange: handleConnectionsChange });\n\n // Return the cleanup function.\n // This `unwatch` function will be called when the component unmounts\n // or when the dependencies in the array change, preventing memory leaks.\n return unwatch;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnection?.walletType, siwe, walletConnectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkBKNDP4VE_cjs=require('./chunk-BKNDP4VE.cjs');Object.defineProperty(exports,"SatelliteConnectProvider",{enumerable:true,get:function(){return chunkBKNDP4VE_cjs.d}});Object.defineProperty(exports,"SatelliteStoreContext",{enumerable:true,get:function(){return chunkBKNDP4VE_cjs.a}});Object.defineProperty(exports,"useInitializeAutoConnect",{enumerable:true,get:function(){return chunkBKNDP4VE_cjs.c}});Object.defineProperty(exports,"useSatelliteConnectStore",{enumerable:true,get:function(){return chunkBKNDP4VE_cjs.b}});//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -49,8 +49,8 @@ declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectSto
|
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
51
|
* ```tsx
|
|
52
|
-
* // Get the active
|
|
53
|
-
* const
|
|
52
|
+
* // Get the active connection
|
|
53
|
+
* const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T) => T;
|
package/dist/index.d.ts
CHANGED
|
@@ -49,8 +49,8 @@ declare const SatelliteStoreContext: react.Context<StoreApi<ISatelliteConnectSto
|
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
51
|
* ```tsx
|
|
52
|
-
* // Get the active
|
|
53
|
-
* const
|
|
52
|
+
* // Get the active connection
|
|
53
|
+
* const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
declare const useSatelliteConnectStore: <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T) => T;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{d as SatelliteConnectProvider,a as SatelliteStoreContext,c as useInitializeAutoConnect,b as useSatelliteConnectStore}from'./chunk-
|
|
1
|
+
export{d as SatelliteConnectProvider,a as SatelliteStoreContext,c as useInitializeAutoConnect,b as useSatelliteConnectStore}from'./chunk-VXHPTE35.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/solana/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkBKNDP4VE_cjs=require('../chunk-BKNDP4VE.cjs'),orbitCore=require('@tuwaio/orbit-core'),react=require('@wallet-standard/react'),react$1=require('react');function W(){let n=react.useWallets(),e=chunkBKNDP4VE_cjs.b(t=>t.activeConnection),a=chunkBKNDP4VE_cjs.b(t=>t.updateActiveConnection),l=chunkBKNDP4VE_cjs.b(t=>t.walletConnectionError),r=chunkBKNDP4VE_cjs.b(t=>t.disconnect);return react$1.useEffect(()=>{if(e&&orbitCore.getAdapterFromWalletType(e.walletType)===orbitCore.OrbitAdapter.SOLANA){let t=n.filter(i=>orbitCore.getWalletTypeFromConnectorName(orbitCore.OrbitAdapter.SOLANA,orbitCore.formatWalletName(i.name))===e.walletType)[0];l||a({address:t?.accounts[0]?.address,isConnected:t?.accounts.length>0,connectedAccount:t?.accounts[0],connectedWallet:t}),t?.accounts.length===0&&r(e.walletType);}},[e?.walletType,n,l,a,r]),null}exports.SolanaWalletsWatcher=W;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/solana/SolanaWalletsWatcher.tsx"],"names":["SolanaWalletsWatcher","wallets","useWallets","
|
|
1
|
+
{"version":3,"sources":["../../src/solana/SolanaWalletsWatcher.tsx"],"names":["SolanaWalletsWatcher","wallets","useWallets","activeConnectionFromStore","useSatelliteConnectStore","store","updateActiveConnection","walletConnectionError","disconnect","useEffect","getAdapterFromWalletType","OrbitAdapter","activeWallet","w","getWalletTypeFromConnectorName","formatWalletName"],"mappings":"6KAsBO,SAASA,CAAAA,EAAuB,CACrC,IAAMC,CAAAA,CAAUC,gBAAAA,EAAW,CAErBC,CAAAA,CAA4BC,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,EACtFC,CAAAA,CAAyBF,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,sBAAsB,CAAA,CACzFE,CAAAA,CAAwBH,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,qBAAqB,CAAA,CACvFG,CAAAA,CAAaJ,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,iBAAAA,CAAU,IAAM,CACd,GACEN,CAAAA,EACAO,kCAAAA,CAAyBP,CAAAA,CAA0B,UAAU,CAAA,GAAMQ,sBAAAA,CAAa,MAAA,CAChF,CACA,IAAMC,CAAAA,CAAeX,CAAAA,CAAQ,MAAA,CAC1BY,CAAAA,EACCC,wCAAAA,CAA+BH,sBAAAA,CAAa,MAAA,CAAQI,0BAAAA,CAAiBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GAC5EV,CAAAA,CAA0B,UAC9B,CAAA,CAAE,CAAC,CAAA,CAEEI,CAAAA,EAGHD,CAAAA,CAAuB,CAErB,OAAA,CAASM,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAEpC,WAAA,CAAaA,CAAAA,EAAc,QAAA,CAAS,MAAA,CAAS,CAAA,CAG7C,gBAAA,CAAkBA,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,CAC1C,eAAA,CAAiBA,CACnB,CAAC,CAAA,CAECA,CAAAA,EAAc,QAAA,CAAS,MAAA,GAAW,CAAA,EAEpCJ,CAAAA,CAAWL,CAAAA,CAA0B,UAAU,EAEnD,CAEF,CAAA,CAAG,CAACA,CAAAA,EAA2B,UAAA,CAAYF,CAAAA,CAASM,CAAAA,CAAuBD,CAAAA,CAAwBE,CAAU,CAAC,CAAA,CAGvG,IACT","file":"index.cjs","sourcesContent":["import {\n formatWalletName,\n getAdapterFromWalletType,\n getWalletTypeFromConnectorName,\n OrbitAdapter,\n} from '@tuwaio/orbit-core';\nimport { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * React component that monitors Solana wallet connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana wallets using the Wallet Standard.\n * Currently handles the first active wallet only, with multi-wallet support planned for future.\n * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.\n *\n * @returns null - This is a headless component\n *\n */\nexport function SolanaWalletsWatcher() {\n const wallets = useWallets();\n\n const activeConnectionFromStore = useSatelliteConnectStore((store) => store.activeConnection);\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected wallets\n useEffect(() => {\n if (\n activeConnectionFromStore &&\n getAdapterFromWalletType(activeConnectionFromStore.walletType) === OrbitAdapter.SOLANA\n ) {\n const activeWallet = wallets.filter(\n (w) =>\n getWalletTypeFromConnectorName(OrbitAdapter.SOLANA, formatWalletName(w.name)) ===\n activeConnectionFromStore.walletType,\n )[0];\n\n if (!walletConnectionError) {\n // Update the Satellite store with the active wallet information\n\n updateActiveConnection({\n // Use the first account's address\n address: activeWallet?.accounts[0]?.address,\n // Set connection status\n isConnected: activeWallet?.accounts.length > 0,\n // Store Wallet Standard specific information\n // @ts-expect-error - wallet type is not set fully on the package level\n connectedAccount: activeWallet?.accounts[0],\n connectedWallet: activeWallet,\n });\n }\n if (activeWallet?.accounts.length === 0) {\n // If the wallet is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect(activeConnectionFromStore.walletType);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnectionFromStore?.walletType, wallets, walletConnectionError, updateActiveConnection, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
|
package/dist/solana/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {b}from'../chunk-
|
|
1
|
+
import {b}from'../chunk-VXHPTE35.js';import {getAdapterFromWalletType,OrbitAdapter,getWalletTypeFromConnectorName,formatWalletName}from'@tuwaio/orbit-core';import {useWallets}from'@wallet-standard/react';import {useEffect}from'react';function W(){let n=useWallets(),e=b(t=>t.activeConnection),a=b(t=>t.updateActiveConnection),l=b(t=>t.walletConnectionError),r=b(t=>t.disconnect);return useEffect(()=>{if(e&&getAdapterFromWalletType(e.walletType)===OrbitAdapter.SOLANA){let t=n.filter(i=>getWalletTypeFromConnectorName(OrbitAdapter.SOLANA,formatWalletName(i.name))===e.walletType)[0];l||a({address:t?.accounts[0]?.address,isConnected:t?.accounts.length>0,connectedAccount:t?.accounts[0],connectedWallet:t}),t?.accounts.length===0&&r(e.walletType);}},[e?.walletType,n,l,a,r]),null}export{W as SolanaWalletsWatcher};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/solana/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/solana/SolanaWalletsWatcher.tsx"],"names":["SolanaWalletsWatcher","wallets","useWallets","
|
|
1
|
+
{"version":3,"sources":["../../src/solana/SolanaWalletsWatcher.tsx"],"names":["SolanaWalletsWatcher","wallets","useWallets","activeConnectionFromStore","useSatelliteConnectStore","store","updateActiveConnection","walletConnectionError","disconnect","useEffect","getAdapterFromWalletType","OrbitAdapter","activeWallet","w","getWalletTypeFromConnectorName","formatWalletName"],"mappings":"0OAsBO,SAASA,CAAAA,EAAuB,CACrC,IAAMC,CAAAA,CAAUC,UAAAA,EAAW,CAErBC,CAAAA,CAA4BC,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,EACtFC,CAAAA,CAAyBF,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,sBAAsB,CAAA,CACzFE,CAAAA,CAAwBH,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,qBAAqB,CAAA,CACvFG,CAAAA,CAAaJ,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,SAAAA,CAAU,IAAM,CACd,GACEN,CAAAA,EACAO,wBAAAA,CAAyBP,CAAAA,CAA0B,UAAU,CAAA,GAAMQ,YAAAA,CAAa,MAAA,CAChF,CACA,IAAMC,CAAAA,CAAeX,CAAAA,CAAQ,MAAA,CAC1BY,CAAAA,EACCC,8BAAAA,CAA+BH,YAAAA,CAAa,MAAA,CAAQI,gBAAAA,CAAiBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GAC5EV,CAAAA,CAA0B,UAC9B,CAAA,CAAE,CAAC,CAAA,CAEEI,CAAAA,EAGHD,CAAAA,CAAuB,CAErB,OAAA,CAASM,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAEpC,WAAA,CAAaA,CAAAA,EAAc,QAAA,CAAS,MAAA,CAAS,CAAA,CAG7C,gBAAA,CAAkBA,CAAAA,EAAc,QAAA,CAAS,CAAC,CAAA,CAC1C,eAAA,CAAiBA,CACnB,CAAC,CAAA,CAECA,CAAAA,EAAc,QAAA,CAAS,MAAA,GAAW,CAAA,EAEpCJ,CAAAA,CAAWL,CAAAA,CAA0B,UAAU,EAEnD,CAEF,CAAA,CAAG,CAACA,CAAAA,EAA2B,UAAA,CAAYF,CAAAA,CAASM,CAAAA,CAAuBD,CAAAA,CAAwBE,CAAU,CAAC,CAAA,CAGvG,IACT","file":"index.js","sourcesContent":["import {\n formatWalletName,\n getAdapterFromWalletType,\n getWalletTypeFromConnectorName,\n OrbitAdapter,\n} from '@tuwaio/orbit-core';\nimport { useWallets } from '@wallet-standard/react';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * React component that monitors Solana wallet connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana wallets using the Wallet Standard.\n * Currently handles the first active wallet only, with multi-wallet support planned for future.\n * It's a headless component that manages state synchronization between Wallet Standard and Satellite store.\n *\n * @returns null - This is a headless component\n *\n */\nexport function SolanaWalletsWatcher() {\n const wallets = useWallets();\n\n const activeConnectionFromStore = useSatelliteConnectStore((store) => store.activeConnection);\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n const walletConnectionError = useSatelliteConnectStore((store) => store.walletConnectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected wallets\n useEffect(() => {\n if (\n activeConnectionFromStore &&\n getAdapterFromWalletType(activeConnectionFromStore.walletType) === OrbitAdapter.SOLANA\n ) {\n const activeWallet = wallets.filter(\n (w) =>\n getWalletTypeFromConnectorName(OrbitAdapter.SOLANA, formatWalletName(w.name)) ===\n activeConnectionFromStore.walletType,\n )[0];\n\n if (!walletConnectionError) {\n // Update the Satellite store with the active wallet information\n\n updateActiveConnection({\n // Use the first account's address\n address: activeWallet?.accounts[0]?.address,\n // Set connection status\n isConnected: activeWallet?.accounts.length > 0,\n // Store Wallet Standard specific information\n // @ts-expect-error - wallet type is not set fully on the package level\n connectedAccount: activeWallet?.accounts[0],\n connectedWallet: activeWallet,\n });\n }\n if (activeWallet?.accounts.length === 0) {\n // If the wallet is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect(activeConnectionFromStore.walletType);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnectionFromStore?.walletType, wallets, walletConnectionError, updateActiveConnection, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/satellite-react",
|
|
3
|
-
"version": "1.0.0-fix-packages-alpha.
|
|
3
|
+
"version": "1.0.0-fix-packages-alpha.3.bf8071b",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -131,9 +131,9 @@
|
|
|
131
131
|
"viem": "^2.40.3",
|
|
132
132
|
"typescript": "^5.9.3",
|
|
133
133
|
"zustand": "^5.0.8",
|
|
134
|
-
"@tuwaio/satellite-
|
|
135
|
-
"@tuwaio/satellite-
|
|
136
|
-
"@tuwaio/satellite-
|
|
134
|
+
"@tuwaio/satellite-evm": "^1.0.0-fix-packages-alpha.3.bf8071b",
|
|
135
|
+
"@tuwaio/satellite-solana": "^1.0.0-fix-packages-alpha.3.bf8071b",
|
|
136
|
+
"@tuwaio/satellite-core": "^1.0.0-fix-packages-alpha.3.bf8071b"
|
|
137
137
|
},
|
|
138
138
|
"scripts": {
|
|
139
139
|
"start": "tsup src/index.ts --watch",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/satteliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"uMAUaA,CAAAA,CAAwBC,aAAAA,CAA0E,IAAI,CAAA,CAqBtGC,EAA+BC,CAAAA,EAAyE,CAEnH,IAAMC,CAAAA,CAAQC,UAAAA,CAAWL,CAAqB,CAAA,CAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,QAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECDO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,SAAAA,CAAU,IAAM,EACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,EAEOF,CAAAA,GAAaG,CAAAA,EAAa,OAAA,CAAQ,KAAA,CAAM,qCAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,SAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,CAAA,CAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,QAAQ,IACbC,2BAAAA,CAA+C,CACpD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAGL,OAAAN,SAAAA,CAAU,IAAM,CACdN,CAAAA,CAAM,QAAA,EAAS,CAAE,aAAA,GAEnB,CAAA,CAAG,EAAE,CAAA,CAELG,EAAyB,CACvB,qBAAA,CAAuB,IAAMH,CAAAA,CAAM,UAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,GAAAA,CAACnB,CAAAA,CAAsB,SAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-3WMGCMYX.js","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connector, Wallet } from '../types';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore<Connector, Wallet>> | null>(null);\n\n/**\n * Custom hook for accessing the Satellite Connect store state\n *\n * @remarks\n * This hook provides type-safe access to the Satellite store state and must be used\n * within a component that is wrapped by SatelliteConnectProvider.\n *\n * @typeParam T - The type of the selected state slice\n * @param selector - Function that selects a slice of the store state\n * @returns Selected state slice\n *\n * @throws Error if used outside of SatelliteConnectProvider\n *\n * @example\n * ```tsx\n * // Get the active wallet\n * const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);\n * ```\n */\nexport const useSatelliteConnectStore = <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T): T => {\n // Get store instance from context\n const store = useContext(SatelliteStoreContext);\n\n // Ensure hook is used within provider\n if (!store) {\n throw new Error('useSatelliteConnectStore must be used within a SatelliteConnectProvider');\n }\n\n // Return selected state using Zustand's useStore\n return useStore(store, selector);\n};\n","import { useEffect } from 'react';\n\n/**\n * Props for the useInitializeAutoConnect hook.\n */\ninterface InitializeAutoConnectProps {\n /** Function to initialize auto connect logic */\n initializeAutoConnect: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing wallet auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected wallet) when a component mounts.\n * It provides default error handling with console.error if no custom handler is provided.\n * The initialization runs only once when the component mounts.\n *\n * @param props - Hook configuration\n * @param props.initializeAutoConnect - Async function that executes the auto-connect logic\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect\n * });\n *\n * // With custom error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect,\n * onError: (error) => {\n * toast.error(`Failed to auto-connect: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAutoConnect = ({ initializeAutoConnect, onError }: InitializeAutoConnectProps): void => {\n useEffect(() => {\n const initializeAutoConnectLocal = async () => {\n try {\n await initializeAutoConnect();\n } catch (error) {\n // Use provided error handler or fallback to default console.error\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize auto connect:', e));\n errorHandler(error as Error);\n }\n };\n // Initialize auto connect when component mounts\n initializeAutoConnectLocal();\n }, []); // Empty dependency array ensures single execution\n};\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useEffect, useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satteliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connector, Wallet } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used wallet */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages wallet connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles wallet connections, state management, and automatic reconnection functionality.\n * The store is memoized to ensure stable reference across renders.\n *\n * @param props - Component properties including store parameters and children\n * @param props.children - Child components that will have access to the store\n * @param props.autoConnect - Optional flag to enable automatic wallet reconnection\n * @param props.adapter - Blockchain adapter(s) for wallet interactions\n * @param props.callbackAfterConnected - Optional callback for successful connections\n *\n * @example\n * ```tsx\n * // Basic usage with single adapter\n * <SatelliteConnectProvider adapter={solanaAdapter}>\n * <App />\n * </SatelliteConnectProvider>\n *\n * // With auto-connect and multiple adapters\n * <SatelliteConnectProvider\n * adapter={[solanaAdapter, evmAdapter]}\n * autoConnect={true}\n * callbackAfterConnected={(wallet) => {\n * console.log('Wallet connected:', wallet.address);\n * }}\n * >\n * <App />\n * </SatelliteConnectProvider>\n * ```\n */\nexport function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps) {\n // Create and memoize the store instance\n const store = useMemo(() => {\n return createSatelliteConnectStore<Connector, Wallet>({\n ...parameters,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Empty dependency array as store should be created only once\n\n // Disconnect from any existing wallets on mount\n useEffect(() => {\n store.getState().disconnectAll();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/satteliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx"],"mappings":"+JAUaA,CAAAA,CAAwBC,mBAAAA,CAA0E,IAAI,CAAA,CAqBtGC,EAA+BC,CAAAA,EAAyE,CAEnH,IAAMC,CAAAA,CAAQC,gBAAAA,CAAWL,CAAqB,CAAA,CAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,gBAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECDO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,eAAAA,CAAU,IAAM,EACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,EAEOF,CAAAA,GAAaG,CAAAA,EAAa,OAAA,CAAQ,KAAA,CAAM,qCAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,SAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,CAAA,CAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,cAAQ,IACbC,yCAAAA,CAA+C,CACpD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAGL,OAAAN,eAAAA,CAAU,IAAM,CACdN,CAAAA,CAAM,QAAA,EAAS,CAAE,aAAA,GAEnB,CAAA,CAAG,EAAE,CAAA,CAELG,EAAyB,CACvB,qBAAA,CAAuB,IAAMH,CAAAA,CAAM,UAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,cAAAA,CAACnB,CAAAA,CAAsB,SAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-YC7F3NGW.cjs","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connector, Wallet } from '../types';\n\n/**\n * React Context for providing Satellite Connect store throughout the application\n * @internal\n */\nexport const SatelliteStoreContext = createContext<StoreApi<ISatelliteConnectStore<Connector, Wallet>> | null>(null);\n\n/**\n * Custom hook for accessing the Satellite Connect store state\n *\n * @remarks\n * This hook provides type-safe access to the Satellite store state and must be used\n * within a component that is wrapped by SatelliteConnectProvider.\n *\n * @typeParam T - The type of the selected state slice\n * @param selector - Function that selects a slice of the store state\n * @returns Selected state slice\n *\n * @throws Error if used outside of SatelliteConnectProvider\n *\n * @example\n * ```tsx\n * // Get the active wallet\n * const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);\n * ```\n */\nexport const useSatelliteConnectStore = <T>(selector: (state: ISatelliteConnectStore<Connector, Wallet>) => T): T => {\n // Get store instance from context\n const store = useContext(SatelliteStoreContext);\n\n // Ensure hook is used within provider\n if (!store) {\n throw new Error('useSatelliteConnectStore must be used within a SatelliteConnectProvider');\n }\n\n // Return selected state using Zustand's useStore\n return useStore(store, selector);\n};\n","import { useEffect } from 'react';\n\n/**\n * Props for the useInitializeAutoConnect hook.\n */\ninterface InitializeAutoConnectProps {\n /** Function to initialize auto connect logic */\n initializeAutoConnect: () => Promise<void>;\n /** Optional error handler callback */\n onError?: (error: Error) => void;\n}\n\n/**\n * Custom hook for initializing wallet auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected wallet) when a component mounts.\n * It provides default error handling with console.error if no custom handler is provided.\n * The initialization runs only once when the component mounts.\n *\n * @param props - Hook configuration\n * @param props.initializeAutoConnect - Async function that executes the auto-connect logic\n * @param props.onError - Optional custom error handler\n *\n * @example\n * ```tsx\n * // Basic usage with default error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect\n * });\n *\n * // With custom error handling\n * useInitializeAutoConnect({\n * initializeAutoConnect: store.initializeAutoConnect,\n * onError: (error) => {\n * toast.error(`Failed to auto-connect: ${error.message}`);\n * }\n * });\n * ```\n */\nexport const useInitializeAutoConnect = ({ initializeAutoConnect, onError }: InitializeAutoConnectProps): void => {\n useEffect(() => {\n const initializeAutoConnectLocal = async () => {\n try {\n await initializeAutoConnect();\n } catch (error) {\n // Use provided error handler or fallback to default console.error\n const errorHandler = onError ?? ((e: Error) => console.error('Failed to initialize auto connect:', e));\n errorHandler(error as Error);\n }\n };\n // Initialize auto connect when component mounts\n initializeAutoConnectLocal();\n }, []); // Empty dependency array ensures single execution\n};\n","import { createSatelliteConnectStore, SatelliteConnectStoreInitialParameters } from '@tuwaio/satellite-core';\nimport { useEffect, useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satteliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connector, Wallet } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Wallet> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used wallet */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages wallet connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles wallet connections, state management, and automatic reconnection functionality.\n * The store is memoized to ensure stable reference across renders.\n *\n * @param props - Component properties including store parameters and children\n * @param props.children - Child components that will have access to the store\n * @param props.autoConnect - Optional flag to enable automatic wallet reconnection\n * @param props.adapter - Blockchain adapter(s) for wallet interactions\n * @param props.callbackAfterConnected - Optional callback for successful connections\n *\n * @example\n * ```tsx\n * // Basic usage with single adapter\n * <SatelliteConnectProvider adapter={solanaAdapter}>\n * <App />\n * </SatelliteConnectProvider>\n *\n * // With auto-connect and multiple adapters\n * <SatelliteConnectProvider\n * adapter={[solanaAdapter, evmAdapter]}\n * autoConnect={true}\n * callbackAfterConnected={(wallet) => {\n * console.log('Wallet connected:', wallet.address);\n * }}\n * >\n * <App />\n * </SatelliteConnectProvider>\n * ```\n */\nexport function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps) {\n // Create and memoize the store instance\n const store = useMemo(() => {\n return createSatelliteConnectStore<Connector, Wallet>({\n ...parameters,\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []); // Empty dependency array as store should be created only once\n\n // Disconnect from any existing wallets on mount\n useEffect(() => {\n store.getState().disconnectAll();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}
|