@tuwaio/satellite-react 0.9.0 → 0.10.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.
- package/README.md +1 -1
- package/dist/evm/index.cjs +1 -1
- package/dist/evm/index.d.cts +5 -2
- package/dist/evm/index.d.ts +5 -2
- package/dist/evm/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +1 -1
- package/dist/solana/index.d.cts +2 -1
- package/dist/solana/index.d.ts +2 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ Connect a wallet with `useSatelliteConnectStore((state) => state.connect)`. Read
|
|
|
93
93
|
|
|
94
94
|
The provider's store saves the last connection and the recently connected wallets to `localStorage`, and removes the impersonated address, through `@tuwaio/orbit-core`. The keys, their content and when they change are listed on the [`@tuwaio/satellite-core`](https://satellite.docs.tuwa.io/packages/satellite-core) page. The store state itself is not persisted: server rendering and the first client render start with no connection, and `initializeAutoConnect` restores it after mount (it waits 300 ms and disconnects the wallets of every adapter first). Read `isAutoConnectFinished` from the store before treating a missing connection as a disconnect.
|
|
95
95
|
|
|
96
|
-
`EVMConnectorsWatcher` hydrates a wagmi config created with `ssr: true` (unless `WagmiProvider` does): wagmi reads its saved state from the `storage` of the config (`localStorage` by default) and the watcher clears the saved wagmi connections.
|
|
96
|
+
`EVMConnectorsWatcher` hydrates a wagmi config created with `ssr: true` (unless `WagmiProvider` does): wagmi reads its saved state from the `storage` of the config (`localStorage` by default) and the watcher clears the saved wagmi connections. To keep nothing of wagmi in the browser, create the config with `storage: createStorage({ storage: noopStorage })` from `@wagmi/core`; with `storage: null` wagmi cannot hydrate the config, and the watcher only adds the installed wallets found through EIP-6963.
|
|
97
97
|
|
|
98
98
|
---
|
|
99
99
|
|
package/dist/evm/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkLSWAATDN_cjs=require('../chunk-LSWAATDN.cjs'),chunkHEG6FP5Z_cjs=require('../chunk-HEG6FP5Z.cjs'),core=require('@wagmi/core'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var d=new WeakSet;function
|
|
1
|
+
'use strict';var chunkLSWAATDN_cjs=require('../chunk-LSWAATDN.cjs'),chunkHEG6FP5Z_cjs=require('../chunk-HEG6FP5Z.cjs'),core=require('@wagmi/core'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var d=new WeakSet;function v(e){let{mipd:r,connectors:i}=e._internal;r&&i.setState(t=>{let o=new Set(t.flatMap(n=>[n.id,...n.rdns===void 0?[]:[n.rdns].flat()])),s=r.getProviders().filter(n=>!o.has(n.info.rdns)).map(n=>i.setup(i.providerDetailToConnector(n)));return [...t,...s]});}function A(e){react.useEffect(()=>{let{ssr:r,store:i}=e._internal;if(!r||d.has(e))return;let{persist:t}=i;if(!t){let c=setTimeout(()=>{d.has(e)||(d.add(e),v(e));},0);return ()=>clearTimeout(c)}if(t.hasHydrated())return;let o=false,s=t.onHydrate(()=>{o=true;}),n=setTimeout(()=>{s(),!(o||t.hasHydrated()||d.has(e))&&(d.add(e),core.hydrate(e,{reconnectOnMount:false}).onMount().catch(c=>console.warn("Failed to hydrate the wagmi config:",c)));},0);return ()=>{clearTimeout(n),s();}},[e]);}function I({createWatcher:e,wagmiConfig:r,siwx:i,siwe:t}){let o=chunkHEG6FP5Z_cjs.b(a=>a.activeConnection),s=chunkHEG6FP5Z_cjs.b(a=>a.disconnect),n=chunkHEG6FP5Z_cjs.b(a=>a.connectionError),c=chunkHEG6FP5Z_cjs.b(a=>a.updateActiveConnection),f=react.useContext(chunkHEG6FP5Z_cjs.a),p=chunkLSWAATDN_cjs.a(i),h=t!==void 0,C=t?.enabled,S=t?.isSignedIn,m=t?.isRejected,E=react.useMemo(()=>h?{enabled:C,isSignedIn:S,isRejected:m}:void 0,[h,C,S,m]);return react.useEffect(()=>e({wagmiConfig:r,siwx:p,siwe:E},{disconnect:s,updateActiveConnection:c,getState:()=>f?.getState()??{activeConnection:o,connectionError:n}}),[e,f,r,p,E,o?.connectorType,n,s,c]),null}function O(e){let[r,i]=react.useState(null);return A(e.wagmiConfig),react.useEffect(()=>{let t=true;return import('@tuwaio/satellite-evm').then(o=>{t&&i(()=>o.createEVMConnectionsWatcher);}).catch(o=>console.warn("Failed to load EVM watcher:",o)),()=>{t=false;}},[]),r?jsxRuntime.jsx(I,{createWatcher:r,...e}):null}exports.EVMConnectorsWatcher=O;
|
package/dist/evm/index.d.cts
CHANGED
|
@@ -48,7 +48,9 @@ interface EVMConnectorsWatcherProps {
|
|
|
48
48
|
* around the app), the watcher calls `hydrate(wagmiConfig, { reconnectOnMount: false }).onMount()` from `@wagmi/core`
|
|
49
49
|
* once per config. It reads the saved wagmi state from the `storage` of the config (`localStorage` by default), adds
|
|
50
50
|
* the EIP-6963 wallets and clears the saved wagmi connections; the last wallet is reconnected by
|
|
51
|
-
* `SatelliteConnectProvider`, not by wagmi. If the hydration fails, a warning is logged.
|
|
51
|
+
* `SatelliteConnectProvider`, not by wagmi. If the hydration fails, a warning is logged. A config created with
|
|
52
|
+
* `storage: null` keeps nothing in the browser and cannot be hydrated by wagmi: the watcher only adds its EIP-6963
|
|
53
|
+
* wallets, at the same moment.
|
|
52
54
|
*
|
|
53
55
|
* @param props - The component props. See {@link EVMConnectorsWatcherProps}.
|
|
54
56
|
* @returns `null`; the component renders nothing.
|
|
@@ -85,4 +87,5 @@ declare module '@tuwaio/satellite-react' {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
export { EVMConnectorsWatcher
|
|
90
|
+
export { EVMConnectorsWatcher };
|
|
91
|
+
export type { EVMConnectorsWatcherProps };
|
package/dist/evm/index.d.ts
CHANGED
|
@@ -48,7 +48,9 @@ interface EVMConnectorsWatcherProps {
|
|
|
48
48
|
* around the app), the watcher calls `hydrate(wagmiConfig, { reconnectOnMount: false }).onMount()` from `@wagmi/core`
|
|
49
49
|
* once per config. It reads the saved wagmi state from the `storage` of the config (`localStorage` by default), adds
|
|
50
50
|
* the EIP-6963 wallets and clears the saved wagmi connections; the last wallet is reconnected by
|
|
51
|
-
* `SatelliteConnectProvider`, not by wagmi. If the hydration fails, a warning is logged.
|
|
51
|
+
* `SatelliteConnectProvider`, not by wagmi. If the hydration fails, a warning is logged. A config created with
|
|
52
|
+
* `storage: null` keeps nothing in the browser and cannot be hydrated by wagmi: the watcher only adds its EIP-6963
|
|
53
|
+
* wallets, at the same moment.
|
|
52
54
|
*
|
|
53
55
|
* @param props - The component props. See {@link EVMConnectorsWatcherProps}.
|
|
54
56
|
* @returns `null`; the component renders nothing.
|
|
@@ -85,4 +87,5 @@ declare module '@tuwaio/satellite-react' {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
export { EVMConnectorsWatcher
|
|
90
|
+
export { EVMConnectorsWatcher };
|
|
91
|
+
export type { EVMConnectorsWatcherProps };
|
package/dist/evm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'../chunk-FBHCKH6M.js';import {b,a}from'../chunk-4A4PSLAK.js';import {hydrate}from'@wagmi/core';import {useState,useEffect,useContext,useMemo}from'react';import {jsx}from'react/jsx-runtime';var d=new WeakSet;function A(e){useEffect(()=>{let{ssr:
|
|
1
|
+
import {a as a$1}from'../chunk-FBHCKH6M.js';import {b,a}from'../chunk-4A4PSLAK.js';import {hydrate}from'@wagmi/core';import {useState,useEffect,useContext,useMemo}from'react';import {jsx}from'react/jsx-runtime';var d=new WeakSet;function A(e){let{mipd:r,connectors:i}=e._internal;r&&i.setState(t=>{let o=new Set(t.flatMap(n=>[n.id,...n.rdns===void 0?[]:[n.rdns].flat()])),s=r.getProviders().filter(n=>!o.has(n.info.rdns)).map(n=>i.setup(i.providerDetailToConnector(n)));return [...t,...s]});}function I(e){useEffect(()=>{let{ssr:r,store:i}=e._internal;if(!r||d.has(e))return;let{persist:t}=i;if(!t){let c=setTimeout(()=>{d.has(e)||(d.add(e),A(e));},0);return ()=>clearTimeout(c)}if(t.hasHydrated())return;let o=false,s=t.onHydrate(()=>{o=true;}),n=setTimeout(()=>{s(),!(o||t.hasHydrated()||d.has(e))&&(d.add(e),hydrate(e,{reconnectOnMount:false}).onMount().catch(c=>console.warn("Failed to hydrate the wagmi config:",c)));},0);return ()=>{clearTimeout(n),s();}},[e]);}function g({createWatcher:e,wagmiConfig:r,siwx:i,siwe:t}){let o=b(a=>a.activeConnection),s=b(a=>a.disconnect),n=b(a=>a.connectionError),c=b(a=>a.updateActiveConnection),f=useContext(a),p=a$1(i),h=t!==void 0,C=t?.enabled,S=t?.isSignedIn,m=t?.isRejected,E=useMemo(()=>h?{enabled:C,isSignedIn:S,isRejected:m}:void 0,[h,C,S,m]);return useEffect(()=>e({wagmiConfig:r,siwx:p,siwe:E},{disconnect:s,updateActiveConnection:c,getState:()=>f?.getState()??{activeConnection:o,connectionError:n}}),[e,f,r,p,E,o?.connectorType,n,s,c]),null}function R(e){let[r,i]=useState(null);return I(e.wagmiConfig),useEffect(()=>{let t=true;return import('@tuwaio/satellite-evm').then(o=>{t&&i(()=>o.createEVMConnectionsWatcher);}).catch(o=>console.warn("Failed to load EVM watcher:",o)),()=>{t=false;}},[]),r?jsx(g,{createWatcher:r,...e}):null}export{R as EVMConnectorsWatcher};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkHEG6FP5Z_cjs=require('./chunk-HEG6FP5Z.cjs'),react=require('react'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var
|
|
1
|
+
'use strict';var chunkHEG6FP5Z_cjs=require('./chunk-HEG6FP5Z.cjs'),react=require('react'),satelliteCore=require('@tuwaio/satellite-core'),jsxRuntime=require('react/jsx-runtime');var s=({initializeAutoConnect:r,onError:i})=>{let o=react.useEffectEvent(async()=>r()),e=react.useEffectEvent(t=>{(i??(C=>console.error("Failed to initialize auto connect:",C)))(t);});react.useEffect(()=>{o().catch(t=>e(t));},[]);};function g({children:r,autoConnect:i,adapter:o,callbackAfterConnected:e,rememberWallet:t}){let n=react.useMemo(()=>satelliteCore.createSatelliteConnectStore({adapter:o,callbackAfterConnected:e,rememberWallet:t}),[]);return react.useEffect(()=>{n.getState().updateParameters({adapter:o,callbackAfterConnected:e});},[n,o,e]),s({initializeAutoConnect:()=>n.getState().initializeAutoConnect(i??false)}),jsxRuntime.jsx(chunkHEG6FP5Z_cjs.a.Provider,{value:n,children:r})}Object.defineProperty(exports,"SatelliteStoreContext",{enumerable:true,get:function(){return chunkHEG6FP5Z_cjs.a}});Object.defineProperty(exports,"useSatelliteConnectStore",{enumerable:true,get:function(){return chunkHEG6FP5Z_cjs.b}});exports.SatelliteConnectProvider=g;exports.useInitializeAutoConnect=s;
|
package/dist/index.d.cts
CHANGED
|
@@ -112,8 +112,8 @@ declare const useInitializeAutoConnect: ({ initializeAutoConnect, onError }: Ini
|
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* Props of {@link SatelliteConnectProvider}: the store parameters (`adapter`, one adapter or an array, and the optional
|
|
115
|
-
* `callbackAfterConnected`, see `SatelliteConnectStoreInitialParameters` from
|
|
116
|
-
* fields below.
|
|
115
|
+
* `callbackAfterConnected` and `rememberWallet`, see `SatelliteConnectStoreInitialParameters` from
|
|
116
|
+
* `@tuwaio/satellite-core`) plus the fields below.
|
|
117
117
|
*/
|
|
118
118
|
interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {
|
|
119
119
|
/** Components that can read the store. */
|
|
@@ -128,11 +128,13 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
|
|
|
128
128
|
* Creates the Satellite Connect store (`createSatelliteConnectStore` from `@tuwaio/satellite-core`) and provides it to
|
|
129
129
|
* its children through {@link SatelliteStoreContext}. Read it with {@link useSatelliteConnectStore}.
|
|
130
130
|
*
|
|
131
|
-
* The store is created once, on the first render
|
|
131
|
+
* The store is created once, on the first render, with `rememberWallet` (read once: change it later with the store's
|
|
132
|
+
* `setRememberWallet`). When `adapter` or `callbackAfterConnected` changes, the new value
|
|
132
133
|
* is passed to the store's `updateParameters`; the state is kept. Define adapters outside the component (or memoize
|
|
133
134
|
* them), so a render does not create new adapter objects. After mount the provider
|
|
134
135
|
* calls the store's `initializeAutoConnect(autoConnect ?? false)` once, which disconnects the wallets of every adapter,
|
|
135
|
-
* cleans the recently connected list
|
|
136
|
+
* cleans the recently connected list and, with `autoConnect`, reconnects the last connected wallet (a wallet saved without
|
|
137
|
+
* `rememberWallet` only until the tab closes).
|
|
136
138
|
* Inside Safe{Wallet} it connects the Safe connector instead, with or without `autoConnect`. The store's
|
|
137
139
|
* `isAutoConnectFinished` turns `true` when this is done.
|
|
138
140
|
* Render the chain watchers (`EVMConnectorsWatcher` from `@tuwaio/satellite-react/evm`, `SolanaConnectorsWatcher`
|
|
@@ -164,6 +166,7 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
|
|
|
164
166
|
* }
|
|
165
167
|
* ```
|
|
166
168
|
*/
|
|
167
|
-
declare function SatelliteConnectProvider({ children, autoConnect, adapter, callbackAfterConnected, }: SatelliteConnectProviderProps): react.JSX.Element;
|
|
169
|
+
declare function SatelliteConnectProvider({ children, autoConnect, adapter, callbackAfterConnected, rememberWallet, }: SatelliteConnectProviderProps): react.JSX.Element;
|
|
168
170
|
|
|
169
|
-
export {
|
|
171
|
+
export { SatelliteConnectProvider, SatelliteStoreContext, useInitializeAutoConnect, useSatelliteConnectStore };
|
|
172
|
+
export type { AllConnections, AllConnectors, Connection, Connector, InitializeAutoConnectProps, SatelliteConnectProviderProps, SatelliteContextType };
|
package/dist/index.d.ts
CHANGED
|
@@ -112,8 +112,8 @@ declare const useInitializeAutoConnect: ({ initializeAutoConnect, onError }: Ini
|
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* Props of {@link SatelliteConnectProvider}: the store parameters (`adapter`, one adapter or an array, and the optional
|
|
115
|
-
* `callbackAfterConnected`, see `SatelliteConnectStoreInitialParameters` from
|
|
116
|
-
* fields below.
|
|
115
|
+
* `callbackAfterConnected` and `rememberWallet`, see `SatelliteConnectStoreInitialParameters` from
|
|
116
|
+
* `@tuwaio/satellite-core`) plus the fields below.
|
|
117
117
|
*/
|
|
118
118
|
interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialParameters<Connector, Connection> {
|
|
119
119
|
/** Components that can read the store. */
|
|
@@ -128,11 +128,13 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
|
|
|
128
128
|
* Creates the Satellite Connect store (`createSatelliteConnectStore` from `@tuwaio/satellite-core`) and provides it to
|
|
129
129
|
* its children through {@link SatelliteStoreContext}. Read it with {@link useSatelliteConnectStore}.
|
|
130
130
|
*
|
|
131
|
-
* The store is created once, on the first render
|
|
131
|
+
* The store is created once, on the first render, with `rememberWallet` (read once: change it later with the store's
|
|
132
|
+
* `setRememberWallet`). When `adapter` or `callbackAfterConnected` changes, the new value
|
|
132
133
|
* is passed to the store's `updateParameters`; the state is kept. Define adapters outside the component (or memoize
|
|
133
134
|
* them), so a render does not create new adapter objects. After mount the provider
|
|
134
135
|
* calls the store's `initializeAutoConnect(autoConnect ?? false)` once, which disconnects the wallets of every adapter,
|
|
135
|
-
* cleans the recently connected list
|
|
136
|
+
* cleans the recently connected list and, with `autoConnect`, reconnects the last connected wallet (a wallet saved without
|
|
137
|
+
* `rememberWallet` only until the tab closes).
|
|
136
138
|
* Inside Safe{Wallet} it connects the Safe connector instead, with or without `autoConnect`. The store's
|
|
137
139
|
* `isAutoConnectFinished` turns `true` when this is done.
|
|
138
140
|
* Render the chain watchers (`EVMConnectorsWatcher` from `@tuwaio/satellite-react/evm`, `SolanaConnectorsWatcher`
|
|
@@ -164,6 +166,7 @@ interface SatelliteConnectProviderProps extends SatelliteConnectStoreInitialPara
|
|
|
164
166
|
* }
|
|
165
167
|
* ```
|
|
166
168
|
*/
|
|
167
|
-
declare function SatelliteConnectProvider({ children, autoConnect, adapter, callbackAfterConnected, }: SatelliteConnectProviderProps): react.JSX.Element;
|
|
169
|
+
declare function SatelliteConnectProvider({ children, autoConnect, adapter, callbackAfterConnected, rememberWallet, }: SatelliteConnectProviderProps): react.JSX.Element;
|
|
168
170
|
|
|
169
|
-
export {
|
|
171
|
+
export { SatelliteConnectProvider, SatelliteStoreContext, useInitializeAutoConnect, useSatelliteConnectStore };
|
|
172
|
+
export type { AllConnections, AllConnectors, Connection, Connector, InitializeAutoConnectProps, SatelliteConnectProviderProps, SatelliteContextType };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-4A4PSLAK.js';export{a as SatelliteStoreContext,b as useSatelliteConnectStore}from'./chunk-4A4PSLAK.js';import {useEffectEvent,useEffect,useMemo}from'react';import {createSatelliteConnectStore}from'@tuwaio/satellite-core';import {jsx}from'react/jsx-runtime';var
|
|
1
|
+
import {a}from'./chunk-4A4PSLAK.js';export{a as SatelliteStoreContext,b as useSatelliteConnectStore}from'./chunk-4A4PSLAK.js';import {useEffectEvent,useEffect,useMemo}from'react';import {createSatelliteConnectStore}from'@tuwaio/satellite-core';import {jsx}from'react/jsx-runtime';var C=({initializeAutoConnect:r,onError:i})=>{let o=useEffectEvent(async()=>r()),e=useEffectEvent(t=>{(i??(p=>console.error("Failed to initialize auto connect:",p)))(t);});useEffect(()=>{o().catch(t=>e(t));},[]);};function h({children:r,autoConnect:i,adapter:o,callbackAfterConnected:e,rememberWallet:t}){let n=useMemo(()=>createSatelliteConnectStore({adapter:o,callbackAfterConnected:e,rememberWallet:t}),[]);return useEffect(()=>{n.getState().updateParameters({adapter:o,callbackAfterConnected:e});},[n,o,e]),C({initializeAutoConnect:()=>n.getState().initializeAutoConnect(i??false)}),jsx(a.Provider,{value:n,children:r})}export{h as SatelliteConnectProvider,C as useInitializeAutoConnect};
|
package/dist/solana/index.d.cts
CHANGED
package/dist/solana/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuwaio/satellite-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Oleksandr Tkach",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -91,17 +91,17 @@
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@tuwaio/orbit-core": "^0.
|
|
95
|
-
"@tuwaio/satellite-core": "^0.
|
|
96
|
-
"@tuwaio/satellite-evm": "^0.
|
|
97
|
-
"@tuwaio/satellite-solana": "^0.
|
|
94
|
+
"@tuwaio/orbit-core": "^0.6.0",
|
|
95
|
+
"@tuwaio/satellite-core": "^0.10.0",
|
|
96
|
+
"@tuwaio/satellite-evm": "^0.10.0",
|
|
97
|
+
"@tuwaio/satellite-solana": "^0.10.0",
|
|
98
98
|
"@types/react": "^19.3.0",
|
|
99
99
|
"@wagmi/core": "^3.6.5",
|
|
100
100
|
"@wallet-standard/react": "^1.0.3",
|
|
101
|
-
"react": "^19.3.
|
|
102
|
-
"tsup": "^
|
|
101
|
+
"react": "^19.3.1",
|
|
102
|
+
"tsup": "^9.0.0",
|
|
103
103
|
"typescript": "6.0.3",
|
|
104
|
-
"viem": "^2.57.
|
|
104
|
+
"viem": "^2.57.7",
|
|
105
105
|
"zustand": "^5.0.15"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|