@tuwaio/satellite-react 1.0.0-fix-packages-alpha.24.dbb32da → 1.0.0-fix-adapters-independ-alpha.1.82df95a

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/README.md +6 -6
  2. package/dist/chunk-6RDFJAW4.cjs +2 -0
  3. package/dist/chunk-6RDFJAW4.cjs.map +1 -0
  4. package/dist/chunk-CL2PKR7V.cjs +2 -0
  5. package/dist/chunk-CL2PKR7V.cjs.map +1 -0
  6. package/dist/chunk-IGRMM7IL.cjs +2 -0
  7. package/dist/chunk-IGRMM7IL.cjs.map +1 -0
  8. package/dist/chunk-JJ2GE6TY.js +2 -0
  9. package/dist/chunk-JJ2GE6TY.js.map +1 -0
  10. package/dist/chunk-TLEFGK44.js +2 -0
  11. package/dist/chunk-TLEFGK44.js.map +1 -0
  12. package/dist/chunk-V7GNOGFC.js +2 -0
  13. package/dist/chunk-V7GNOGFC.js.map +1 -0
  14. package/dist/evm/dynamicImports.cjs +2 -0
  15. package/dist/evm/dynamicImports.cjs.map +1 -0
  16. package/dist/evm/dynamicImports.d.cts +17 -0
  17. package/dist/evm/dynamicImports.d.ts +17 -0
  18. package/dist/evm/dynamicImports.js +2 -0
  19. package/dist/evm/dynamicImports.js.map +1 -0
  20. package/dist/evm/index.cjs +1 -1
  21. package/dist/evm/index.cjs.map +1 -1
  22. package/dist/evm/index.js +1 -1
  23. package/dist/evm/index.js.map +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.d.cts +10 -1
  26. package/dist/index.d.ts +10 -1
  27. package/dist/index.js +1 -1
  28. package/dist/solana/dynamicImports.cjs +2 -0
  29. package/dist/solana/dynamicImports.cjs.map +1 -0
  30. package/dist/solana/dynamicImports.d.cts +17 -0
  31. package/dist/solana/dynamicImports.d.ts +17 -0
  32. package/dist/solana/dynamicImports.js +2 -0
  33. package/dist/solana/dynamicImports.js.map +1 -0
  34. package/dist/solana/index.cjs +1 -1
  35. package/dist/solana/index.cjs.map +1 -1
  36. package/dist/solana/index.js +1 -1
  37. package/dist/solana/index.js.map +1 -1
  38. package/package.json +8 -8
  39. package/dist/chunk-23IZMVDP.cjs +0 -2
  40. package/dist/chunk-23IZMVDP.cjs.map +0 -1
  41. package/dist/chunk-4RWO4WUN.js +0 -2
  42. package/dist/chunk-4RWO4WUN.js.map +0 -1
package/README.md CHANGED
@@ -56,7 +56,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
56
56
  import { satelliteEVMAdapter, createDefaultTransports } from '@tuwaio/satellite-evm';
57
57
  import { SatelliteConnectProvider } from '@tuwaio/satellite-react';
58
58
  import { EVMConnectorsWatcher } from '@tuwaio/satellite-react/evm';
59
- import { SolanaWalletsWatcher } from '@tuwaio/satellite-react/solana';
59
+ import { SolanaConnectorsWatcher } from '@tuwaio/satellite-react/solana';
60
60
  import { satelliteSolanaAdapter } from '@tuwaio/satellite-solana';
61
61
  import { WagmiProvider } from 'wagmi';
62
62
  import { ReactNode } from 'react';
