@tuwaio/satellite-react 0.5.0 → 0.6.0

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.
@@ -8,41 +8,52 @@ import { SatelliteSiwxState } from '@tuwaio/satellite-core';
8
8
  */
9
9
  interface SolanaConnectorsWatcherProps {
10
10
  /**
11
- * Optional Sign-In With X (SIWX) session state.
12
- * If provided, the watcher will manage updates and disconnections based on SIWX status.
13
- * Directly compatible with `useSiwxSession()` from `@tuwaio/siwx-react`.
11
+ * Optional Sign-In With X (SIWX) session state, for example the result of `useSiwxSession()` from
12
+ * `@tuwaio/siwx-react`. The watcher runs again when one of its fields changes.
14
13
  */
15
14
  siwx?: SatelliteSiwxState;
16
15
  }
17
16
  /**
18
- * A dynamic version of the SolanaConnectorsWatcher component that avoids static imports.
19
- * This component dynamically imports the dependencies only when they are available.
17
+ * Headless component that keeps the Satellite Connect store in sync with the Solana wallets of the Wallet Standard.
18
+ * Render it once inside `SatelliteConnectProvider`, next to a Solana adapter.
20
19
  *
21
- * @param props - Component props containing optional SIWX session state.
22
- * @returns null - This is a headless component
20
+ * After mount it loads `@tuwaio/satellite-solana` and `@wallet-standard/react` with dynamic imports. Whenever the list
21
+ * of registered wallets (from `useWallets`) changes, it runs `createSolanaConnectionsWatcher`: an account change in
22
+ * the connected wallet updates the active connection and a wallet without accounts is disconnected. With `siwx`, the
23
+ * connection is disconnected when the SIWX sign-in is rejected or fails, or when the account no longer matches the
24
+ * signed-in session. It also runs when a field of `siwx`, the active connector or the connection error changes. If an
25
+ * import fails, a warning is logged and nothing is watched.
26
+ *
27
+ * @param props - The component props. See {@link SolanaConnectorsWatcherProps}.
28
+ * @returns `null`; the component renders nothing.
23
29
  *
24
30
  * @example
25
31
  * ```tsx
26
- * import { useSiwxSession } from '@tuwaio/siwx-react';
27
32
  * import { SolanaConnectorsWatcher } from '@tuwaio/satellite-react/solana';
33
+ * import { useSiwxSession } from '@tuwaio/siwx-react';
28
34
  *
29
- * function WatcherContainer() {
35
+ * export function WatcherContainer() {
30
36
  * const siwxSession = useSiwxSession();
31
37
  * return <SolanaConnectorsWatcher siwx={siwxSession} />;
32
38
  * }
33
39
  * ```
34
- *
35
- * @remarks
36
- * Monitors Wallet Standard account changes. Automatically disconnects wallet state if SIWX
37
- * session validation fails or is rejected.
38
40
  */
39
41
  declare function SolanaConnectorsWatcher(props?: SolanaConnectorsWatcherProps): react.JSX.Element | null;
40
42
 
43
+ /**
44
+ * The Solana watcher component, imported from `@tuwaio/satellite-react/solana`. Importing this entry point also adds
45
+ * `SolanaConnection` and `ConnectorSolana` from `@tuwaio/satellite-solana` to `AllConnections` and `AllConnectors`.
46
+ *
47
+ * @module solana
48
+ */
49
+
41
50
  declare module '@tuwaio/satellite-react' {
42
51
  interface AllConnections {
52
+ /** Solana connections (`SolanaConnection` from `@tuwaio/satellite-solana`), added by `@tuwaio/satellite-react/solana`. */
43
53
  [OrbitAdapter.SOLANA]: SolanaConnection;
44
54
  }
45
55
  interface AllConnectors {
56
+ /** Wallet Standard wallets (`ConnectorSolana` from `@tuwaio/satellite-solana`), added by `@tuwaio/satellite-react/solana`. */
46
57
  [OrbitAdapter.SOLANA]: ConnectorSolana;
47
58
  }
48
59
  }
