@tuwaio/satellite-react 0.4.10 → 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.4.10",
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",
@@ -60,104 +64,45 @@
60
64
  }
61
65
  ],
62
66
  "peerDependencies": {
63
- "@tuwaio/orbit-core": ">=0.2.8",
64
- "@tuwaio/orbit-evm": ">=0.2.11",
65
- "@tuwaio/orbit-solana": ">=0.2.4",
66
- "@tuwaio/satellite-core": ">=0.3.2",
67
- "@tuwaio/satellite-evm": ">=0.3.2",
68
- "@tuwaio/satellite-solana": ">=0.3.2",
69
- "@tuwaio/siwx-core": ">=0.2.2",
70
- "@tuwaio/siwx-react": ">=0.2.3",
71
- "@tuwaio/siwx-evm": ">=0.2.1",
72
- "@tuwaio/siwx-solana": ">=0.2.1",
67
+ "@tuwaio/orbit-core": ">=0.3",
68
+ "@tuwaio/satellite-core": ">=0.5",
69
+ "@tuwaio/satellite-evm": ">=0.5",
70
+ "@tuwaio/satellite-solana": ">=0.5",
73
71
  "@wagmi/core": "3.x.x",
74
- "viem": "2.x.x",
75
72
  "@wallet-standard/react": "1.x.x",
76
- "gill": ">=0.14",
77
73
  "react": ">=19.2.3",
78
- "immer": "11.x.x",
79
74
  "zustand": "5.x.x"
80
75
  },
81
76
  "peerDependenciesMeta": {
82
77
  "@tuwaio/orbit-core": {
83
- "optional": false
84
- },
85
- "@tuwaio/satellite-core": {
86
- "optional": false
87
- },
88
- "react": {
89
- "optional": false
90
- },
91
- "immer": {
92
- "optional": false
93
- },
94
- "zustand": {
95
- "optional": false
96
- },
97
- "@tuwaio/orbit-evm": {
98
78
  "optional": true
99
79
  },
100
80
  "@tuwaio/satellite-evm": {
101
81
  "optional": true
102
82
  },
103
- "@wagmi/core": {
104
- "optional": true
105
- },
106
- "viem": {
107
- "optional": true
108
- },
109
- "@tuwaio/orbit-solana": {
110
- "optional": true
111
- },
112
83
  "@tuwaio/satellite-solana": {
113
84
  "optional": true
114
85
  },
115
- "@tuwaio/siwx-core": {
116
- "optional": true
117
- },
118
- "@tuwaio/siwx-react": {
119
- "optional": true
120
- },
121
- "@tuwaio/siwx-evm": {
122
- "optional": true
123
- },
124
- "@tuwaio/siwx-solana": {
86
+ "@wagmi/core": {
125
87
  "optional": true
126
88
  },
127
89
  "@wallet-standard/react": {
128
90
  "optional": true
129
- },
130
- "gill": {
131
- "optional": true
132
91
  }
133
92
  },
134
93
  "devDependencies": {
135
- "@types/react": "^19.2.18",
136
- "@tuwaio/orbit-core": "^0.2.15",
137
- "@tuwaio/orbit-evm": "^0.2.22",
138
- "@tuwaio/orbit-solana": "^0.2.13",
139
- "@tuwaio/siwx-core": "^0.2.2",
140
- "@tuwaio/siwx-react": "^0.2.3",
141
- "@tuwaio/siwx-evm": "^0.2.1",
142
- "@tuwaio/siwx-solana": "^0.2.1",
143
- "@wagmi/core": "^3.6.4",
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",
99
+ "@wagmi/core": "^3.6.5",
144
100
  "@wallet-standard/react": "^1.0.3",
145
- "@wallet-standard/app": "^1.1.1",
146
- "@wallet-standard/base": "^1.1.1",
147
- "@wallet-standard/features": "^1.1.1",
148
- "@wallet-standard/core": "^1.1.2",
149
- "@wallet-standard/ui": "^1.0.3",
150
- "@wallet-standard/ui-registry": "^1.1.1",
151
- "gill": "^0.14.0",
152
- "immer": "^11.1.16",
153
- "react": "^19.2.8",
101
+ "react": "^19.3.0",
154
102
  "tsup": "^8.5.1",
155
- "viem": "^2.55.16",
103
+ "viem": "^2.56.9",
156
104
  "typescript": "6.0.3",
157
- "zustand": "^5.0.15",
158
- "@tuwaio/satellite-core": "^0.4.3",
159
- "@tuwaio/satellite-evm": "^0.4.4",
160
- "@tuwaio/satellite-solana": "^0.4.9"
105
+ "zustand": "^5.0.15"
161
106
  },
162
107
  "scripts": {
163
108
  "start": "tsup src/index.ts --watch",
@@ -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;