@@ -93,7 +93,7 @@ export function Providers({ children }: { children: ReactNode }) {
93
93
  autoConnect={true}
94
94
  >
95
95
  <EVMConnectorsWatcher wagmiConfig={wagmiConfig} />
96
- <SolanaWalletsWatcher />
96
+ <SolanaConnectorsWatcher />
97
97
  {children}
98
98
  </SatelliteConnectProvider>
99
99
  </QueryClientProvider>
@@ -108,8 +108,8 @@ export function Providers({ children }: { children: ReactNode }) {
108
108
  import { useSatelliteConnectStore } from '@tuwaio/satellite-react';
109
109
 
110
110
  function ExampleGettingActiveWalletFromStore() {
111
- const activeWallet = useSatelliteConnectStore((state) => state.activeWallet);
112
- return <div>{activeWallet?.address}</div>
111
+ const activeConnection = useSatelliteConnectStore((state) => state.activeConnection);
112
+ return <div>{activeConnection?.address}</div>
113
113
  }
114
114
  ```
115
115
 
@@ -123,8 +123,8 @@ function ExampleGettingActiveWalletFromStore() {
123
123
 
124
124
  2. **Provider Components**
125
125
  - `SatelliteConnectProvider`: Global context provider with all necessary configurations
126
- - `EVMConnectorsWatcher`: EVM wallet connection state management
127
- - `SolanaWalletsWatcher`: Solana wallet connection state management
126
+ - `EVMConnectorsWatcher`: EVM connection state management
127
+ - `SolanaConnectorsWatcher`: Solana connection state management
128
128
 
129
129
  ---
130
130
 
@@ -0,0 +1,2 @@
1
+ 'use strict';var r=typeof process<"u"&&process.env?.NODE_ENV==="production";async function t(){if(r)try{return new Function('try { return Boolean(require("@tuwaio/orbit-evm") && require("@tuwaio/satellite-evm") && require("@wagmi/core") && require("viem")); } catch { return false; }')()}catch{return false}try{return await Promise.all([import('@tuwaio/orbit-evm'),import('@tuwaio/satellite-evm'),import('@wagmi/core'),import('viem')]),!0}catch{return false}}async function i(){try{return await t()?await new Function('return import("./index.js").catch(error => { console.warn("Failed to load EVM exports:", error); return null; })')():(console.warn("EVM dependencies are not available. EVM functionality will be disabled."),null)}catch(e){return console.warn("Failed to load EVM exports:",e),null}}exports.a=r;exports.b=t;exports.c=i;//# sourceMappingURL=chunk-6RDFJAW4.cjs.map
2
+ //# sourceMappingURL=chunk-6RDFJAW4.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/evm/dynamicImports.ts"],"names":["IS_BUNDLER_ENV","checkEvmDependencies","getEvmExports","error"],"mappings":"aAMO,IAAMA,EAAiB,OAAO,OAAA,CAAY,GAAA,EAAe,OAAA,CAAQ,KAAK,QAAA,GAAa,aAM1F,eAAsBC,CAAAA,EAAyC,CAC7D,GAAID,CAAAA,CACF,GAAI,CAKF,OAHoB,IAAI,QAAA,CACtB,gKACF,CAAA,EAEF,MAAQ,CACN,OAAO,MACT,CAGF,GAAI,CAEF,OAAA,MAAM,OAAA,CAAQ,GAAA,CAAI,CAChB,OAAO,mBAAmB,CAAA,CAC1B,OAAO,uBAAuB,CAAA,CAC9B,OAAO,aAAa,CAAA,CACpB,OAAO,MAAM,CACf,CAAC,CAAA,CACM,CAAA,CACT,CAAA,KAAQ,CACN,OAAO,MACT,CACF,CAMA,eAAsBE,CAAAA,EAAgB,CACpC,GAAI,CAGF,OADwB,MAAMD,CAAAA,EAAqB,CAWhC,MAJK,IAAI,SAC1B,kHACF,CAAA,IAPE,OAAA,CAAQ,IAAA,CAAK,yEAAyE,CAAA,CAC/E,IAAA,CAUX,CAAA,MAASE,CAAAA,CAAO,CACd,OAAA,OAAA,CAAQ,IAAA,CAAK,8BAA+BA,CAAK,CAAA,CAC1C,IACT,CACF","file":"chunk-6RDFJAW4.cjs","sourcesContent":["/**\n * This file contains utility functions for dynamically importing EVM-specific dependencies.\n * It allows the package to be used in Solana-only environments without requiring EVM dependencies.\n */\n\n// Detect if we're in a bundler environment\nexport const IS_BUNDLER_ENV = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\n\n/**\n * Checks if the required EVM dependencies are available.\n * @returns A promise that resolves to a boolean indicating if the dependencies are available.\n */\nexport async function checkEvmDependencies(): Promise<boolean> {\n if (IS_BUNDLER_ENV) {\n try {\n // In a bundler environment, use Function constructor to avoid static analysis\n const checkImport = new Function(\n 'try { return Boolean(require(\"@tuwaio/orbit-evm\") && require(\"@tuwaio/satellite-evm\") && require(\"@wagmi/core\") && require(\"viem\")); } catch { return false; }',\n );\n return checkImport();\n } catch {\n return false;\n }\n }\n\n try {\n // In a non-bundler environment, use dynamic imports\n await Promise.all([\n import('@tuwaio/orbit-evm'),\n import('@tuwaio/satellite-evm'),\n import('@wagmi/core'),\n import('viem'),\n ]);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Dynamically imports and returns the EVM-specific exports.\n * @returns A promise that resolves to the EVM exports or null if the dependencies are not available.\n */\nexport async function getEvmExports() {\n try {\n // Check if dependencies are available before attempting to import\n const hasDependencies = await checkEvmDependencies();\n if (!hasDependencies) {\n console.warn('EVM dependencies are not available. EVM functionality will be disabled.');\n return null;\n }\n\n // Use Function constructor to avoid static analysis by bundlers\n const importEvmModule = new Function(\n 'return import(\"./index.js\").catch(error => { console.warn(\"Failed to load EVM exports:\", error); return null; })',\n );\n\n const evmExports = await importEvmModule();\n return evmExports;\n } catch (error) {\n console.warn('Failed to load EVM exports:', error);\n return null;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunk6RDFJAW4_cjs=require('./chunk-6RDFJAW4.cjs'),chunkIGRMM7IL_cjs=require('./chunk-IGRMM7IL.cjs'),react=require('react'),zustand=require('zustand'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var r=react.createContext(null),A=t=>{let e=react.useContext(r);if(!e)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return zustand.useStore(e,t)};var a=({initializeAutoConnect:t,onError:e})=>{react.useEffect(()=>{(async()=>{try{await t();}catch(o){(e??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function L({children:t,autoConnect:e,...n}){let o=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...n}),[]);return a({initializeAutoConnect:()=>o.getState().initializeAutoConnect(e??!1)}),jsxRuntime.jsx(r.Provider,{value:o,children:t})}var x=typeof process<"u"&&process.env?.NODE_ENV==="production";async function d(){try{let t=await chunk6RDFJAW4_cjs.c();t&&Object.assign(exports,t);let e=await chunkIGRMM7IL_cjs.c();e&&Object.assign(exports,e);}catch(t){console.warn("Error initializing satellite-react:",t);}}x||d().catch(console.error);exports.a=r;exports.b=A;exports.c=a;exports.d=L;exports.e=x;exports.f=d;//# sourceMappingURL=chunk-CL2PKR7V.cjs.map
2
+ //# sourceMappingURL=chunk-CL2PKR7V.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/satelliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx","../src/index.ts"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx","IS_BUNDLER_ENV","initializeSatelliteReact","evmExports","getEvmExports","solanaExports","getSolanaExports"],"mappings":"+PAUO,IAAMA,EAAwBC,mBAAAA,CACnC,IACF,EAqBaC,CAAAA,CACXC,CAAAA,EACM,CAEN,IAAMC,CAAAA,CAAQC,iBAAWL,CAAqB,CAAA,CAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,iBAASF,CAAAA,CAAOD,CAAQ,CACjC,MCLaI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,QAAAC,CAAQ,CAAA,GAAwC,CAChHC,eAAAA,CAAU,IAAM,EACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,IACR,CAAA,MAASG,EAAO,CAAA,CAEOF,CAAAA,GAAaG,GAAa,OAAA,CAAQ,KAAA,CAAM,qCAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,KAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,QAAA,CAAAC,EAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,CAAA,CAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,cAAQ,IACbC,yCAAAA,CAAmD,CACxD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAEL,OAAAT,EAAyB,CACvB,qBAAA,CAAuB,IAAMH,CAAAA,CAAM,QAAA,GAAW,qBAAA,CAAsBW,CAAAA,EAAe,EAAK,CAC1F,CAAC,EAEMI,cAAAA,CAACnB,CAAAA,CAAsB,SAAtB,CAA+B,KAAA,CAAOI,EAAQ,QAAA,CAAAU,CAAAA,CAAS,CACjE,CCrDO,IAAMM,EAAiB,OAAO,OAAA,CAAY,KAAe,OAAA,CAAQ,GAAA,EAAK,WAAa,aAQ1F,eAAsBC,GAA2B,CAC/C,GAAI,CAEF,IAAMC,CAAAA,CAAa,MAAMC,mBAAAA,EAAc,CACnCD,GACF,MAAA,CAAO,MAAA,CAAO,QAASA,CAAU,CAAA,CAInC,IAAME,CAAAA,CAAgB,MAAMC,qBAAiB,CACzCD,CAAAA,EACF,OAAO,MAAA,CAAO,OAAA,CAASA,CAAa,EAExC,CAAA,MAASb,EAAO,CACd,OAAA,CAAQ,KAAK,qCAAA,CAAuCA,CAAK,EAC3D,CACF,CAGKS,GACHC,CAAAA,EAAyB,CAAE,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA","file":"chunk-CL2PKR7V.cjs","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connection, Connector } 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, Connection>> | null>(\n null,\n);\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>(\n selector: (state: ISatelliteConnectStore<Connector, Connection>) => T,\n): 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 connector auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected connector) 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 { useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satelliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connection, Connector } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used connector */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages connector connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles connector 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 connector reconnection\n * @param props.adapter - Blockchain adapter(s) for connector 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, Connection>({\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 useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n","// Core exports that are always available\nexport * from './hooks/satelliteHook';\nexport * from './hooks/useInitializeAutoConnect';\nexport * from './providers/SatelliteConnectProvider';\nexport * from './types';\n\n// Dynamic imports for blockchain-specific modules\nimport { getEvmExports } from './evm/dynamicImports';\nimport { getSolanaExports } from './solana/dynamicImports';\n\n// Detect if we're in a bundler environment\nexport const IS_BUNDLER_ENV = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\n\n/**\n * Dynamically loads and initializes blockchain-specific modules.\n * This function should be called at the application entry point.\n *\n * @returns A promise that resolves when all modules are loaded.\n */\nexport async function initializeSatelliteReact() {\n try {\n // Load EVM module if dependencies are available\n const evmExports = await getEvmExports();\n if (evmExports) {\n Object.assign(exports, evmExports);\n }\n\n // Load Solana module if dependencies are available\n const solanaExports = await getSolanaExports();\n if (solanaExports) {\n Object.assign(exports, solanaExports);\n }\n } catch (error) {\n console.warn('Error initializing satellite-react:', error);\n }\n}\n\n// Auto-initialize in non-bundler environments\nif (!IS_BUNDLER_ENV) {\n initializeSatelliteReact().catch(console.error);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';var r=typeof process<"u"&&process.env?.NODE_ENV==="production";async function o(){if(r)try{return new Function('try { return Boolean(require("@tuwaio/orbit-solana") && require("@tuwaio/satellite-solana") && require("@wallet-standard/react") && require("gill")); } catch { return false; }')()}catch{return false}try{return await Promise.all([import('@tuwaio/orbit-solana'),import('@tuwaio/satellite-solana'),import('@wallet-standard/react'),import('gill')]),!0}catch{return false}}async function a(){try{return await o()?await new Function('return import("./index.js").catch(error => { console.warn("Failed to load Solana exports:", error); return null; })')():(console.warn("Solana dependencies are not available. Solana functionality will be disabled."),null)}catch(e){return console.warn("Failed to load Solana exports:",e),null}}exports.a=r;exports.b=o;exports.c=a;//# sourceMappingURL=chunk-IGRMM7IL.cjs.map
2
+ //# sourceMappingURL=chunk-IGRMM7IL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/solana/dynamicImports.ts"],"names":["IS_BUNDLER_ENV","checkSolanaDependencies","getSolanaExports","error"],"mappings":"aAMO,IAAMA,EAAiB,OAAO,OAAA,CAAY,GAAA,EAAe,OAAA,CAAQ,KAAK,QAAA,GAAa,aAM1F,eAAsBC,CAAAA,EAA4C,CAChE,GAAID,CAAAA,CACF,GAAI,CAKF,OAHoB,IAAI,QAAA,CACtB,iLACF,CAAA,EAEF,MAAQ,CACN,OAAO,MACT,CAGF,GAAI,CAEF,OAAA,MAAM,OAAA,CAAQ,GAAA,CAAI,CAChB,OAAO,sBAAsB,CAAA,CAC7B,OAAO,0BAA0B,CAAA,CACjC,OAAO,wBAAwB,CAAA,CAC/B,OAAO,MAAM,CACf,CAAC,CAAA,CACM,CAAA,CACT,CAAA,KAAQ,CACN,OAAO,MACT,CACF,CAMA,eAAsBE,CAAAA,EAAmB,CACvC,GAAI,CAGF,OADwB,MAAMD,CAAAA,EAAwB,CAWhC,MAJK,IAAI,SAC7B,qHACF,CAAA,IAPE,OAAA,CAAQ,IAAA,CAAK,+EAA+E,CAAA,CACrF,IAAA,CAUX,CAAA,MAASE,CAAAA,CAAO,CACd,OAAA,OAAA,CAAQ,IAAA,CAAK,iCAAkCA,CAAK,CAAA,CAC7C,IACT,CACF","file":"chunk-IGRMM7IL.cjs","sourcesContent":["/**\n * This file contains utility functions for dynamically importing Solana-specific dependencies.\n * It allows the package to be used in EVM-only environments without requiring Solana dependencies.\n */\n\n// Detect if we're in a bundler environment\nexport const IS_BUNDLER_ENV = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\n\n/**\n * Checks if the required Solana dependencies are available.\n * @returns A promise that resolves to a boolean indicating if the dependencies are available.\n */\nexport async function checkSolanaDependencies(): Promise<boolean> {\n if (IS_BUNDLER_ENV) {\n try {\n // In a bundler environment, use Function constructor to avoid static analysis\n const checkImport = new Function(\n 'try { return Boolean(require(\"@tuwaio/orbit-solana\") && require(\"@tuwaio/satellite-solana\") && require(\"@wallet-standard/react\") && require(\"gill\")); } catch { return false; }',\n );\n return checkImport();\n } catch {\n return false;\n }\n }\n\n try {\n // In a non-bundler environment, use dynamic imports\n await Promise.all([\n import('@tuwaio/orbit-solana'),\n import('@tuwaio/satellite-solana'),\n import('@wallet-standard/react'),\n import('gill'),\n ]);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Dynamically imports and returns the Solana-specific exports.\n * @returns A promise that resolves to the Solana exports or null if the dependencies are not available.\n */\nexport async function getSolanaExports() {\n try {\n // Check if dependencies are available before attempting to import\n const hasDependencies = await checkSolanaDependencies();\n if (!hasDependencies) {\n console.warn('Solana dependencies are not available. Solana functionality will be disabled.');\n return null;\n }\n\n // Use Function constructor to avoid static analysis by bundlers\n const importSolanaModule = new Function(\n 'return import(\"./index.js\").catch(error => { console.warn(\"Failed to load Solana exports:\", error); return null; })',\n );\n\n const solanaExports = await importSolanaModule();\n return solanaExports;\n } catch (error) {\n console.warn('Failed to load Solana exports:', error);\n return null;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ var r=typeof process<"u"&&process.env?.NODE_ENV==="production";async function o(){if(r)try{return new Function('try { return Boolean(require("@tuwaio/orbit-solana") && require("@tuwaio/satellite-solana") && require("@wallet-standard/react") && require("gill")); } catch { return false; }')()}catch{return false}try{return await Promise.all([import('@tuwaio/orbit-solana'),import('@tuwaio/satellite-solana'),import('@wallet-standard/react'),import('gill')]),!0}catch{return false}}async function a(){try{return await o()?await new Function('return import("./index.js").catch(error => { console.warn("Failed to load Solana exports:", error); return null; })')():(console.warn("Solana dependencies are not available. Solana functionality will be disabled."),null)}catch(e){return console.warn("Failed to load Solana exports:",e),null}}export{r as a,o as b,a as c};//# sourceMappingURL=chunk-JJ2GE6TY.js.map
2
+ //# sourceMappingURL=chunk-JJ2GE6TY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/solana/dynamicImports.ts"],"names":["IS_BUNDLER_ENV","checkSolanaDependencies","getSolanaExports","error"],"mappings":"AAMO,IAAMA,EAAiB,OAAO,OAAA,CAAY,GAAA,EAAe,OAAA,CAAQ,KAAK,QAAA,GAAa,aAM1F,eAAsBC,CAAAA,EAA4C,CAChE,GAAID,CAAAA,CACF,GAAI,CAKF,OAHoB,IAAI,QAAA,CACtB,iLACF,CAAA,EAEF,MAAQ,CACN,OAAO,MACT,CAGF,GAAI,CAEF,OAAA,MAAM,OAAA,CAAQ,GAAA,CAAI,CAChB,OAAO,sBAAsB,CAAA,CAC7B,OAAO,0BAA0B,CAAA,CACjC,OAAO,wBAAwB,CAAA,CAC/B,OAAO,MAAM,CACf,CAAC,CAAA,CACM,CAAA,CACT,CAAA,KAAQ,CACN,OAAO,MACT,CACF,CAMA,eAAsBE,CAAAA,EAAmB,CACvC,GAAI,CAGF,OADwB,MAAMD,CAAAA,EAAwB,CAWhC,MAJK,IAAI,SAC7B,qHACF,CAAA,IAPE,OAAA,CAAQ,IAAA,CAAK,+EAA+E,CAAA,CACrF,IAAA,CAUX,CAAA,MAASE,CAAAA,CAAO,CACd,OAAA,OAAA,CAAQ,IAAA,CAAK,iCAAkCA,CAAK,CAAA,CAC7C,IACT,CACF","file":"chunk-JJ2GE6TY.js","sourcesContent":["/**\n * This file contains utility functions for dynamically importing Solana-specific dependencies.\n * It allows the package to be used in EVM-only environments without requiring Solana dependencies.\n */\n\n// Detect if we're in a bundler environment\nexport const IS_BUNDLER_ENV = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\n\n/**\n * Checks if the required Solana dependencies are available.\n * @returns A promise that resolves to a boolean indicating if the dependencies are available.\n */\nexport async function checkSolanaDependencies(): Promise<boolean> {\n if (IS_BUNDLER_ENV) {\n try {\n // In a bundler environment, use Function constructor to avoid static analysis\n const checkImport = new Function(\n 'try { return Boolean(require(\"@tuwaio/orbit-solana\") && require(\"@tuwaio/satellite-solana\") && require(\"@wallet-standard/react\") && require(\"gill\")); } catch { return false; }',\n );\n return checkImport();\n } catch {\n return false;\n }\n }\n\n try {\n // In a non-bundler environment, use dynamic imports\n await Promise.all([\n import('@tuwaio/orbit-solana'),\n import('@tuwaio/satellite-solana'),\n import('@wallet-standard/react'),\n import('gill'),\n ]);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Dynamically imports and returns the Solana-specific exports.\n * @returns A promise that resolves to the Solana exports or null if the dependencies are not available.\n */\nexport async function getSolanaExports() {\n try {\n // Check if dependencies are available before attempting to import\n const hasDependencies = await checkSolanaDependencies();\n if (!hasDependencies) {\n console.warn('Solana dependencies are not available. Solana functionality will be disabled.');\n return null;\n }\n\n // Use Function constructor to avoid static analysis by bundlers\n const importSolanaModule = new Function(\n 'return import(\"./index.js\").catch(error => { console.warn(\"Failed to load Solana exports:\", error); return null; })',\n );\n\n const solanaExports = await importSolanaModule();\n return solanaExports;\n } catch (error) {\n console.warn('Failed to load Solana exports:', error);\n return null;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ var r=typeof process<"u"&&process.env?.NODE_ENV==="production";async function t(){if(r)try{return new Function('try { return Boolean(require("@tuwaio/orbit-evm") && require("@tuwaio/satellite-evm") && require("@wagmi/core") && require("viem")); } catch { return false; }')()}catch{return false}try{return await Promise.all([import('@tuwaio/orbit-evm'),import('@tuwaio/satellite-evm'),import('@wagmi/core'),import('viem')]),!0}catch{return false}}async function i(){try{return await t()?await new Function('return import("./index.js").catch(error => { console.warn("Failed to load EVM exports:", error); return null; })')():(console.warn("EVM dependencies are not available. EVM functionality will be disabled."),null)}catch(e){return console.warn("Failed to load EVM exports:",e),null}}export{r as a,t as b,i as c};//# sourceMappingURL=chunk-TLEFGK44.js.map
2
+ //# sourceMappingURL=chunk-TLEFGK44.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/evm/dynamicImports.ts"],"names":["IS_BUNDLER_ENV","checkEvmDependencies","getEvmExports","error"],"mappings":"AAMO,IAAMA,EAAiB,OAAO,OAAA,CAAY,GAAA,EAAe,OAAA,CAAQ,KAAK,QAAA,GAAa,aAM1F,eAAsBC,CAAAA,EAAyC,CAC7D,GAAID,CAAAA,CACF,GAAI,CAKF,OAHoB,IAAI,QAAA,CACtB,gKACF,CAAA,EAEF,MAAQ,CACN,OAAO,MACT,CAGF,GAAI,CAEF,OAAA,MAAM,OAAA,CAAQ,GAAA,CAAI,CAChB,OAAO,mBAAmB,CAAA,CAC1B,OAAO,uBAAuB,CAAA,CAC9B,OAAO,aAAa,CAAA,CACpB,OAAO,MAAM,CACf,CAAC,CAAA,CACM,CAAA,CACT,CAAA,KAAQ,CACN,OAAO,MACT,CACF,CAMA,eAAsBE,CAAAA,EAAgB,CACpC,GAAI,CAGF,OADwB,MAAMD,CAAAA,EAAqB,CAWhC,MAJK,IAAI,SAC1B,kHACF,CAAA,IAPE,OAAA,CAAQ,IAAA,CAAK,yEAAyE,CAAA,CAC/E,IAAA,CAUX,CAAA,MAASE,CAAAA,CAAO,CACd,OAAA,OAAA,CAAQ,IAAA,CAAK,8BAA+BA,CAAK,CAAA,CAC1C,IACT,CACF","file":"chunk-TLEFGK44.js","sourcesContent":["/**\n * This file contains utility functions for dynamically importing EVM-specific dependencies.\n * It allows the package to be used in Solana-only environments without requiring EVM dependencies.\n */\n\n// Detect if we're in a bundler environment\nexport const IS_BUNDLER_ENV = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\n\n/**\n * Checks if the required EVM dependencies are available.\n * @returns A promise that resolves to a boolean indicating if the dependencies are available.\n */\nexport async function checkEvmDependencies(): Promise<boolean> {\n if (IS_BUNDLER_ENV) {\n try {\n // In a bundler environment, use Function constructor to avoid static analysis\n const checkImport = new Function(\n 'try { return Boolean(require(\"@tuwaio/orbit-evm\") && require(\"@tuwaio/satellite-evm\") && require(\"@wagmi/core\") && require(\"viem\")); } catch { return false; }',\n );\n return checkImport();\n } catch {\n return false;\n }\n }\n\n try {\n // In a non-bundler environment, use dynamic imports\n await Promise.all([\n import('@tuwaio/orbit-evm'),\n import('@tuwaio/satellite-evm'),\n import('@wagmi/core'),\n import('viem'),\n ]);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Dynamically imports and returns the EVM-specific exports.\n * @returns A promise that resolves to the EVM exports or null if the dependencies are not available.\n */\nexport async function getEvmExports() {\n try {\n // Check if dependencies are available before attempting to import\n const hasDependencies = await checkEvmDependencies();\n if (!hasDependencies) {\n console.warn('EVM dependencies are not available. EVM functionality will be disabled.');\n return null;\n }\n\n // Use Function constructor to avoid static analysis by bundlers\n const importEvmModule = new Function(\n 'return import(\"./index.js\").catch(error => { console.warn(\"Failed to load EVM exports:\", error); return null; })',\n );\n\n const evmExports = await importEvmModule();\n return evmExports;\n } catch (error) {\n console.warn('Failed to load EVM exports:', error);\n return null;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import {c}from'./chunk-TLEFGK44.js';import {c as c$1}from'./chunk-JJ2GE6TY.js';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=t=>{let e=useContext(r);if(!e)throw new Error("useSatelliteConnectStore must be used within a SatelliteConnectProvider");return useStore(e,t)};var a=({initializeAutoConnect:t,onError:e})=>{useEffect(()=>{(async()=>{try{await t();}catch(o){(e??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function L({children:t,autoConnect:e,...n}){let o=useMemo(()=>createSatelliteConnectStore({...n}),[]);return a({initializeAutoConnect:()=>o.getState().initializeAutoConnect(e??!1)}),jsx(r.Provider,{value:o,children:t})}var x=typeof process<"u"&&process.env?.NODE_ENV==="production";async function d(){try{let t=await c();t&&Object.assign(exports,t);let e=await c$1();e&&Object.assign(exports,e);}catch(t){console.warn("Error initializing satellite-react:",t);}}x||d().catch(console.error);export{r as a,A as b,a as c,L as d,x as e,d as f};//# sourceMappingURL=chunk-V7GNOGFC.js.map
2
+ //# sourceMappingURL=chunk-V7GNOGFC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/satelliteHook.ts","../src/hooks/useInitializeAutoConnect.tsx","../src/providers/SatelliteConnectProvider.tsx","../src/index.ts"],"names":["SatelliteStoreContext","createContext","useSatelliteConnectStore","selector","store","useContext","useStore","useInitializeAutoConnect","initializeAutoConnect","onError","useEffect","error","e","SatelliteConnectProvider","children","autoConnect","parameters","useMemo","createSatelliteConnectStore","jsx","IS_BUNDLER_ENV","initializeSatelliteReact","evmExports","getEvmExports","solanaExports","getSolanaExports"],"mappings":"kRAUO,IAAMA,EAAwBC,aAAAA,CACnC,IACF,EAqBaC,CAAAA,CACXC,CAAAA,EACM,CAEN,IAAMC,CAAAA,CAAQC,WAAWL,CAAqB,CAAA,CAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,SAASF,CAAAA,CAAOD,CAAQ,CACjC,MCLaI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,QAAAC,CAAQ,CAAA,GAAwC,CAChHC,SAAAA,CAAU,IAAM,EACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,IACR,CAAA,MAASG,EAAO,CAAA,CAEOF,CAAAA,GAAaG,GAAa,OAAA,CAAQ,KAAA,CAAM,qCAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,KAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,QAAA,CAAAC,EAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,CAAA,CAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,QAAQ,IACbC,2BAAAA,CAAmD,CACxD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAEL,OAAAT,EAAyB,CACvB,qBAAA,CAAuB,IAAMH,CAAAA,CAAM,QAAA,GAAW,qBAAA,CAAsBW,CAAAA,EAAe,EAAK,CAC1F,CAAC,EAEMI,GAAAA,CAACnB,CAAAA,CAAsB,SAAtB,CAA+B,KAAA,CAAOI,EAAQ,QAAA,CAAAU,CAAAA,CAAS,CACjE,CCrDO,IAAMM,EAAiB,OAAO,OAAA,CAAY,KAAe,OAAA,CAAQ,GAAA,EAAK,WAAa,aAQ1F,eAAsBC,GAA2B,CAC/C,GAAI,CAEF,IAAMC,CAAAA,CAAa,MAAMC,CAAAA,EAAc,CACnCD,GACF,MAAA,CAAO,MAAA,CAAO,QAASA,CAAU,CAAA,CAInC,IAAME,CAAAA,CAAgB,MAAMC,KAAiB,CACzCD,CAAAA,EACF,OAAO,MAAA,CAAO,OAAA,CAASA,CAAa,EAExC,CAAA,MAASb,EAAO,CACd,OAAA,CAAQ,KAAK,qCAAA,CAAuCA,CAAK,EAC3D,CACF,CAGKS,GACHC,CAAAA,EAAyB,CAAE,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA","file":"chunk-V7GNOGFC.js","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connection, Connector } 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, Connection>> | null>(\n null,\n);\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>(\n selector: (state: ISatelliteConnectStore<Connector, Connection>) => T,\n): 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 connector auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected connector) 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 { useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satelliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connection, Connector } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used connector */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages connector connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles connector 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 connector reconnection\n * @param props.adapter - Blockchain adapter(s) for connector 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, Connection>({\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 useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n","// Core exports that are always available\nexport * from './hooks/satelliteHook';\nexport * from './hooks/useInitializeAutoConnect';\nexport * from './providers/SatelliteConnectProvider';\nexport * from './types';\n\n// Dynamic imports for blockchain-specific modules\nimport { getEvmExports } from './evm/dynamicImports';\nimport { getSolanaExports } from './solana/dynamicImports';\n\n// Detect if we're in a bundler environment\nexport const IS_BUNDLER_ENV = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\n\n/**\n * Dynamically loads and initializes blockchain-specific modules.\n * This function should be called at the application entry point.\n *\n * @returns A promise that resolves when all modules are loaded.\n */\nexport async function initializeSatelliteReact() {\n try {\n // Load EVM module if dependencies are available\n const evmExports = await getEvmExports();\n if (evmExports) {\n Object.assign(exports, evmExports);\n }\n\n // Load Solana module if dependencies are available\n const solanaExports = await getSolanaExports();\n if (solanaExports) {\n Object.assign(exports, solanaExports);\n }\n } catch (error) {\n console.warn('Error initializing satellite-react:', error);\n }\n}\n\n// Auto-initialize in non-bundler environments\nif (!IS_BUNDLER_ENV) {\n initializeSatelliteReact().catch(console.error);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunk6RDFJAW4_cjs=require('../chunk-6RDFJAW4.cjs');Object.defineProperty(exports,"IS_BUNDLER_ENV",{enumerable:true,get:function(){return chunk6RDFJAW4_cjs.a}});Object.defineProperty(exports,"checkEvmDependencies",{enumerable:true,get:function(){return chunk6RDFJAW4_cjs.b}});Object.defineProperty(exports,"getEvmExports",{enumerable:true,get:function(){return chunk6RDFJAW4_cjs.c}});//# sourceMappingURL=dynamicImports.cjs.map
2
+ //# sourceMappingURL=dynamicImports.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"dynamicImports.cjs"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file contains utility functions for dynamically importing EVM-specific dependencies.
3
+ * It allows the package to be used in Solana-only environments without requiring EVM dependencies.
4
+ */
5
+ declare const IS_BUNDLER_ENV: boolean;
6
+ /**
7
+ * Checks if the required EVM dependencies are available.
8
+ * @returns A promise that resolves to a boolean indicating if the dependencies are available.
9
+ */
10
+ declare function checkEvmDependencies(): Promise<boolean>;
11
+ /**
12
+ * Dynamically imports and returns the EVM-specific exports.
13
+ * @returns A promise that resolves to the EVM exports or null if the dependencies are not available.
14
+ */
15
+ declare function getEvmExports(): Promise<any>;
16
+
17
+ export { IS_BUNDLER_ENV, checkEvmDependencies, getEvmExports };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file contains utility functions for dynamically importing EVM-specific dependencies.
3
+ * It allows the package to be used in Solana-only environments without requiring EVM dependencies.
4
+ */
5
+ declare const IS_BUNDLER_ENV: boolean;
6
+ /**
7
+ * Checks if the required EVM dependencies are available.
8
+ * @returns A promise that resolves to a boolean indicating if the dependencies are available.
9
+ */
10
+ declare function checkEvmDependencies(): Promise<boolean>;
11
+ /**
12
+ * Dynamically imports and returns the EVM-specific exports.
13
+ * @returns A promise that resolves to the EVM exports or null if the dependencies are not available.
14
+ */
15
+ declare function getEvmExports(): Promise<any>;
16
+
17
+ export { IS_BUNDLER_ENV, checkEvmDependencies, getEvmExports };
@@ -0,0 +1,2 @@
1
+ export{a as IS_BUNDLER_ENV,b as checkEvmDependencies,c as getEvmExports}from'../chunk-TLEFGK44.js';//# sourceMappingURL=dynamicImports.js.map
2
+ //# sourceMappingURL=dynamicImports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"dynamicImports.js"}
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk23IZMVDP_cjs=require('../chunk-23IZMVDP.cjs'),orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react');function v({wagmiConfig:a,siwe:o}){let n=chunk23IZMVDP_cjs.b(e=>e.activeConnection),c=chunk23IZMVDP_cjs.b(e=>e.disconnect),s=chunk23IZMVDP_cjs.b(e=>e.connectionError),l=chunk23IZMVDP_cjs.b(e=>e.updateActiveConnection);return react.useEffect(()=>{o?.enabled&&!o?.isSignedIn&&o?.isRejected&&n&&c(n.connectorType);},[o,c,n]),react.useEffect(()=>core.watchConnections(a,{onChange:u=>{if(n&&orbitCore.getAdapterFromConnectorType(n.connectorType)!==orbitCore.OrbitAdapter.EVM)return;if(u.length===0){n&&c(n.connectorType);return}let t=core.getConnection(a);if(n&&orbitCore.getAdapterFromConnectorType(n.connectorType)!==orbitCore.OrbitAdapter.EVM||!t||s)return;if(o?.enabled?o.isSignedIn:true){let p=t.connector,f={connectorType:p?`${orbitCore.OrbitAdapter.EVM}:${orbitCore.formatConnectorName(p.name)}`:n?.connectorType,address:t.address,chainId:t.chainId,rpcURL:t?.chain?.rpcUrls.default.http[0],isConnected:true};l(f);}}}),[n?.connectorType,o,s]),null}exports.EVMConnectorsWatcher=v;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunkCL2PKR7V_cjs=require('../chunk-CL2PKR7V.cjs');require('../chunk-6RDFJAW4.cjs'),require('../chunk-IGRMM7IL.cjs');var orbitCore=require('@tuwaio/orbit-core'),core=require('@wagmi/core'),react=require('react');function v({wagmiConfig:a,siwe:o}){let n=chunkCL2PKR7V_cjs.b(e=>e.activeConnection),c=chunkCL2PKR7V_cjs.b(e=>e.disconnect),s=chunkCL2PKR7V_cjs.b(e=>e.connectionError),l=chunkCL2PKR7V_cjs.b(e=>e.updateActiveConnection);return react.useEffect(()=>{o?.enabled&&!o?.isSignedIn&&o?.isRejected&&n&&c(n.connectorType);},[o,c,n]),react.useEffect(()=>core.watchConnections(a,{onChange:u=>{if(n&&orbitCore.getAdapterFromConnectorType(n.connectorType)!==orbitCore.OrbitAdapter.EVM)return;if(u.length===0){n&&c(n.connectorType);return}let t=core.getConnection(a);if(n&&orbitCore.getAdapterFromConnectorType(n.connectorType)!==orbitCore.OrbitAdapter.EVM||!t||s)return;if(o?.enabled?o.isSignedIn:true){let p=t.connector,f={connectorType:p?`${orbitCore.OrbitAdapter.EVM}:${orbitCore.formatConnectorName(p.name)}`:n?.connectorType,address:t.address,chainId:t.chainId,rpcURL:t?.chain?.rpcUrls.default.http[0],isConnected:true};l(f);}}}),[n?.connectorType,o,s]),null}exports.EVMConnectorsWatcher=v;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/evm/EVMConnectorsWatcher.tsx"],"names":["EVMConnectorsWatcher","wagmiConfig","siwe","activeConnection","useSatelliteConnectStore","store","disconnect","connectionError","updateActiveConnection","useEffect","watchConnections","connections","getAdapterFromConnectorType","OrbitAdapter","currentConnection","getConnection","currentConnector","updatedConnector","formatConnectorName"],"mappings":"+JAiDO,SAASA,CAAAA,CAAqB,CAAE,WAAA,CAAAC,CAAAA,CAAa,KAAAC,CAAK,CAAA,CAA8B,CAUrF,IAAMC,CAAAA,CAAmBC,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CAI7EC,CAAAA,CAAaF,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,CAAAA,CAAkBH,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,eAAe,CAAA,CAI3EG,EAAyBJ,mBAAAA,CAA0BC,CAAAA,EAAUA,EAAM,sBAAsB,CAAA,CAY/F,OAAAI,eAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,SAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC1CC,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,EAG/C,EAAG,CAACD,CAAAA,CAAMI,EAAYH,CAAgB,CAAC,EASvCM,eAAAA,CAAU,IAgEQC,sBAAiBT,CAAAA,CAAa,CAAE,SAzDyBU,CAAAA,EAAgB,CAEvF,GAAIR,CAAAA,EAAoBS,qCAAAA,CAA4BT,EAAiB,aAAa,CAAA,GAAMU,sBAAAA,CAAa,GAAA,CACnG,OAIF,GAAIF,CAAAA,CAAY,SAAW,CAAA,CAAG,CACxBR,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,CAAA,CAE3C,MACF,CAEA,IAAMW,EAAoBC,kBAAAA,CAAcd,CAAW,EAQnD,GACGE,CAAAA,EAAoBS,qCAAAA,CAA4BT,CAAAA,CAAiB,aAAa,CAAA,GAAMU,sBAAAA,CAAa,KAClG,CAACC,CAAAA,EACDP,EAEA,OAUF,GAFqBL,GAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAChB,IAAMc,CAAAA,CAAmBF,CAAAA,CAAkB,UAKrCG,CAAAA,CAAmB,CACvB,aAAA,CAL2BD,CAAAA,CACxB,GAAGH,sBAAAA,CAAa,GAAG,IAAIK,6BAAAA,CAAoBF,CAAAA,CAAiB,IAAI,CAAC,CAAA,CAAA,CAClEb,GAAkB,aAAA,CAIpB,OAAA,CAASW,EAAkB,OAAA,CAC3B,OAAA,CAASA,EAAkB,OAAA,CAC3B,MAAA,CAAQA,GAAmB,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACxD,WAAA,CAAa,IACf,CAAA,CAGAN,CAAAA,CAAuBS,CAAgB,EACzC,CACF,CAGkF,CAAC,CAAA,CAOlF,CAACd,CAAAA,EAAkB,aAAA,CAAeD,EAAMK,CAAe,CAAC,EAGpD,IACT","file":"index.cjs","sourcesContent":["import { ConnectorType, formatConnectorName, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, getConnection, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMConnectorsWatcher} component.\n */\ninterface EVMConnectorsWatcherProps {\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 connector\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 EVMConnectorsWatcherProps} for details.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMConnectorsWatcher({ wagmiConfig, siwe }: EVMConnectorsWatcherProps) {\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 connector disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n /**\n * The global function to update the active connector'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.connectorType);\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 connectors' 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 && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Case 1: No connections means all connectors were disconnected\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n return;\n }\n\n const currentConnection = getConnection(wagmiConfig);\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active connector in our store is NOT an EVM connector\n // (we don't want this watcher to override a non-EVM connector).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) ||\n !currentConnection ||\n connectionError\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 const currentConnector = currentConnection.connector;\n const currentConnectorType = currentConnector\n ? (`${OrbitAdapter.EVM}:${formatConnectorName(currentConnector.name)}` as ConnectorType)\n : activeConnection?.connectorType;\n\n const updatedConnector = {\n connectorType: currentConnectorType,\n address: currentConnection.address,\n chainId: currentConnection.chainId,\n rpcURL: currentConnection?.chain?.rpcUrls.default.http[0],\n isConnected: true,\n };\n\n // Update the global store with the new connector state.\n updateActiveConnection(updatedConnector);\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?.connectorType, siwe, connectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/evm/EVMConnectorsWatcher.tsx"],"names":["EVMConnectorsWatcher","wagmiConfig","siwe","activeConnection","useSatelliteConnectStore","store","disconnect","connectionError","updateActiveConnection","useEffect","watchConnections","connections","getAdapterFromConnectorType","OrbitAdapter","currentConnection","getConnection","currentConnector","updatedConnector","formatConnectorName"],"mappings":"qOAiDO,SAASA,CAAAA,CAAqB,CAAE,WAAA,CAAAC,CAAAA,CAAa,KAAAC,CAAK,CAAA,CAA8B,CAUrF,IAAMC,CAAAA,CAAmBC,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CAI7EC,CAAAA,CAAaF,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,CAAAA,CAAkBH,oBAA0BC,CAAAA,EAAUA,CAAAA,CAAM,eAAe,CAAA,CAI3EG,EAAyBJ,mBAAAA,CAA0BC,CAAAA,EAAUA,EAAM,sBAAsB,CAAA,CAY/F,OAAAI,eAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,SAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC1CC,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,EAG/C,EAAG,CAACD,CAAAA,CAAMI,EAAYH,CAAgB,CAAC,EASvCM,eAAAA,CAAU,IAgEQC,sBAAiBT,CAAAA,CAAa,CAAE,SAzDyBU,CAAAA,EAAgB,CAEvF,GAAIR,CAAAA,EAAoBS,qCAAAA,CAA4BT,EAAiB,aAAa,CAAA,GAAMU,sBAAAA,CAAa,GAAA,CACnG,OAIF,GAAIF,CAAAA,CAAY,SAAW,CAAA,CAAG,CACxBR,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,CAAA,CAE3C,MACF,CAEA,IAAMW,EAAoBC,kBAAAA,CAAcd,CAAW,EAQnD,GACGE,CAAAA,EAAoBS,qCAAAA,CAA4BT,CAAAA,CAAiB,aAAa,CAAA,GAAMU,sBAAAA,CAAa,KAClG,CAACC,CAAAA,EACDP,EAEA,OAUF,GAFqBL,GAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAChB,IAAMc,CAAAA,CAAmBF,CAAAA,CAAkB,UAKrCG,CAAAA,CAAmB,CACvB,aAAA,CAL2BD,CAAAA,CACxB,GAAGH,sBAAAA,CAAa,GAAG,IAAIK,6BAAAA,CAAoBF,CAAAA,CAAiB,IAAI,CAAC,CAAA,CAAA,CAClEb,GAAkB,aAAA,CAIpB,OAAA,CAASW,EAAkB,OAAA,CAC3B,OAAA,CAASA,EAAkB,OAAA,CAC3B,MAAA,CAAQA,GAAmB,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACxD,WAAA,CAAa,IACf,CAAA,CAGAN,CAAAA,CAAuBS,CAAgB,EACzC,CACF,CAGkF,CAAC,CAAA,CAOlF,CAACd,CAAAA,EAAkB,aAAA,CAAeD,EAAMK,CAAe,CAAC,EAGpD,IACT","file":"index.cjs","sourcesContent":["import { ConnectorType, formatConnectorName, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, getConnection, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMConnectorsWatcher} component.\n */\ninterface EVMConnectorsWatcherProps {\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 connector\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 EVMConnectorsWatcherProps} for details.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMConnectorsWatcher({ wagmiConfig, siwe }: EVMConnectorsWatcherProps) {\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 connector disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n /**\n * The global function to update the active connector'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.connectorType);\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 connectors' 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 && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Case 1: No connections means all connectors were disconnected\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n return;\n }\n\n const currentConnection = getConnection(wagmiConfig);\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active connector in our store is NOT an EVM connector\n // (we don't want this watcher to override a non-EVM connector).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) ||\n !currentConnection ||\n connectionError\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 const currentConnector = currentConnection.connector;\n const currentConnectorType = currentConnector\n ? (`${OrbitAdapter.EVM}:${formatConnectorName(currentConnector.name)}` as ConnectorType)\n : activeConnection?.connectorType;\n\n const updatedConnector = {\n connectorType: currentConnectorType,\n address: currentConnection.address,\n chainId: currentConnection.chainId,\n rpcURL: currentConnection?.chain?.rpcUrls.default.http[0],\n isConnected: true,\n };\n\n // Update the global store with the new connector state.\n updateActiveConnection(updatedConnector);\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?.connectorType, siwe, connectionError]);\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-4RWO4WUN.js';import {getAdapterFromConnectorType,OrbitAdapter,formatConnectorName}from'@tuwaio/orbit-core';import {watchConnections,getConnection}from'@wagmi/core';import {useEffect}from'react';function v({wagmiConfig:a,siwe:o}){let n=b(e=>e.activeConnection),c=b(e=>e.disconnect),s=b(e=>e.connectionError),l=b(e=>e.updateActiveConnection);return useEffect(()=>{o?.enabled&&!o?.isSignedIn&&o?.isRejected&&n&&c(n.connectorType);},[o,c,n]),useEffect(()=>watchConnections(a,{onChange:u=>{if(n&&getAdapterFromConnectorType(n.connectorType)!==OrbitAdapter.EVM)return;if(u.length===0){n&&c(n.connectorType);return}let t=getConnection(a);if(n&&getAdapterFromConnectorType(n.connectorType)!==OrbitAdapter.EVM||!t||s)return;if(o?.enabled?o.isSignedIn:true){let p=t.connector,f={connectorType:p?`${OrbitAdapter.EVM}:${formatConnectorName(p.name)}`:n?.connectorType,address:t.address,chainId:t.chainId,rpcURL:t?.chain?.rpcUrls.default.http[0],isConnected:true};l(f);}}}),[n?.connectorType,o,s]),null}export{v as EVMConnectorsWatcher};//# sourceMappingURL=index.js.map
1
+ import {b}from'../chunk-V7GNOGFC.js';import'../chunk-TLEFGK44.js';import'../chunk-JJ2GE6TY.js';import {getAdapterFromConnectorType,OrbitAdapter,formatConnectorName}from'@tuwaio/orbit-core';import {watchConnections,getConnection}from'@wagmi/core';import {useEffect}from'react';function v({wagmiConfig:a,siwe:o}){let n=b(e=>e.activeConnection),c=b(e=>e.disconnect),s=b(e=>e.connectionError),l=b(e=>e.updateActiveConnection);return useEffect(()=>{o?.enabled&&!o?.isSignedIn&&o?.isRejected&&n&&c(n.connectorType);},[o,c,n]),useEffect(()=>watchConnections(a,{onChange:u=>{if(n&&getAdapterFromConnectorType(n.connectorType)!==OrbitAdapter.EVM)return;if(u.length===0){n&&c(n.connectorType);return}let t=getConnection(a);if(n&&getAdapterFromConnectorType(n.connectorType)!==OrbitAdapter.EVM||!t||s)return;if(o?.enabled?o.isSignedIn:true){let p=t.connector,f={connectorType:p?`${OrbitAdapter.EVM}:${formatConnectorName(p.name)}`:n?.connectorType,address:t.address,chainId:t.chainId,rpcURL:t?.chain?.rpcUrls.default.http[0],isConnected:true};l(f);}}}),[n?.connectorType,o,s]),null}export{v as EVMConnectorsWatcher};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/evm/EVMConnectorsWatcher.tsx"],"names":["EVMConnectorsWatcher","wagmiConfig","siwe","activeConnection","useSatelliteConnectStore","store","disconnect","connectionError","updateActiveConnection","useEffect","watchConnections","connections","getAdapterFromConnectorType","OrbitAdapter","currentConnection","getConnection","currentConnector","updatedConnector","formatConnectorName"],"mappings":"0NAiDO,SAASA,CAAAA,CAAqB,CAAE,WAAA,CAAAC,CAAAA,CAAa,KAAAC,CAAK,CAAA,CAA8B,CAUrF,IAAMC,CAAAA,CAAmBC,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CAI7EC,CAAAA,CAAaF,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,CAAAA,CAAkBH,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,eAAe,CAAA,CAI3EG,EAAyBJ,CAAAA,CAA0BC,CAAAA,EAAUA,EAAM,sBAAsB,CAAA,CAY/F,OAAAI,SAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,SAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC1CC,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,EAG/C,EAAG,CAACD,CAAAA,CAAMI,EAAYH,CAAgB,CAAC,EASvCM,SAAAA,CAAU,IAgEQC,iBAAiBT,CAAAA,CAAa,CAAE,SAzDyBU,CAAAA,EAAgB,CAEvF,GAAIR,CAAAA,EAAoBS,2BAAAA,CAA4BT,EAAiB,aAAa,CAAA,GAAMU,YAAAA,CAAa,GAAA,CACnG,OAIF,GAAIF,CAAAA,CAAY,SAAW,CAAA,CAAG,CACxBR,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,CAAA,CAE3C,MACF,CAEA,IAAMW,EAAoBC,aAAAA,CAAcd,CAAW,EAQnD,GACGE,CAAAA,EAAoBS,2BAAAA,CAA4BT,CAAAA,CAAiB,aAAa,CAAA,GAAMU,YAAAA,CAAa,KAClG,CAACC,CAAAA,EACDP,EAEA,OAUF,GAFqBL,GAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAChB,IAAMc,CAAAA,CAAmBF,CAAAA,CAAkB,UAKrCG,CAAAA,CAAmB,CACvB,aAAA,CAL2BD,CAAAA,CACxB,GAAGH,YAAAA,CAAa,GAAG,IAAIK,mBAAAA,CAAoBF,CAAAA,CAAiB,IAAI,CAAC,CAAA,CAAA,CAClEb,GAAkB,aAAA,CAIpB,OAAA,CAASW,EAAkB,OAAA,CAC3B,OAAA,CAASA,EAAkB,OAAA,CAC3B,MAAA,CAAQA,GAAmB,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACxD,WAAA,CAAa,IACf,CAAA,CAGAN,CAAAA,CAAuBS,CAAgB,EACzC,CACF,CAGkF,CAAC,CAAA,CAOlF,CAACd,CAAAA,EAAkB,aAAA,CAAeD,EAAMK,CAAe,CAAC,EAGpD,IACT","file":"index.js","sourcesContent":["import { ConnectorType, formatConnectorName, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, getConnection, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMConnectorsWatcher} component.\n */\ninterface EVMConnectorsWatcherProps {\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 connector\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 EVMConnectorsWatcherProps} for details.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMConnectorsWatcher({ wagmiConfig, siwe }: EVMConnectorsWatcherProps) {\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 connector disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n /**\n * The global function to update the active connector'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.connectorType);\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 connectors' 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 && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Case 1: No connections means all connectors were disconnected\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n return;\n }\n\n const currentConnection = getConnection(wagmiConfig);\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active connector in our store is NOT an EVM connector\n // (we don't want this watcher to override a non-EVM connector).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) ||\n !currentConnection ||\n connectionError\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 const currentConnector = currentConnection.connector;\n const currentConnectorType = currentConnector\n ? (`${OrbitAdapter.EVM}:${formatConnectorName(currentConnector.name)}` as ConnectorType)\n : activeConnection?.connectorType;\n\n const updatedConnector = {\n connectorType: currentConnectorType,\n address: currentConnection.address,\n chainId: currentConnection.chainId,\n rpcURL: currentConnection?.chain?.rpcUrls.default.http[0],\n isConnected: true,\n };\n\n // Update the global store with the new connector state.\n updateActiveConnection(updatedConnector);\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?.connectorType, siwe, connectionError]);\n\n // This component is \"headless\" - it performs logic but renders nothing.\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/evm/EVMConnectorsWatcher.tsx"],"names":["EVMConnectorsWatcher","wagmiConfig","siwe","activeConnection","useSatelliteConnectStore","store","disconnect","connectionError","updateActiveConnection","useEffect","watchConnections","connections","getAdapterFromConnectorType","OrbitAdapter","currentConnection","getConnection","currentConnector","updatedConnector","formatConnectorName"],"mappings":"oRAiDO,SAASA,CAAAA,CAAqB,CAAE,WAAA,CAAAC,CAAAA,CAAa,KAAAC,CAAK,CAAA,CAA8B,CAUrF,IAAMC,CAAAA,CAAmBC,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CAI7EC,CAAAA,CAAaF,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAIjEE,CAAAA,CAAkBH,EAA0BC,CAAAA,EAAUA,CAAAA,CAAM,eAAe,CAAA,CAI3EG,EAAyBJ,CAAAA,CAA0BC,CAAAA,EAAUA,EAAM,sBAAsB,CAAA,CAY/F,OAAAI,SAAAA,CAAU,IAAM,CACVP,CAAAA,EAAM,SAAW,CAACA,CAAAA,EAAM,YAAcA,CAAAA,EAAM,UAAA,EAC1CC,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,EAG/C,EAAG,CAACD,CAAAA,CAAMI,EAAYH,CAAgB,CAAC,EASvCM,SAAAA,CAAU,IAgEQC,iBAAiBT,CAAAA,CAAa,CAAE,SAzDyBU,CAAAA,EAAgB,CAEvF,GAAIR,CAAAA,EAAoBS,2BAAAA,CAA4BT,EAAiB,aAAa,CAAA,GAAMU,YAAAA,CAAa,GAAA,CACnG,OAIF,GAAIF,CAAAA,CAAY,SAAW,CAAA,CAAG,CACxBR,GACFG,CAAAA,CAAWH,CAAAA,CAAiB,aAAa,CAAA,CAE3C,MACF,CAEA,IAAMW,EAAoBC,aAAAA,CAAcd,CAAW,EAQnD,GACGE,CAAAA,EAAoBS,2BAAAA,CAA4BT,CAAAA,CAAiB,aAAa,CAAA,GAAMU,YAAAA,CAAa,KAClG,CAACC,CAAAA,EACDP,EAEA,OAUF,GAFqBL,GAAM,OAAA,CAAUA,CAAAA,CAAK,WAAa,IAAA,CAErC,CAChB,IAAMc,CAAAA,CAAmBF,CAAAA,CAAkB,UAKrCG,CAAAA,CAAmB,CACvB,aAAA,CAL2BD,CAAAA,CACxB,GAAGH,YAAAA,CAAa,GAAG,IAAIK,mBAAAA,CAAoBF,CAAAA,CAAiB,IAAI,CAAC,CAAA,CAAA,CAClEb,GAAkB,aAAA,CAIpB,OAAA,CAASW,EAAkB,OAAA,CAC3B,OAAA,CAASA,EAAkB,OAAA,CAC3B,MAAA,CAAQA,GAAmB,KAAA,EAAO,OAAA,CAAQ,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACxD,WAAA,CAAa,IACf,CAAA,CAGAN,CAAAA,CAAuBS,CAAgB,EACzC,CACF,CAGkF,CAAC,CAAA,CAOlF,CAACd,CAAAA,EAAkB,aAAA,CAAeD,EAAMK,CAAe,CAAC,EAGpD,IACT","file":"index.js","sourcesContent":["import { ConnectorType, formatConnectorName, getAdapterFromConnectorType, OrbitAdapter } from '@tuwaio/orbit-core';\nimport { Config, getConnection, watchConnections, WatchConnectionsParameters } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { useSatelliteConnectStore } from '../index';\n\n/**\n * Props for the {@link EVMConnectorsWatcher} component.\n */\ninterface EVMConnectorsWatcherProps {\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 connector\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 EVMConnectorsWatcherProps} for details.\n * @returns {null} This component does not render any UI.\n */\nexport function EVMConnectorsWatcher({ wagmiConfig, siwe }: EVMConnectorsWatcherProps) {\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 connector disconnection.\n */\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n /**\n * The current connection error state, if any.\n */\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n /**\n * The global function to update the active connector'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.connectorType);\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 connectors' 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 && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) {\n return;\n }\n\n // Case 1: No connections means all connectors were disconnected\n if (connections.length === 0) {\n if (activeConnection) {\n disconnect(activeConnection.connectorType);\n }\n return;\n }\n\n const currentConnection = getConnection(wagmiConfig);\n\n // --- Guard Clauses ---\n // Stop processing if any of these conditions are true:\n // 1. The currently active connector in our store is NOT an EVM connector\n // (we don't want this watcher to override a non-EVM connector).\n // 2. The current connection has no accounts.\n // 3. There is already a connection error in our global store.\n if (\n (activeConnection && getAdapterFromConnectorType(activeConnection.connectorType) !== OrbitAdapter.EVM) ||\n !currentConnection ||\n connectionError\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 const currentConnector = currentConnection.connector;\n const currentConnectorType = currentConnector\n ? (`${OrbitAdapter.EVM}:${formatConnectorName(currentConnector.name)}` as ConnectorType)\n : activeConnection?.connectorType;\n\n const updatedConnector = {\n connectorType: currentConnectorType,\n address: currentConnection.address,\n chainId: currentConnection.chainId,\n rpcURL: currentConnection?.chain?.rpcUrls.default.http[0],\n isConnected: true,\n };\n\n // Update the global store with the new connector state.\n updateActiveConnection(updatedConnector);\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?.connectorType, siwe, connectionError]);\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 chunk23IZMVDP_cjs=require('./chunk-23IZMVDP.cjs');Object.defineProperty(exports,"SatelliteConnectProvider",{enumerable:true,get:function(){return chunk23IZMVDP_cjs.d}});Object.defineProperty(exports,"SatelliteStoreContext",{enumerable:true,get:function(){return chunk23IZMVDP_cjs.a}});Object.defineProperty(exports,"useInitializeAutoConnect",{enumerable:true,get:function(){return chunk23IZMVDP_cjs.c}});Object.defineProperty(exports,"useSatelliteConnectStore",{enumerable:true,get:function(){return chunk23IZMVDP_cjs.b}});//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunkCL2PKR7V_cjs=require('./chunk-CL2PKR7V.cjs');require('./chunk-6RDFJAW4.cjs'),require('./chunk-IGRMM7IL.cjs');Object.defineProperty(exports,"IS_BUNDLER_ENV",{enumerable:true,get:function(){return chunkCL2PKR7V_cjs.e}});Object.defineProperty(exports,"SatelliteConnectProvider",{enumerable:true,get:function(){return chunkCL2PKR7V_cjs.d}});Object.defineProperty(exports,"SatelliteStoreContext",{enumerable:true,get:function(){return chunkCL2PKR7V_cjs.a}});Object.defineProperty(exports,"initializeSatelliteReact",{enumerable:true,get:function(){return chunkCL2PKR7V_cjs.f}});Object.defineProperty(exports,"useInitializeAutoConnect",{enumerable:true,get:function(){return chunkCL2PKR7V_cjs.c}});Object.defineProperty(exports,"useSatelliteConnectStore",{enumerable:true,get:function(){return chunkCL2PKR7V_cjs.b}});//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -139,4 +139,13 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
139
139
  */
140
140
  declare function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps): react_jsx_runtime.JSX.Element;
141
141
 
142
- export { type AllConnections, type AllConnectors, type Connection, type Connector, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, useInitializeAutoConnect, useSatelliteConnectStore };
142
+ declare const IS_BUNDLER_ENV: boolean;
143
+ /**
144
+ * Dynamically loads and initializes blockchain-specific modules.
145
+ * This function should be called at the application entry point.
146
+ *
147
+ * @returns A promise that resolves when all modules are loaded.
148
+ */
149
+ declare function initializeSatelliteReact(): Promise<void>;
150
+
151
+ export { type AllConnections, type AllConnectors, type Connection, type Connector, IS_BUNDLER_ENV, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, initializeSatelliteReact, useInitializeAutoConnect, useSatelliteConnectStore };
package/dist/index.d.ts CHANGED
@@ -139,4 +139,13 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
139
139
  */
140
140
  declare function SatelliteConnectProvider({ children, autoConnect, ...parameters }: SatelliteConnectProviderProps): react_jsx_runtime.JSX.Element;
141
141
 
142
- export { type AllConnections, type AllConnectors, type Connection, type Connector, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, useInitializeAutoConnect, useSatelliteConnectStore };
142
+ declare const IS_BUNDLER_ENV: boolean;
143
+ /**
144
+ * Dynamically loads and initializes blockchain-specific modules.
145
+ * This function should be called at the application entry point.
146
+ *
147
+ * @returns A promise that resolves when all modules are loaded.
148
+ */
149
+ declare function initializeSatelliteReact(): Promise<void>;
150
+
151
+ export { type AllConnections, type AllConnectors, type Connection, type Connector, IS_BUNDLER_ENV, SatelliteConnectProvider, type SatelliteConnectProviderProps, SatelliteStoreContext, initializeSatelliteReact, useInitializeAutoConnect, useSatelliteConnectStore };
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-4RWO4WUN.js';//# sourceMappingURL=index.js.map
1
+ export{e as IS_BUNDLER_ENV,d as SatelliteConnectProvider,a as SatelliteStoreContext,f as initializeSatelliteReact,c as useInitializeAutoConnect,b as useSatelliteConnectStore}from'./chunk-V7GNOGFC.js';import'./chunk-TLEFGK44.js';import'./chunk-JJ2GE6TY.js';//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkIGRMM7IL_cjs=require('../chunk-IGRMM7IL.cjs');Object.defineProperty(exports,"IS_BUNDLER_ENV",{enumerable:true,get:function(){return chunkIGRMM7IL_cjs.a}});Object.defineProperty(exports,"checkSolanaDependencies",{enumerable:true,get:function(){return chunkIGRMM7IL_cjs.b}});Object.defineProperty(exports,"getSolanaExports",{enumerable:true,get:function(){return chunkIGRMM7IL_cjs.c}});//# sourceMappingURL=dynamicImports.cjs.map
2
+ //# sourceMappingURL=dynamicImports.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"dynamicImports.cjs"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file contains utility functions for dynamically importing Solana-specific dependencies.
3
+ * It allows the package to be used in EVM-only environments without requiring Solana dependencies.
4
+ */
5
+ declare const IS_BUNDLER_ENV: boolean;
6
+ /**
7
+ * Checks if the required Solana dependencies are available.
8
+ * @returns A promise that resolves to a boolean indicating if the dependencies are available.
9
+ */
10
+ declare function checkSolanaDependencies(): Promise<boolean>;
11
+ /**
12
+ * Dynamically imports and returns the Solana-specific exports.
13
+ * @returns A promise that resolves to the Solana exports or null if the dependencies are not available.
14
+ */
15
+ declare function getSolanaExports(): Promise<any>;
16
+
17
+ export { IS_BUNDLER_ENV, checkSolanaDependencies, getSolanaExports };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file contains utility functions for dynamically importing Solana-specific dependencies.
3
+ * It allows the package to be used in EVM-only environments without requiring Solana dependencies.
4
+ */
5
+ declare const IS_BUNDLER_ENV: boolean;
6
+ /**
7
+ * Checks if the required Solana dependencies are available.
8
+ * @returns A promise that resolves to a boolean indicating if the dependencies are available.
9
+ */
10
+ declare function checkSolanaDependencies(): Promise<boolean>;
11
+ /**
12
+ * Dynamically imports and returns the Solana-specific exports.
13
+ * @returns A promise that resolves to the Solana exports or null if the dependencies are not available.
14
+ */
15
+ declare function getSolanaExports(): Promise<any>;
16
+
17
+ export { IS_BUNDLER_ENV, checkSolanaDependencies, getSolanaExports };
@@ -0,0 +1,2 @@
1
+ export{a as IS_BUNDLER_ENV,b as checkSolanaDependencies,c as getSolanaExports}from'../chunk-JJ2GE6TY.js';//# sourceMappingURL=dynamicImports.js.map
2
+ //# sourceMappingURL=dynamicImports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"dynamicImports.js"}
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk23IZMVDP_cjs=require('../chunk-23IZMVDP.cjs'),orbitCore=require('@tuwaio/orbit-core'),react=require('@wallet-standard/react'),react$1=require('react');function h(){let c=react.useWallets(),o=chunk23IZMVDP_cjs.b(n=>n.activeConnection),r=chunk23IZMVDP_cjs.b(n=>n.updateActiveConnection),a=chunk23IZMVDP_cjs.b(n=>n.connectionError),i=chunk23IZMVDP_cjs.b(n=>n.disconnect);return react$1.useEffect(()=>{if(o&&orbitCore.getAdapterFromConnectorType(o.connectorType)===orbitCore.OrbitAdapter.SOLANA){let n=c.filter(e=>orbitCore.getConnectorTypeFromName(orbitCore.OrbitAdapter.SOLANA,orbitCore.formatConnectorName(e.name))===o.connectorType)[0];if(!a){let e={address:n?.accounts[0]?.address,isConnected:n?.accounts.length>0,connectedAccount:n?.accounts[0],connectedWallet:n};(e.address!==o.address||e.isConnected!==o.isConnected)&&r(e);}n?.accounts.length===0&&o.connectorType&&i(o.connectorType);}},[o?.connectorType,c,a,r,i]),null}exports.SolanaConnectorsWatcher=h;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunkCL2PKR7V_cjs=require('../chunk-CL2PKR7V.cjs');require('../chunk-6RDFJAW4.cjs'),require('../chunk-IGRMM7IL.cjs');var orbitCore=require('@tuwaio/orbit-core'),react=require('@wallet-standard/react'),react$1=require('react');function h(){let c=react.useWallets(),o=chunkCL2PKR7V_cjs.b(n=>n.activeConnection),r=chunkCL2PKR7V_cjs.b(n=>n.updateActiveConnection),a=chunkCL2PKR7V_cjs.b(n=>n.connectionError),i=chunkCL2PKR7V_cjs.b(n=>n.disconnect);return react$1.useEffect(()=>{if(o&&orbitCore.getAdapterFromConnectorType(o.connectorType)===orbitCore.OrbitAdapter.SOLANA){let n=c.filter(e=>orbitCore.getConnectorTypeFromName(orbitCore.OrbitAdapter.SOLANA,orbitCore.formatConnectorName(e.name))===o.connectorType)[0];if(!a){let e={address:n?.accounts[0]?.address,isConnected:n?.accounts.length>0,connectedAccount:n?.accounts[0],connectedWallet:n};(e.address!==o.address||e.isConnected!==o.isConnected)&&r(e);}n?.accounts.length===0&&o.connectorType&&i(o.connectorType);}},[o?.connectorType,c,a,r,i]),null}exports.SolanaConnectorsWatcher=h;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/solana/SolanaConnectorsWatcher.tsx"],"names":["SolanaConnectorsWatcher","wallets","useWallets","activeConnectionFromStore","useSatelliteConnectStore","store","updateActiveConnection","connectionError","disconnect","useEffect","getAdapterFromConnectorType","OrbitAdapter","activeConnection","w","getConnectorTypeFromName","formatConnectorName","newState"],"mappings":"6KAsBO,SAASA,CAAAA,EAA0B,CACxC,IAAMC,EAAUC,gBAAAA,EAAW,CAErBC,CAAAA,CAA4BC,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CACtFC,EAAyBF,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,sBAAsB,CAAA,CACzFE,CAAAA,CAAkBH,mBAAAA,CAA0BC,CAAAA,EAAUA,EAAM,eAAe,CAAA,CAC3EG,CAAAA,CAAaJ,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,iBAAAA,CAAU,IAAM,CACd,GACEN,CAAAA,EACAO,qCAAAA,CAA4BP,CAAAA,CAA0B,aAAa,IAAMQ,sBAAAA,CAAa,MAAA,CACtF,CACA,IAAMC,CAAAA,CAAmBX,CAAAA,CAAQ,MAAA,CAC9BY,CAAAA,EACCC,mCAAyBH,sBAAAA,CAAa,MAAA,CAAQI,6BAAAA,CAAoBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GACzEV,CAAAA,CAA0B,aAC9B,CAAA,CAAE,CAAC,CAAA,CAEH,GAAI,CAACI,CAAAA,CAAiB,CACpB,IAAMS,CAAAA,CAAW,CAEf,OAAA,CAASJ,CAAAA,EAAkB,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAExC,YAAaA,CAAAA,EAAkB,QAAA,CAAS,MAAA,CAAS,CAAA,CAEjD,gBAAA,CAAkBA,CAAAA,EAAkB,QAAA,CAAS,CAAC,EAC9C,eAAA,CAAiBA,CACnB,CAAA,CAAA,CAMEI,CAAAA,CAAS,OAAA,GAAYb,CAAAA,CAA0B,OAAA,EAC/Ca,CAAAA,CAAS,cAAgBb,CAAAA,CAA0B,WAAA,GAInDG,CAAAA,CAAuBU,CAAQ,EAEnC,CACIJ,CAAAA,EAAkB,QAAA,CAAS,SAAW,CAAA,EAAKT,CAAAA,CAA0B,aAAA,EAEvEK,CAAAA,CAAWL,CAAAA,CAA0B,aAAa,EAEtD,CAEF,EAAG,CAACA,CAAAA,EAA2B,aAAA,CAAeF,CAAAA,CAASM,CAAAA,CAAiBD,CAAAA,CAAwBE,CAAU,CAAC,EAGpG,IACT","file":"index.cjs","sourcesContent":["import {\n formatConnectorName,\n getAdapterFromConnectorType,\n getConnectorTypeFromName,\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 connector connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana connectors using the Wallet Standard.\n * Currently handles the first active connector only, with multi-connector 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 SolanaConnectorsWatcher() {\n const wallets = useWallets();\n\n const activeConnectionFromStore = useSatelliteConnectStore((store) => store.activeConnection);\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected connectors\n useEffect(() => {\n if (\n activeConnectionFromStore &&\n getAdapterFromConnectorType(activeConnectionFromStore.connectorType) === OrbitAdapter.SOLANA\n ) {\n const activeConnection = wallets.filter(\n (w) =>\n getConnectorTypeFromName(OrbitAdapter.SOLANA, formatConnectorName(w.name)) ===\n activeConnectionFromStore.connectorType,\n )[0];\n\n if (!connectionError) {\n const newState = {\n // Use the first account's address\n address: activeConnection?.accounts[0]?.address,\n // Set connection status\n isConnected: activeConnection?.accounts.length > 0,\n // Store Wallet Standard specific information\n connectedAccount: activeConnection?.accounts[0],\n connectedWallet: activeConnection,\n };\n\n // Check if anything actually changed to prevent infinite loops\n // We only check address and isConnected because connectedAccount/connectedWallet\n // might be new references on every render, causing infinite loops if checked.\n const hasChanged =\n newState.address !== activeConnectionFromStore.address ||\n newState.isConnected !== activeConnectionFromStore.isConnected;\n\n if (hasChanged) {\n // Update the Satellite store with the active connector information\n updateActiveConnection(newState);\n }\n }\n if (activeConnection?.accounts.length === 0 && activeConnectionFromStore.connectorType) {\n // If the connector is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect(activeConnectionFromStore.connectorType);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnectionFromStore?.connectorType, wallets, connectionError, updateActiveConnection, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/solana/SolanaConnectorsWatcher.tsx"],"names":["SolanaConnectorsWatcher","wallets","useWallets","activeConnectionFromStore","useSatelliteConnectStore","store","updateActiveConnection","connectionError","disconnect","useEffect","getAdapterFromConnectorType","OrbitAdapter","activeConnection","w","getConnectorTypeFromName","formatConnectorName","newState"],"mappings":"mPAsBO,SAASA,CAAAA,EAA0B,CACxC,IAAMC,EAAUC,gBAAAA,EAAW,CAErBC,CAAAA,CAA4BC,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CACtFC,EAAyBF,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,sBAAsB,CAAA,CACzFE,CAAAA,CAAkBH,mBAAAA,CAA0BC,CAAAA,EAAUA,EAAM,eAAe,CAAA,CAC3EG,CAAAA,CAAaJ,mBAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,iBAAAA,CAAU,IAAM,CACd,GACEN,CAAAA,EACAO,qCAAAA,CAA4BP,CAAAA,CAA0B,aAAa,IAAMQ,sBAAAA,CAAa,MAAA,CACtF,CACA,IAAMC,CAAAA,CAAmBX,CAAAA,CAAQ,MAAA,CAC9BY,CAAAA,EACCC,mCAAyBH,sBAAAA,CAAa,MAAA,CAAQI,6BAAAA,CAAoBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GACzEV,CAAAA,CAA0B,aAC9B,CAAA,CAAE,CAAC,CAAA,CAEH,GAAI,CAACI,CAAAA,CAAiB,CACpB,IAAMS,CAAAA,CAAW,CAEf,OAAA,CAASJ,CAAAA,EAAkB,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAExC,YAAaA,CAAAA,EAAkB,QAAA,CAAS,MAAA,CAAS,CAAA,CAEjD,gBAAA,CAAkBA,CAAAA,EAAkB,QAAA,CAAS,CAAC,EAC9C,eAAA,CAAiBA,CACnB,CAAA,CAAA,CAMEI,CAAAA,CAAS,OAAA,GAAYb,CAAAA,CAA0B,OAAA,EAC/Ca,CAAAA,CAAS,cAAgBb,CAAAA,CAA0B,WAAA,GAInDG,CAAAA,CAAuBU,CAAQ,EAEnC,CACIJ,CAAAA,EAAkB,QAAA,CAAS,SAAW,CAAA,EAAKT,CAAAA,CAA0B,aAAA,EAEvEK,CAAAA,CAAWL,CAAAA,CAA0B,aAAa,EAEtD,CAEF,EAAG,CAACA,CAAAA,EAA2B,aAAA,CAAeF,CAAAA,CAASM,CAAAA,CAAiBD,CAAAA,CAAwBE,CAAU,CAAC,EAGpG,IACT","file":"index.cjs","sourcesContent":["import {\n formatConnectorName,\n getAdapterFromConnectorType,\n getConnectorTypeFromName,\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 connector connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana connectors using the Wallet Standard.\n * Currently handles the first active connector only, with multi-connector 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 SolanaConnectorsWatcher() {\n const wallets = useWallets();\n\n const activeConnectionFromStore = useSatelliteConnectStore((store) => store.activeConnection);\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected connectors\n useEffect(() => {\n if (\n activeConnectionFromStore &&\n getAdapterFromConnectorType(activeConnectionFromStore.connectorType) === OrbitAdapter.SOLANA\n ) {\n const activeConnection = wallets.filter(\n (w) =>\n getConnectorTypeFromName(OrbitAdapter.SOLANA, formatConnectorName(w.name)) ===\n activeConnectionFromStore.connectorType,\n )[0];\n\n if (!connectionError) {\n const newState = {\n // Use the first account's address\n address: activeConnection?.accounts[0]?.address,\n // Set connection status\n isConnected: activeConnection?.accounts.length > 0,\n // Store Wallet Standard specific information\n connectedAccount: activeConnection?.accounts[0],\n connectedWallet: activeConnection,\n };\n\n // Check if anything actually changed to prevent infinite loops\n // We only check address and isConnected because connectedAccount/connectedWallet\n // might be new references on every render, causing infinite loops if checked.\n const hasChanged =\n newState.address !== activeConnectionFromStore.address ||\n newState.isConnected !== activeConnectionFromStore.isConnected;\n\n if (hasChanged) {\n // Update the Satellite store with the active connector information\n updateActiveConnection(newState);\n }\n }\n if (activeConnection?.accounts.length === 0 && activeConnectionFromStore.connectorType) {\n // If the connector is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect(activeConnectionFromStore.connectorType);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnectionFromStore?.connectorType, wallets, connectionError, updateActiveConnection, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
@@ -1,2 +1,2 @@
1
- import {b}from'../chunk-4RWO4WUN.js';import {getAdapterFromConnectorType,OrbitAdapter,getConnectorTypeFromName,formatConnectorName}from'@tuwaio/orbit-core';import {useWallets}from'@wallet-standard/react';import {useEffect}from'react';function h(){let c=useWallets(),o=b(n=>n.activeConnection),r=b(n=>n.updateActiveConnection),a=b(n=>n.connectionError),i=b(n=>n.disconnect);return useEffect(()=>{if(o&&getAdapterFromConnectorType(o.connectorType)===OrbitAdapter.SOLANA){let n=c.filter(e=>getConnectorTypeFromName(OrbitAdapter.SOLANA,formatConnectorName(e.name))===o.connectorType)[0];if(!a){let e={address:n?.accounts[0]?.address,isConnected:n?.accounts.length>0,connectedAccount:n?.accounts[0],connectedWallet:n};(e.address!==o.address||e.isConnected!==o.isConnected)&&r(e);}n?.accounts.length===0&&o.connectorType&&i(o.connectorType);}},[o?.connectorType,c,a,r,i]),null}export{h as SolanaConnectorsWatcher};//# sourceMappingURL=index.js.map
1
+ import {b}from'../chunk-V7GNOGFC.js';import'../chunk-TLEFGK44.js';import'../chunk-JJ2GE6TY.js';import {getAdapterFromConnectorType,OrbitAdapter,getConnectorTypeFromName,formatConnectorName}from'@tuwaio/orbit-core';import {useWallets}from'@wallet-standard/react';import {useEffect}from'react';function h(){let c=useWallets(),o=b(n=>n.activeConnection),r=b(n=>n.updateActiveConnection),a=b(n=>n.connectionError),i=b(n=>n.disconnect);return useEffect(()=>{if(o&&getAdapterFromConnectorType(o.connectorType)===OrbitAdapter.SOLANA){let n=c.filter(e=>getConnectorTypeFromName(OrbitAdapter.SOLANA,formatConnectorName(e.name))===o.connectorType)[0];if(!a){let e={address:n?.accounts[0]?.address,isConnected:n?.accounts.length>0,connectedAccount:n?.accounts[0],connectedWallet:n};(e.address!==o.address||e.isConnected!==o.isConnected)&&r(e);}n?.accounts.length===0&&o.connectorType&&i(o.connectorType);}},[o?.connectorType,c,a,r,i]),null}export{h as SolanaConnectorsWatcher};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/solana/SolanaConnectorsWatcher.tsx"],"names":["SolanaConnectorsWatcher","wallets","useWallets","activeConnectionFromStore","useSatelliteConnectStore","store","updateActiveConnection","connectionError","disconnect","useEffect","getAdapterFromConnectorType","OrbitAdapter","activeConnection","w","getConnectorTypeFromName","formatConnectorName","newState"],"mappings":"0OAsBO,SAASA,CAAAA,EAA0B,CACxC,IAAMC,EAAUC,UAAAA,EAAW,CAErBC,CAAAA,CAA4BC,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CACtFC,EAAyBF,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,sBAAsB,CAAA,CACzFE,CAAAA,CAAkBH,CAAAA,CAA0BC,CAAAA,EAAUA,EAAM,eAAe,CAAA,CAC3EG,CAAAA,CAAaJ,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,SAAAA,CAAU,IAAM,CACd,GACEN,CAAAA,EACAO,2BAAAA,CAA4BP,CAAAA,CAA0B,aAAa,IAAMQ,YAAAA,CAAa,MAAA,CACtF,CACA,IAAMC,CAAAA,CAAmBX,CAAAA,CAAQ,MAAA,CAC9BY,CAAAA,EACCC,yBAAyBH,YAAAA,CAAa,MAAA,CAAQI,mBAAAA,CAAoBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GACzEV,CAAAA,CAA0B,aAC9B,CAAA,CAAE,CAAC,CAAA,CAEH,GAAI,CAACI,CAAAA,CAAiB,CACpB,IAAMS,CAAAA,CAAW,CAEf,OAAA,CAASJ,CAAAA,EAAkB,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAExC,YAAaA,CAAAA,EAAkB,QAAA,CAAS,MAAA,CAAS,CAAA,CAEjD,gBAAA,CAAkBA,CAAAA,EAAkB,QAAA,CAAS,CAAC,EAC9C,eAAA,CAAiBA,CACnB,CAAA,CAAA,CAMEI,CAAAA,CAAS,OAAA,GAAYb,CAAAA,CAA0B,OAAA,EAC/Ca,CAAAA,CAAS,cAAgBb,CAAAA,CAA0B,WAAA,GAInDG,CAAAA,CAAuBU,CAAQ,EAEnC,CACIJ,CAAAA,EAAkB,QAAA,CAAS,SAAW,CAAA,EAAKT,CAAAA,CAA0B,aAAA,EAEvEK,CAAAA,CAAWL,CAAAA,CAA0B,aAAa,EAEtD,CAEF,EAAG,CAACA,CAAAA,EAA2B,aAAA,CAAeF,CAAAA,CAASM,CAAAA,CAAiBD,CAAAA,CAAwBE,CAAU,CAAC,EAGpG,IACT","file":"index.js","sourcesContent":["import {\n formatConnectorName,\n getAdapterFromConnectorType,\n getConnectorTypeFromName,\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 connector connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana connectors using the Wallet Standard.\n * Currently handles the first active connector only, with multi-connector 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 SolanaConnectorsWatcher() {\n const wallets = useWallets();\n\n const activeConnectionFromStore = useSatelliteConnectStore((store) => store.activeConnection);\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected connectors\n useEffect(() => {\n if (\n activeConnectionFromStore &&\n getAdapterFromConnectorType(activeConnectionFromStore.connectorType) === OrbitAdapter.SOLANA\n ) {\n const activeConnection = wallets.filter(\n (w) =>\n getConnectorTypeFromName(OrbitAdapter.SOLANA, formatConnectorName(w.name)) ===\n activeConnectionFromStore.connectorType,\n )[0];\n\n if (!connectionError) {\n const newState = {\n // Use the first account's address\n address: activeConnection?.accounts[0]?.address,\n // Set connection status\n isConnected: activeConnection?.accounts.length > 0,\n // Store Wallet Standard specific information\n connectedAccount: activeConnection?.accounts[0],\n connectedWallet: activeConnection,\n };\n\n // Check if anything actually changed to prevent infinite loops\n // We only check address and isConnected because connectedAccount/connectedWallet\n // might be new references on every render, causing infinite loops if checked.\n const hasChanged =\n newState.address !== activeConnectionFromStore.address ||\n newState.isConnected !== activeConnectionFromStore.isConnected;\n\n if (hasChanged) {\n // Update the Satellite store with the active connector information\n updateActiveConnection(newState);\n }\n }\n if (activeConnection?.accounts.length === 0 && activeConnectionFromStore.connectorType) {\n // If the connector is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect(activeConnectionFromStore.connectorType);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnectionFromStore?.connectorType, wallets, connectionError, updateActiveConnection, disconnect]); // Re-run effect when wallets array changes\n\n // This is a headless component, so return null\n return null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/solana/SolanaConnectorsWatcher.tsx"],"names":["SolanaConnectorsWatcher","wallets","useWallets","activeConnectionFromStore","useSatelliteConnectStore","store","updateActiveConnection","connectionError","disconnect","useEffect","getAdapterFromConnectorType","OrbitAdapter","activeConnection","w","getConnectorTypeFromName","formatConnectorName","newState"],"mappings":"oSAsBO,SAASA,CAAAA,EAA0B,CACxC,IAAMC,EAAUC,UAAAA,EAAW,CAErBC,CAAAA,CAA4BC,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,gBAAgB,CAAA,CACtFC,EAAyBF,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,sBAAsB,CAAA,CACzFE,CAAAA,CAAkBH,CAAAA,CAA0BC,CAAAA,EAAUA,EAAM,eAAe,CAAA,CAC3EG,CAAAA,CAAaJ,CAAAA,CAA0BC,CAAAA,EAAUA,CAAAA,CAAM,UAAU,CAAA,CAGvE,OAAAI,SAAAA,CAAU,IAAM,CACd,GACEN,CAAAA,EACAO,2BAAAA,CAA4BP,CAAAA,CAA0B,aAAa,IAAMQ,YAAAA,CAAa,MAAA,CACtF,CACA,IAAMC,CAAAA,CAAmBX,CAAAA,CAAQ,MAAA,CAC9BY,CAAAA,EACCC,yBAAyBH,YAAAA,CAAa,MAAA,CAAQI,mBAAAA,CAAoBF,CAAAA,CAAE,IAAI,CAAC,CAAA,GACzEV,CAAAA,CAA0B,aAC9B,CAAA,CAAE,CAAC,CAAA,CAEH,GAAI,CAACI,CAAAA,CAAiB,CACpB,IAAMS,CAAAA,CAAW,CAEf,OAAA,CAASJ,CAAAA,EAAkB,QAAA,CAAS,CAAC,CAAA,EAAG,OAAA,CAExC,YAAaA,CAAAA,EAAkB,QAAA,CAAS,MAAA,CAAS,CAAA,CAEjD,gBAAA,CAAkBA,CAAAA,EAAkB,QAAA,CAAS,CAAC,EAC9C,eAAA,CAAiBA,CACnB,CAAA,CAAA,CAMEI,CAAAA,CAAS,OAAA,GAAYb,CAAAA,CAA0B,OAAA,EAC/Ca,CAAAA,CAAS,cAAgBb,CAAAA,CAA0B,WAAA,GAInDG,CAAAA,CAAuBU,CAAQ,EAEnC,CACIJ,CAAAA,EAAkB,QAAA,CAAS,SAAW,CAAA,EAAKT,CAAAA,CAA0B,aAAA,EAEvEK,CAAAA,CAAWL,CAAAA,CAA0B,aAAa,EAEtD,CAEF,EAAG,CAACA,CAAAA,EAA2B,aAAA,CAAeF,CAAAA,CAASM,CAAAA,CAAiBD,CAAAA,CAAwBE,CAAU,CAAC,EAGpG,IACT","file":"index.js","sourcesContent":["import {\n formatConnectorName,\n getAdapterFromConnectorType,\n getConnectorTypeFromName,\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 connector connections and updates the Satellite store\n *\n * @remarks\n * This component watches for changes in connected Solana connectors using the Wallet Standard.\n * Currently handles the first active connector only, with multi-connector 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 SolanaConnectorsWatcher() {\n const wallets = useWallets();\n\n const activeConnectionFromStore = useSatelliteConnectStore((store) => store.activeConnection);\n const updateActiveConnection = useSatelliteConnectStore((store) => store.updateActiveConnection);\n const connectionError = useSatelliteConnectStore((store) => store.connectionError);\n const disconnect = useSatelliteConnectStore((store) => store.disconnect);\n\n // Watch for changes in connected connectors\n useEffect(() => {\n if (\n activeConnectionFromStore &&\n getAdapterFromConnectorType(activeConnectionFromStore.connectorType) === OrbitAdapter.SOLANA\n ) {\n const activeConnection = wallets.filter(\n (w) =>\n getConnectorTypeFromName(OrbitAdapter.SOLANA, formatConnectorName(w.name)) ===\n activeConnectionFromStore.connectorType,\n )[0];\n\n if (!connectionError) {\n const newState = {\n // Use the first account's address\n address: activeConnection?.accounts[0]?.address,\n // Set connection status\n isConnected: activeConnection?.accounts.length > 0,\n // Store Wallet Standard specific information\n connectedAccount: activeConnection?.accounts[0],\n connectedWallet: activeConnection,\n };\n\n // Check if anything actually changed to prevent infinite loops\n // We only check address and isConnected because connectedAccount/connectedWallet\n // might be new references on every render, causing infinite loops if checked.\n const hasChanged =\n newState.address !== activeConnectionFromStore.address ||\n newState.isConnected !== activeConnectionFromStore.isConnected;\n\n if (hasChanged) {\n // Update the Satellite store with the active connector information\n updateActiveConnection(newState);\n }\n }\n if (activeConnection?.accounts.length === 0 && activeConnectionFromStore.connectorType) {\n // If the connector is disconnected from the wallet provider, disconnect from Satellite store as well\n disconnect(activeConnectionFromStore.connectorType);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConnectionFromStore?.connectorType, wallets, connectionError, 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.24.dbb32da",
3
+ "version": "1.0.0-fix-adapters-independ-alpha.1.82df95a",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
@@ -66,7 +66,7 @@
66
66
  "viem": "2.x.x",
67
67
  "@wallet-standard/react": "1.x.x",
68
68
  "gill": ">=0.14",
69
- "react": "19.x.x",
69
+ "react": ">=19.2.3",
70
70
  "immer": "11.x.x",
71
71
  "zustand": "5.x.x"
72
72
  },
@@ -114,7 +114,7 @@
114
114
  "devDependencies": {
115
115
  "@types/react": "^19.2.7",
116
116
  "@tuwaio/orbit-core": "^0.2.0",
117
- "@tuwaio/orbit-evm": "^0.2.0",
117
+ "@tuwaio/orbit-evm": "^0.2.2",
118
118
  "@tuwaio/orbit-solana": "^0.2.0",
119
119
  "@wagmi/core": "^3.0.0",
120
120
  "@wallet-standard/react": "^1.0.1",
@@ -126,14 +126,14 @@
126
126
  "@wallet-standard/ui-registry": "^1.0.1",
127
127
  "gill": "^0.14.0",
128
128
  "immer": "^11.0.1",
129
- "react": "^19.2.0",
129
+ "react": "^19.2.3",
130
130
  "tsup": "^8.5.1",
131
- "viem": "^2.40.3",
131
+ "viem": "^2.42.1",
132
132
  "typescript": "^5.9.3",
133
133
  "zustand": "^5.0.9",
134
- "@tuwaio/satellite-core": "^1.0.0-fix-packages-alpha.24.dbb32da",
135
- "@tuwaio/satellite-evm": "^1.0.0-fix-packages-alpha.24.dbb32da",
136
- "@tuwaio/satellite-solana": "^1.0.0-fix-packages-alpha.24.dbb32da"
134
+ "@tuwaio/satellite-core": "^1.0.0-fix-adapters-independ-alpha.1.82df95a",
135
+ "@tuwaio/satellite-evm": "^1.0.0-fix-adapters-independ-alpha.1.82df95a",
136
+ "@tuwaio/satellite-solana": "^1.0.0-fix-adapters-independ-alpha.1.82df95a"
137
137
  },
138
138
  "scripts": {
139
139
  "start": "tsup src/index.ts --watch",
@@ -1,2 +0,0 @@
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),P=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??(c=>console.error("Failed to initialize auto connect:",c)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...n}),[]);return i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsxRuntime.jsx(r.Provider,{value:o,children:e})}exports.a=r;exports.b=P;exports.c=i;exports.d=b;//# sourceMappingURL=chunk-23IZMVDP.cjs.map
2
- //# sourceMappingURL=chunk-23IZMVDP.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/satelliteHook.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":"2JAUO,IAAMA,CAAAA,CAAwBC,mBAAAA,CACnC,IACF,CAAA,CAqBaC,CAAAA,CACXC,CAAAA,EACM,CAEN,IAAMC,CAAAA,CAAQC,gBAAAA,CAAWL,CAAqB,EAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,gBAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECLO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,eAAAA,CAAU,IAAM,CAAA,CACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,CAAA,CAEOF,CAAAA,GAAaG,CAAAA,EAAa,QAAQ,KAAA,CAAM,oCAAA,CAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,QAAA,CAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,EAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,aAAAA,CAAQ,IACbC,yCAAAA,CAAmD,CACxD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAEL,OAAAT,CAAAA,CAAyB,CACvB,sBAAuB,IAAMH,CAAAA,CAAM,QAAA,EAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,cAAAA,CAACnB,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-23IZMVDP.cjs","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connection, Connector } 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, Connection>> | null>(\n null,\n);\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>(\n selector: (state: ISatelliteConnectStore<Connector, Connection>) => T,\n): 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 connector auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected connector) 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 { useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satelliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connection, Connector } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used connector */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages connector connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles connector 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 connector reconnection\n * @param props.adapter - Blockchain adapter(s) for connector 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, Connection>({\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 useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}
@@ -1,2 +0,0 @@
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),P=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??(c=>console.error("Failed to initialize auto connect:",c)))(o);}})();},[]);};function b({children:e,autoConnect:t,...n}){let o=useMemo(()=>createSatelliteConnectStore({...n}),[]);return i({initializeAutoConnect:()=>o.getState().initializeAutoConnect(t??!1)}),jsx(r.Provider,{value:o,children:e})}export{r as a,P as b,i as c,b as d};//# sourceMappingURL=chunk-4RWO4WUN.js.map
2
- //# sourceMappingURL=chunk-4RWO4WUN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/satelliteHook.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":"mMAUO,IAAMA,CAAAA,CAAwBC,aAAAA,CACnC,IACF,CAAA,CAqBaC,CAAAA,CACXC,CAAAA,EACM,CAEN,IAAMC,CAAAA,CAAQC,UAAAA,CAAWL,CAAqB,EAG9C,GAAI,CAACI,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,yEAAyE,CAAA,CAI3F,OAAOE,QAAAA,CAASF,CAAAA,CAAOD,CAAQ,CACjC,ECLO,IAAMI,CAAAA,CAA2B,CAAC,CAAE,qBAAA,CAAAC,CAAAA,CAAuB,OAAA,CAAAC,CAAQ,CAAA,GAAwC,CAChHC,SAAAA,CAAU,IAAM,CAAA,CACqB,SAAY,CAC7C,GAAI,CACF,MAAMF,CAAAA,GACR,CAAA,MAASG,CAAAA,CAAO,CAAA,CAEOF,CAAAA,GAAaG,CAAAA,EAAa,QAAQ,KAAA,CAAM,oCAAA,CAAsCA,CAAC,CAAA,CAAA,EACvFD,CAAc,EAC7B,CACF,CAAA,IAGF,CAAA,CAAG,EAAE,EACP,ECLO,SAASE,CAAAA,CAAyB,CAAE,QAAA,CAAAC,CAAAA,CAAU,WAAA,CAAAC,CAAAA,CAAa,GAAGC,CAAW,EAAkC,CAEhH,IAAMZ,CAAAA,CAAQa,OAAAA,CAAQ,IACbC,2BAAAA,CAAmD,CACxD,GAAGF,CACL,CAAC,CAAA,CAEA,EAAE,CAAA,CAEL,OAAAT,CAAAA,CAAyB,CACvB,sBAAuB,IAAMH,CAAAA,CAAM,QAAA,EAAS,CAAE,qBAAA,CAAsBW,CAAAA,EAAe,CAAA,CAAK,CAC1F,CAAC,CAAA,CAEMI,GAAAA,CAACnB,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOI,CAAAA,CAAQ,QAAA,CAAAU,EAAS,CACjE","file":"chunk-4RWO4WUN.js","sourcesContent":["import { ISatelliteConnectStore } from '@tuwaio/satellite-core';\nimport { createContext, useContext } from 'react';\nimport { StoreApi, useStore } from 'zustand';\n\nimport { Connection, Connector } 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, Connection>> | null>(\n null,\n);\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>(\n selector: (state: ISatelliteConnectStore<Connector, Connection>) => T,\n): 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 connector auto-connection with error handling.\n *\n * @remarks\n * This hook handles the initial connection logic (e.g., checking for a previously\n * connected connector) 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 { useMemo } from 'react';\n\nimport { SatelliteStoreContext } from '../hooks/satelliteHook';\nimport { useInitializeAutoConnect } from '../hooks/useInitializeAutoConnect';\nimport { Connection, Connector } from '../types';\n\n/**\n * Props for SatelliteConnectProvider component\n */\nexport interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {\n /** React child components */\n children: React.ReactNode;\n /** Whether to automatically connect to last used connector */\n autoConnect?: boolean;\n}\n\n/**\n * Provider component that manages connector connections and state\n *\n * @remarks\n * This component creates and provides the Satellite Connect store context to its children.\n * It handles connector 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 connector reconnection\n * @param props.adapter - Blockchain adapter(s) for connector 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, Connection>({\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 useInitializeAutoConnect({\n initializeAutoConnect: () => store.getState().initializeAutoConnect(autoConnect ?? false),\n });\n\n return <SatelliteStoreContext.Provider value={store}>{children}</SatelliteStoreContext.Provider>;\n}\n"]}