@@ -1 +1 @@
1
- import {b}from'../chunk-EYVLQZ24.js';import {useState,useEffect}from'react';import {jsx}from'react/jsx-runtime';function y(o={}){let[c,m]=useState(null);return useEffect(()=>{(async()=>{try{let e=!1,l=null,i=null;try{let[r,a]=await Promise.all([import('@tuwaio/satellite-solana'),import('@wallet-standard/react')]);l=r.createSolanaConnectionsWatcher,i=a.useWallets,e=!0;}catch{e=!1;}if(e){let r=()=>{let a=i(),s=b(t=>t.activeConnection),p=b(t=>t.updateActiveConnection),u=b(t=>t.connectionError),S=b(t=>t.disconnect);return useEffect(()=>l({wallets:a,siwx:o.siwx},{activeConnection:s,disconnect:S,connectionError:u,updateActiveConnection:p}),[s?.connectorType,a,o.siwx,u,p,S]),null};m(()=>r);}}catch(e){console.warn("Failed to load Solana watcher:",e);}})();},[o.siwx]),c?jsx(c,{...o}):null}export{y as SolanaConnectorsWatcher};
1
+ import {a as a$1}from'../chunk-FBHCKH6M.js';import {b,a}from'../chunk-4A4PSLAK.js';import {useState,useEffect,useContext}from'react';import {jsx}from'react/jsx-runtime';function w({modules:a$2,siwx:r}){let l=a$2.useWallets(),o=b(t=>t.activeConnection),e=b(t=>t.updateActiveConnection),c=b(t=>t.connectionError),s=b(t=>t.disconnect),i=useContext(a),S=a$1(r),{createWatcher:p}=a$2;return useEffect(()=>p({wallets:l,siwx:S},{disconnect:s,updateActiveConnection:e,getState:()=>i?.getState()??{activeConnection:o,connectionError:c}}),[p,i,l,S,o?.connectorType,c,e,s]),null}function v(a={}){let[r,l]=useState(null);return useEffect(()=>{let o=true;return Promise.all([import('@tuwaio/satellite-solana'),import('@wallet-standard/react')]).then(([e,c])=>{o&&l({createWatcher:e.createSolanaConnectionsWatcher,useWallets:c.useWallets});}).catch(e=>console.warn("Failed to load Solana watcher:",e)),()=>{o=false;}},[]),r?jsx(w,{modules:r,...a}):null}export{v as SolanaConnectorsWatcher};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@tuwaio/satellite-react",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
7
- "description": "Layer 4 (L4) of the TUWA Ecosystem. React state hooks and context providers for orchestrating framework-agnostic Satellite wallet connector instances.",
7
+ "description": "L4 React package of Satellite Connect (TUWA): provider, store hook and EVM and Solana watcher components that keep wallet connections in sync with wallets and SIWX sessions.",
8
8
  "type": "module",
9
9
  "main": "./dist/index.cjs",
10
10
  "module": "./dist/index.js",
@@ -37,12 +37,16 @@
37
37
  "socket.json"
38
38
  ],
39
39
  "keywords": [
40
+ "tuwa",
41
+ "satellite-connect",
42
+ "wallet-connection",
40
43
  "web3",
41
- "connect",
42
- "wallet",
43
- "wagmi",
44
- "viem",
45
- "zustand"
44
+ "react",
45
+ "hooks",
46
+ "evm",
47
+ "solana",
48
+ "siwx",
49
+ "typescript"
46
50
  ],
47
51
  "repository": {
48
52
  "type": "git",
@@ -61,91 +65,42 @@
61
65
  ],
62
66
  "peerDependencies": {
63
67
  "@tuwaio/orbit-core": ">=0.3",
64
- "@tuwaio/orbit-evm": ">=0.3",
65
- "@tuwaio/orbit-solana": ">=0.3",
66
68
  "@tuwaio/satellite-core": ">=0.5",
67
69
  "@tuwaio/satellite-evm": ">=0.5",
68
70
  "@tuwaio/satellite-solana": ">=0.5",
69
- "@tuwaio/siwx-core": ">=0.3",
70
- "@tuwaio/siwx-react": ">=0.3",
71
71
  "@wagmi/core": "3.x.x",
72
- "viem": "2.x.x",
73
72
  "@wallet-standard/react": "1.x.x",
74
- "@solana/kit": ">=8.2",
75
73
  "react": ">=19.2.3",
76
- "immer": "11.x.x",
77
74
  "zustand": "5.x.x"
78
75
  },
79
76
  "peerDependenciesMeta": {
80
77
  "@tuwaio/orbit-core": {
81
- "optional": false
82
- },
83
- "@tuwaio/satellite-core": {
84
- "optional": false
85
- },
86
- "react": {
87
- "optional": false
88
- },
89
- "immer": {
90
- "optional": false
91
- },
92
- "zustand": {
93
- "optional": false
94
- },
95
- "@tuwaio/orbit-evm": {
96
78
  "optional": true
97
79
  },
98
80
  "@tuwaio/satellite-evm": {
99
81
  "optional": true
100
82
  },
101
- "@wagmi/core": {
102
- "optional": true
103
- },
104
- "viem": {
105
- "optional": true
106
- },
107
- "@tuwaio/orbit-solana": {
108
- "optional": true
109
- },
110
83
  "@tuwaio/satellite-solana": {
111
84
  "optional": true
112
85
  },
113
- "@tuwaio/siwx-core": {
114
- "optional": true
115
- },
116
- "@tuwaio/siwx-react": {
86
+ "@wagmi/core": {
117
87
  "optional": true
118
88
  },
119
89
  "@wallet-standard/react": {
120
90
  "optional": true
121
- },
122
- "@solana/kit": {
123
- "optional": true
124
91
  }
125
92
  },
126
93
  "devDependencies": {
127
- "@types/react": "^19.2.18",
128
- "@tuwaio/orbit-core": "^0.3.0",
129
- "@tuwaio/orbit-evm": "^0.3.0",
130
- "@tuwaio/orbit-solana": "^0.3.0",
131
- "@tuwaio/satellite-core": "^0.5.0",
132
- "@tuwaio/satellite-evm": "^0.5.0",
133
- "@tuwaio/satellite-solana": "^0.5.0",
134
- "@tuwaio/siwx-core": "^0.3.0",
135
- "@tuwaio/siwx-react": "^0.3.0",
94
+ "@types/react": "^19.3.0",
95
+ "@tuwaio/orbit-core": "^0.3.1",
96
+ "@tuwaio/satellite-core": "^0.6.0",
97
+ "@tuwaio/satellite-evm": "^0.6.0",
98
+ "@tuwaio/satellite-solana": "^0.6.0",
136
99
  "@wagmi/core": "^3.6.5",
137
100
  "@wallet-standard/react": "^1.0.3",
138
- "@wallet-standard/app": "^1.1.1",
139
- "@wallet-standard/base": "^1.1.1",
140
- "@wallet-standard/features": "^1.1.1",
141
- "@wallet-standard/core": "^1.1.2",
142
- "@wallet-standard/ui": "^1.0.3",
143
- "@wallet-standard/ui-registry": "^1.1.1",
144
- "@solana/kit": "^8.2.0",
145
- "immer": "^11.1.18",
146
- "react": "^19.2.8",
101
+ "react": "^19.3.0",
147
102
  "tsup": "^8.5.1",
148
- "viem": "^2.56.3",
103
+ "viem": "^2.56.9",
149
104
  "typescript": "6.0.3",
150
105
  "zustand": "^5.0.15"
151
106
  },
@@ -1 +0,0 @@
1
- import {a}from'./chunk-EYVLQZ24.js';import {useEffect,useMemo}from'react';import {createSatelliteConnectStore}from'@tuwaio/satellite-core';import {jsx}from'react/jsx-runtime';var l=({initializeAutoConnect:t,onError:n})=>{useEffect(()=>{(async()=>{try{await t();}catch(o){(n??(a=>console.error("Failed to initialize auto connect:",a)))(o);}})();},[]);};function E({children:t,autoConnect:n,...e}){let o=useMemo(()=>createSatelliteConnectStore({...e}),[]);return useEffect(()=>{o.getState().updateParameters(e);},[e,o]),l({initializeAutoConnect:()=>o.getState().initializeAutoConnect(n??!1)}),jsx(a.Provider,{value:o,children:t})}export{l as a,E as b};
@@ -1 +0,0 @@
1
- 'use strict';var chunkG2YC6JBO_cjs=require('./chunk-G2YC6JBO.cjs'),react=require('react'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var c=({initializeAutoConnect:t,onError:n})=>{react.useEffect(()=>{(async()=>{try{await t();}catch(o){(n??(l=>console.error("Failed to initialize auto connect:",l)))(o);}})();},[]);};function y({children:t,autoConnect:n,...e}){let o=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({...e}),[]);return react.useEffect(()=>{o.getState().updateParameters(e);},[e,o]),c({initializeAutoConnect:()=>o.getState().initializeAutoConnect(n??!1)}),jsxRuntime.jsx(chunkG2YC6JBO_cjs.a.Provider,{value:o,children:t})}exports.a=c;exports.b=y;