@vue-solana/vue 2.0.0 → 2.2.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 +210 -21
- package/dist/index.cjs +60 -20
- package/dist/index.d.cts +26 -5
- package/dist/index.d.mts +26 -5
- package/dist/index.d.ts +26 -5
- package/dist/index.mjs +38 -19
- package/dist/shared/vue.5euWd6-V.mjs +59 -0
- package/dist/shared/vue.9TPxZPMf.cjs +59 -0
- package/dist/shared/vue.B4-LEdSE.cjs +102 -0
- package/dist/shared/{vue.CP1DPDX9.cjs → vue.B6ainw2G.cjs} +1 -1
- package/dist/shared/vue.B8LptjZP.mjs +32 -0
- package/dist/shared/vue.B8VvC8d2.mjs +101 -0
- package/dist/shared/{vue.DP7qY8Rk.mjs → vue.BD6Gm1nl.mjs} +2 -2
- package/dist/shared/vue.BDNOyiGZ.mjs +109 -0
- package/dist/shared/{vue.BAlo-tIh.cjs → vue.BGxz4dru.cjs} +5 -1
- package/dist/shared/{vue.stUBDBI9.mjs → vue.BINkrA8h.mjs} +2 -2
- package/dist/shared/{vue.k9Q6aN-0.cjs → vue.BIxphCAq.cjs} +1 -1
- package/dist/shared/{vue.yQcL1yMv.mjs → vue.BOpgWr43.mjs} +2 -2
- package/dist/shared/{vue.dPRo2X5y.mjs → vue.BQRpjwKl.mjs} +2 -2
- package/dist/shared/vue.BSfiHqwj.mjs +34 -0
- package/dist/shared/{vue.CZwftA0L.cjs → vue.BVaMoz9y.cjs} +1 -1
- package/dist/shared/vue.BY0qpgYr.cjs +35 -0
- package/dist/shared/vue.Bk5xjlUx.cjs +61 -0
- package/dist/shared/{vue.3VLZmw05.mjs → vue.BsGwt78R.mjs} +1 -1
- package/dist/shared/{vue.B_LRH8SM.cjs → vue.Bwd1sGAM.cjs} +2 -2
- package/dist/shared/vue.ByxbBC3y.mjs +57 -0
- package/dist/shared/{vue.BbMPRDeO.mjs → vue.C13umiQi.mjs} +2 -2
- package/dist/shared/vue.C5FVoEZT.mjs +99 -0
- package/dist/shared/vue.CATOh_9G.mjs +42 -0
- package/dist/shared/{vue.XQFqlMId.cjs → vue.CIs8QhCw.cjs} +2 -2
- package/dist/shared/vue.CMohL_Cz.mjs +58 -0
- package/dist/shared/{vue.CnUlZSe8.mjs → vue.CQh3AUE8.mjs} +2 -5
- package/dist/shared/vue.CTqPbvz3.cjs +36 -0
- package/dist/shared/{vue.CSJSK0Nq.cjs → vue.CWZSMVnB.cjs} +3 -3
- package/dist/shared/{vue.DL-yMCNc.mjs → vue.CXB4NEMA.mjs} +2 -2
- package/dist/shared/{vue.D7xFeC2m.mjs → vue.C_4qJDiF.mjs} +1 -1
- package/dist/shared/vue.CbJFnho-.mjs +171 -0
- package/dist/shared/vue.CoaIWGPT.cjs +38 -0
- package/dist/shared/{vue.ChujsB0B.mjs → vue.CpkwC8Th.mjs} +1 -1
- package/dist/shared/vue.CrkK_T15.cjs +86 -0
- package/dist/shared/{vue.BMencBpI.cjs → vue.D-qi8PSL.cjs} +2 -2
- package/dist/shared/{vue.PJjEncbP.mjs → vue.D218Ow7t.mjs} +6 -2
- package/dist/shared/{vue.B2sFJ1xI.mjs → vue.D3Y0PWbF.mjs} +1 -1
- package/dist/shared/vue.D5U1yLG3.mjs +83 -0
- package/dist/shared/{vue.CXHYdyKZ.cjs → vue.DAg5wC1G.cjs} +2 -2
- package/dist/shared/vue.DDbVk0Zh.cjs +180 -0
- package/dist/shared/{vue.BaR1VPhl.cjs → vue.DE3emjSF.cjs} +2 -6
- package/dist/shared/vue.DEHxNvUX.cjs +7 -0
- package/dist/shared/vue.DFaMJLAQ.cjs +60 -0
- package/dist/shared/{vue.DgCmU1RR.cjs → vue.DKyQ7J67.cjs} +1 -1
- package/dist/shared/vue.DXQVIRZA.mjs +174 -0
- package/dist/shared/vue.DYk0Xfr3.mjs +36 -0
- package/dist/shared/vue.D_P5SqqD.mjs +5 -0
- package/dist/shared/{vue.C7yR7Cs0.cjs → vue.Di7yjJ-R.cjs} +2 -2
- package/dist/shared/vue.DxM45azl.cjs +173 -0
- package/dist/shared/{vue.WugzPOca.mjs → vue.Dyi1OCI1.mjs} +3 -3
- package/dist/shared/{vue.CEn2purG.cjs → vue.E_npPFoV.cjs} +2 -2
- package/dist/shared/{vue.__r7YYZE.cjs → vue.FiMmnMHr.cjs} +1 -1
- package/dist/shared/{vue.CZO8TwJP.mjs → vue.JUWqu6kD.mjs} +1 -1
- package/dist/shared/{vue.BaFrF2PF.mjs → vue.Mxc8w6Qk.mjs} +1 -1
- package/dist/shared/{vue.C32ozdA1.cjs → vue.Sbbm9JSu.cjs} +1 -1
- package/dist/shared/vue.ZuUCEEab.cjs +103 -0
- package/dist/shared/vue.g8fnm_ca.cjs +45 -0
- package/dist/shared/vue.l3UCdN7z.cjs +111 -0
- package/dist/swr.cjs +136 -0
- package/dist/swr.d.cts +41 -0
- package/dist/swr.d.mts +41 -0
- package/dist/swr.d.ts +41 -0
- package/dist/swr.mjs +131 -0
- package/dist/useAccountInfo.cjs +5 -4
- package/dist/useAccountInfo.mjs +5 -4
- package/dist/useAction.cjs +9 -0
- package/dist/useAction.d.cts +45 -0
- package/dist/useAction.d.mts +45 -0
- package/dist/useAction.d.ts +45 -0
- package/dist/useAction.mjs +3 -0
- package/dist/useAirdrop.cjs +14 -0
- package/dist/useAirdrop.d.cts +25 -0
- package/dist/useAirdrop.d.mts +25 -0
- package/dist/useAirdrop.d.ts +25 -0
- package/dist/useAirdrop.mjs +8 -0
- package/dist/useBalance.cjs +5 -4
- package/dist/useBalance.mjs +5 -4
- package/dist/useClientCapability.cjs +12 -0
- package/dist/useClientCapability.d.cts +39 -0
- package/dist/useClientCapability.d.mts +39 -0
- package/dist/useClientCapability.d.ts +39 -0
- package/dist/useClientCapability.mjs +5 -0
- package/dist/useConnection.cjs +4 -3
- package/dist/useConnection.d.cts +3 -2
- package/dist/useConnection.d.mts +3 -2
- package/dist/useConnection.d.ts +3 -2
- package/dist/useConnection.mjs +4 -3
- package/dist/useIdentity.cjs +12 -0
- package/dist/useIdentity.d.cts +3 -0
- package/dist/useIdentity.d.mts +3 -0
- package/dist/useIdentity.d.ts +3 -0
- package/dist/useIdentity.mjs +6 -0
- package/dist/usePayer.cjs +13 -0
- package/dist/usePayer.d.cts +18 -0
- package/dist/usePayer.d.mts +18 -0
- package/dist/usePayer.d.ts +18 -0
- package/dist/usePayer.mjs +6 -0
- package/dist/usePlanTransaction.cjs +14 -0
- package/dist/usePlanTransaction.d.cts +37 -0
- package/dist/usePlanTransaction.d.mts +37 -0
- package/dist/usePlanTransaction.d.ts +37 -0
- package/dist/usePlanTransaction.mjs +7 -0
- package/dist/usePlanTransactions.cjs +13 -0
- package/dist/usePlanTransactions.d.cts +4 -0
- package/dist/usePlanTransactions.d.mts +4 -0
- package/dist/usePlanTransactions.d.ts +4 -0
- package/dist/usePlanTransactions.mjs +7 -0
- package/dist/useProgramAccounts.cjs +5 -4
- package/dist/useProgramAccounts.mjs +5 -4
- package/dist/useRequest.cjs +11 -0
- package/dist/useRequest.d.cts +73 -0
- package/dist/useRequest.d.mts +73 -0
- package/dist/useRequest.d.ts +73 -0
- package/dist/useRequest.mjs +5 -0
- package/dist/useRpc.cjs +3 -2
- package/dist/useRpc.d.cts +3 -2
- package/dist/useRpc.d.mts +3 -2
- package/dist/useRpc.d.ts +3 -2
- package/dist/useRpc.mjs +3 -2
- package/dist/useSelectedWalletAccount.cjs +13 -0
- package/dist/useSelectedWalletAccount.d.cts +117 -0
- package/dist/useSelectedWalletAccount.d.mts +117 -0
- package/dist/useSelectedWalletAccount.d.ts +117 -0
- package/dist/useSelectedWalletAccount.mjs +3 -0
- package/dist/useSignAndSendTransaction.cjs +7 -6
- package/dist/useSignAndSendTransaction.mjs +7 -6
- package/dist/useSignAndSendTransactions.cjs +15 -0
- package/dist/useSignAndSendTransactions.d.cts +35 -0
- package/dist/useSignAndSendTransactions.d.mts +35 -0
- package/dist/useSignAndSendTransactions.d.ts +35 -0
- package/dist/useSignAndSendTransactions.mjs +8 -0
- package/dist/useSignIn.cjs +13 -0
- package/dist/useSignIn.d.cts +23 -0
- package/dist/useSignIn.d.mts +23 -0
- package/dist/useSignIn.d.ts +23 -0
- package/dist/useSignIn.mjs +7 -0
- package/dist/useSignMessage.cjs +4 -3
- package/dist/useSignMessage.mjs +4 -3
- package/dist/useSignTransactions.cjs +13 -0
- package/dist/useSignTransactions.d.cts +24 -0
- package/dist/useSignTransactions.d.mts +24 -0
- package/dist/useSignTransactions.d.ts +24 -0
- package/dist/useSignTransactions.mjs +7 -0
- package/dist/useSignatureStatus.cjs +5 -4
- package/dist/useSignatureStatus.mjs +5 -4
- package/dist/useSolana.cjs +2 -1
- package/dist/useSolana.mjs +2 -1
- package/dist/useSolanaClient.cjs +3 -2
- package/dist/useSolanaClient.d.cts +3 -2
- package/dist/useSolanaClient.d.mts +3 -2
- package/dist/useSolanaClient.d.ts +3 -2
- package/dist/useSolanaClient.mjs +3 -2
- package/dist/useSubscription.cjs +9 -0
- package/dist/useSubscription.d.cts +70 -0
- package/dist/useSubscription.d.mts +70 -0
- package/dist/useSubscription.d.ts +70 -0
- package/dist/useSubscription.mjs +3 -0
- package/dist/useTokenAccounts.cjs +5 -4
- package/dist/useTokenAccounts.mjs +5 -4
- package/dist/useTokenBalance.cjs +5 -4
- package/dist/useTokenBalance.mjs +5 -4
- package/dist/useTrackedData.cjs +10 -0
- package/dist/useTrackedData.d.cts +98 -0
- package/dist/useTrackedData.d.mts +98 -0
- package/dist/useTrackedData.d.ts +98 -0
- package/dist/useTrackedData.mjs +4 -0
- package/dist/useTransaction.cjs +2 -1
- package/dist/useTransaction.d.cts +12 -1
- package/dist/useTransaction.d.mts +12 -1
- package/dist/useTransaction.d.ts +12 -1
- package/dist/useTransaction.mjs +2 -1
- package/dist/useTransactionConfirmation.cjs +5 -4
- package/dist/useTransactionConfirmation.mjs +5 -4
- package/dist/useWallet.cjs +3 -2
- package/dist/useWallet.mjs +3 -2
- package/dist/useWallets.cjs +3 -2
- package/dist/useWallets.mjs +3 -2
- package/package.json +78 -3
- package/dist/shared/vue.C4d2JA8U.mjs +0 -44
- package/dist/shared/vue.CE5i8KZZ.cjs +0 -46
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as _solana_kit from '@solana/kit';
|
|
2
2
|
|
|
3
3
|
declare function useSolanaClient(): {
|
|
4
|
-
client: _solana_kit.Client<
|
|
4
|
+
client: _solana_kit.Client<{
|
|
5
5
|
rpc: _solana_kit.Rpc<_solana_kit.RequestAirdropApi & _solana_kit.GetAccountInfoApi & _solana_kit.GetAgGenesisCertApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetTransactionsForAddressApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi>;
|
|
6
6
|
rpcSubscriptions: _solana_kit.RpcSubscriptions<_solana_kit.SolanaRpcSubscriptionsApi>;
|
|
7
|
-
|
|
7
|
+
airdrop: (address: _solana_kit.Address, amount: _solana_kit.Lamports, abortSignal?: AbortSignal) => Promise<_solana_kit.Signature | undefined>;
|
|
8
|
+
}>;
|
|
8
9
|
rpc: _solana_kit.Rpc<_solana_kit.RequestAirdropApi & _solana_kit.GetAccountInfoApi & _solana_kit.GetAgGenesisCertApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetTransactionsForAddressApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi>;
|
|
9
10
|
};
|
|
10
11
|
|
package/dist/useSolanaClient.mjs
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { ReactiveStreamStore } from '@vue-solana/core/kit';
|
|
3
|
+
import { ComputedRef, Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
type UseSubscriptionStatus = "loading" | "loaded" | "error" | "disabled";
|
|
6
|
+
/**
|
|
7
|
+
* A subscription source accepted by `useSubscription`:
|
|
8
|
+
*
|
|
9
|
+
* - a Kit reactive stream source such as `PendingRpcSubscriptionsRequest`
|
|
10
|
+
* (for example `rpcSubscriptions.accountNotifications(address)`),
|
|
11
|
+
* - a `ref`/`computed` of a source or `null` to disable, or
|
|
12
|
+
* - `null` to disable outright.
|
|
13
|
+
*/
|
|
14
|
+
type UseSubscriptionSource<TResult> = {
|
|
15
|
+
reactiveStore: () => ReactiveStreamStore<TResult>;
|
|
16
|
+
} | Ref<{
|
|
17
|
+
reactiveStore: () => ReactiveStreamStore<TResult>;
|
|
18
|
+
} | null | undefined> | null | undefined;
|
|
19
|
+
interface UseSubscriptionOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Returns a caller-provided `AbortSignal` per connection (for example
|
|
22
|
+
* `AbortSignal.timeout(30_000)`), composed with the per-connection signal by
|
|
23
|
+
* the underlying store. Aborting it fails the connection with the abort
|
|
24
|
+
* reason without touching other state. Read fresh from the latest render,
|
|
25
|
+
* so inline closures need no callback wrapping.
|
|
26
|
+
*/
|
|
27
|
+
getAbortSignal?: (connection: number) => AbortSignal | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Called when the subscription transitions into `error`.
|
|
30
|
+
*/
|
|
31
|
+
onError?: (error: unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
/** Per-connection abort overrides for `reconnect()`. */
|
|
34
|
+
type UseSubscriptionReconnectOptions = {
|
|
35
|
+
/**
|
|
36
|
+
* Applies only this signal to the connection, bypassing `getAbortSignal`.
|
|
37
|
+
* Passing `undefined` (or an empty options object) applies no caller signal
|
|
38
|
+
* for that connection; call `reconnect()` with no argument to keep the
|
|
39
|
+
* `getAbortSignal` factory behavior.
|
|
40
|
+
*/
|
|
41
|
+
abortSignal?: AbortSignal;
|
|
42
|
+
};
|
|
43
|
+
interface UseSubscriptionReturn<TResult> {
|
|
44
|
+
data: ComputedRef<TResult | undefined>;
|
|
45
|
+
error: ComputedRef<SolanaError | null>;
|
|
46
|
+
/** Re-opens the connection. `reconnect({ abortSignal })` overrides `getAbortSignal`. */
|
|
47
|
+
reconnect: (options?: UseSubscriptionReconnectOptions) => void;
|
|
48
|
+
status: ComputedRef<UseSubscriptionStatus>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Live data from RPC subscriptions and other reactive stream sources.
|
|
52
|
+
*
|
|
53
|
+
* Accepts a Kit reactive stream source (duck-typed on `reactiveStore()`),
|
|
54
|
+
* bridges its `{ subscribe, getState }` contract into Vue reactive state, and
|
|
55
|
+
* tears the connection down when the component unmounts.
|
|
56
|
+
*
|
|
57
|
+
* Status set: `loading` | `loaded` | `error` | `disabled`.
|
|
58
|
+
*
|
|
59
|
+
* - A `null` source disables the subscription and clears state.
|
|
60
|
+
* - `reconnect()` re-opens the connection with stale-while-revalidate: the
|
|
61
|
+
* last known `data` stays visible until fresh data arrives.
|
|
62
|
+
* - Errors preserve the last known `data`; only the first error per connection
|
|
63
|
+
* window is captured (matching the underlying store's contract).
|
|
64
|
+
* - Changing a ref/computed source tears down the previous subscription and
|
|
65
|
+
* connects to the new one.
|
|
66
|
+
*/
|
|
67
|
+
declare function useSubscription<TResult>(source: UseSubscriptionSource<TResult>, options?: UseSubscriptionOptions): UseSubscriptionReturn<TResult>;
|
|
68
|
+
|
|
69
|
+
export { useSubscription };
|
|
70
|
+
export type { UseSubscriptionOptions, UseSubscriptionReconnectOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { ReactiveStreamStore } from '@vue-solana/core/kit';
|
|
3
|
+
import { ComputedRef, Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
type UseSubscriptionStatus = "loading" | "loaded" | "error" | "disabled";
|
|
6
|
+
/**
|
|
7
|
+
* A subscription source accepted by `useSubscription`:
|
|
8
|
+
*
|
|
9
|
+
* - a Kit reactive stream source such as `PendingRpcSubscriptionsRequest`
|
|
10
|
+
* (for example `rpcSubscriptions.accountNotifications(address)`),
|
|
11
|
+
* - a `ref`/`computed` of a source or `null` to disable, or
|
|
12
|
+
* - `null` to disable outright.
|
|
13
|
+
*/
|
|
14
|
+
type UseSubscriptionSource<TResult> = {
|
|
15
|
+
reactiveStore: () => ReactiveStreamStore<TResult>;
|
|
16
|
+
} | Ref<{
|
|
17
|
+
reactiveStore: () => ReactiveStreamStore<TResult>;
|
|
18
|
+
} | null | undefined> | null | undefined;
|
|
19
|
+
interface UseSubscriptionOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Returns a caller-provided `AbortSignal` per connection (for example
|
|
22
|
+
* `AbortSignal.timeout(30_000)`), composed with the per-connection signal by
|
|
23
|
+
* the underlying store. Aborting it fails the connection with the abort
|
|
24
|
+
* reason without touching other state. Read fresh from the latest render,
|
|
25
|
+
* so inline closures need no callback wrapping.
|
|
26
|
+
*/
|
|
27
|
+
getAbortSignal?: (connection: number) => AbortSignal | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Called when the subscription transitions into `error`.
|
|
30
|
+
*/
|
|
31
|
+
onError?: (error: unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
/** Per-connection abort overrides for `reconnect()`. */
|
|
34
|
+
type UseSubscriptionReconnectOptions = {
|
|
35
|
+
/**
|
|
36
|
+
* Applies only this signal to the connection, bypassing `getAbortSignal`.
|
|
37
|
+
* Passing `undefined` (or an empty options object) applies no caller signal
|
|
38
|
+
* for that connection; call `reconnect()` with no argument to keep the
|
|
39
|
+
* `getAbortSignal` factory behavior.
|
|
40
|
+
*/
|
|
41
|
+
abortSignal?: AbortSignal;
|
|
42
|
+
};
|
|
43
|
+
interface UseSubscriptionReturn<TResult> {
|
|
44
|
+
data: ComputedRef<TResult | undefined>;
|
|
45
|
+
error: ComputedRef<SolanaError | null>;
|
|
46
|
+
/** Re-opens the connection. `reconnect({ abortSignal })` overrides `getAbortSignal`. */
|
|
47
|
+
reconnect: (options?: UseSubscriptionReconnectOptions) => void;
|
|
48
|
+
status: ComputedRef<UseSubscriptionStatus>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Live data from RPC subscriptions and other reactive stream sources.
|
|
52
|
+
*
|
|
53
|
+
* Accepts a Kit reactive stream source (duck-typed on `reactiveStore()`),
|
|
54
|
+
* bridges its `{ subscribe, getState }` contract into Vue reactive state, and
|
|
55
|
+
* tears the connection down when the component unmounts.
|
|
56
|
+
*
|
|
57
|
+
* Status set: `loading` | `loaded` | `error` | `disabled`.
|
|
58
|
+
*
|
|
59
|
+
* - A `null` source disables the subscription and clears state.
|
|
60
|
+
* - `reconnect()` re-opens the connection with stale-while-revalidate: the
|
|
61
|
+
* last known `data` stays visible until fresh data arrives.
|
|
62
|
+
* - Errors preserve the last known `data`; only the first error per connection
|
|
63
|
+
* window is captured (matching the underlying store's contract).
|
|
64
|
+
* - Changing a ref/computed source tears down the previous subscription and
|
|
65
|
+
* connects to the new one.
|
|
66
|
+
*/
|
|
67
|
+
declare function useSubscription<TResult>(source: UseSubscriptionSource<TResult>, options?: UseSubscriptionOptions): UseSubscriptionReturn<TResult>;
|
|
68
|
+
|
|
69
|
+
export { useSubscription };
|
|
70
|
+
export type { UseSubscriptionOptions, UseSubscriptionReconnectOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { ReactiveStreamStore } from '@vue-solana/core/kit';
|
|
3
|
+
import { ComputedRef, Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
type UseSubscriptionStatus = "loading" | "loaded" | "error" | "disabled";
|
|
6
|
+
/**
|
|
7
|
+
* A subscription source accepted by `useSubscription`:
|
|
8
|
+
*
|
|
9
|
+
* - a Kit reactive stream source such as `PendingRpcSubscriptionsRequest`
|
|
10
|
+
* (for example `rpcSubscriptions.accountNotifications(address)`),
|
|
11
|
+
* - a `ref`/`computed` of a source or `null` to disable, or
|
|
12
|
+
* - `null` to disable outright.
|
|
13
|
+
*/
|
|
14
|
+
type UseSubscriptionSource<TResult> = {
|
|
15
|
+
reactiveStore: () => ReactiveStreamStore<TResult>;
|
|
16
|
+
} | Ref<{
|
|
17
|
+
reactiveStore: () => ReactiveStreamStore<TResult>;
|
|
18
|
+
} | null | undefined> | null | undefined;
|
|
19
|
+
interface UseSubscriptionOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Returns a caller-provided `AbortSignal` per connection (for example
|
|
22
|
+
* `AbortSignal.timeout(30_000)`), composed with the per-connection signal by
|
|
23
|
+
* the underlying store. Aborting it fails the connection with the abort
|
|
24
|
+
* reason without touching other state. Read fresh from the latest render,
|
|
25
|
+
* so inline closures need no callback wrapping.
|
|
26
|
+
*/
|
|
27
|
+
getAbortSignal?: (connection: number) => AbortSignal | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Called when the subscription transitions into `error`.
|
|
30
|
+
*/
|
|
31
|
+
onError?: (error: unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
/** Per-connection abort overrides for `reconnect()`. */
|
|
34
|
+
type UseSubscriptionReconnectOptions = {
|
|
35
|
+
/**
|
|
36
|
+
* Applies only this signal to the connection, bypassing `getAbortSignal`.
|
|
37
|
+
* Passing `undefined` (or an empty options object) applies no caller signal
|
|
38
|
+
* for that connection; call `reconnect()` with no argument to keep the
|
|
39
|
+
* `getAbortSignal` factory behavior.
|
|
40
|
+
*/
|
|
41
|
+
abortSignal?: AbortSignal;
|
|
42
|
+
};
|
|
43
|
+
interface UseSubscriptionReturn<TResult> {
|
|
44
|
+
data: ComputedRef<TResult | undefined>;
|
|
45
|
+
error: ComputedRef<SolanaError | null>;
|
|
46
|
+
/** Re-opens the connection. `reconnect({ abortSignal })` overrides `getAbortSignal`. */
|
|
47
|
+
reconnect: (options?: UseSubscriptionReconnectOptions) => void;
|
|
48
|
+
status: ComputedRef<UseSubscriptionStatus>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Live data from RPC subscriptions and other reactive stream sources.
|
|
52
|
+
*
|
|
53
|
+
* Accepts a Kit reactive stream source (duck-typed on `reactiveStore()`),
|
|
54
|
+
* bridges its `{ subscribe, getState }` contract into Vue reactive state, and
|
|
55
|
+
* tears the connection down when the component unmounts.
|
|
56
|
+
*
|
|
57
|
+
* Status set: `loading` | `loaded` | `error` | `disabled`.
|
|
58
|
+
*
|
|
59
|
+
* - A `null` source disables the subscription and clears state.
|
|
60
|
+
* - `reconnect()` re-opens the connection with stale-while-revalidate: the
|
|
61
|
+
* last known `data` stays visible until fresh data arrives.
|
|
62
|
+
* - Errors preserve the last known `data`; only the first error per connection
|
|
63
|
+
* window is captured (matching the underlying store's contract).
|
|
64
|
+
* - Changing a ref/computed source tears down the previous subscription and
|
|
65
|
+
* connects to the new one.
|
|
66
|
+
*/
|
|
67
|
+
declare function useSubscription<TResult>(source: UseSubscriptionSource<TResult>, options?: UseSubscriptionOptions): UseSubscriptionReturn<TResult>;
|
|
68
|
+
|
|
69
|
+
export { useSubscription };
|
|
70
|
+
export type { UseSubscriptionOptions, UseSubscriptionReconnectOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useTokenAccounts = require('./shared/vue.
|
|
3
|
+
const useTokenAccounts = require('./shared/vue.Bwd1sGAM.cjs');
|
|
4
4
|
require('@vue-solana/core/token-accounts');
|
|
5
5
|
require('@vue-solana/core/errors');
|
|
6
6
|
require('@vue-solana/core/address');
|
|
7
7
|
require('vue');
|
|
8
|
-
require('./shared/vue.
|
|
9
|
-
require('./shared/vue.
|
|
10
|
-
require('./shared/vue.
|
|
8
|
+
require('./shared/vue.BVaMoz9y.cjs');
|
|
9
|
+
require('./shared/vue.BIxphCAq.cjs');
|
|
10
|
+
require('./shared/vue.DE3emjSF.cjs');
|
|
11
|
+
require('./shared/vue.DEHxNvUX.cjs');
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { u as useTokenAccounts } from './shared/vue.
|
|
1
|
+
export { u as useTokenAccounts } from './shared/vue.BOpgWr43.mjs';
|
|
2
2
|
import '@vue-solana/core/token-accounts';
|
|
3
3
|
import '@vue-solana/core/errors';
|
|
4
4
|
import '@vue-solana/core/address';
|
|
5
5
|
import 'vue';
|
|
6
|
-
import './shared/vue.
|
|
7
|
-
import './shared/vue.
|
|
8
|
-
import './shared/vue.
|
|
6
|
+
import './shared/vue.CpkwC8Th.mjs';
|
|
7
|
+
import './shared/vue.Mxc8w6Qk.mjs';
|
|
8
|
+
import './shared/vue.CQh3AUE8.mjs';
|
|
9
|
+
import './shared/vue.D_P5SqqD.mjs';
|
package/dist/useTokenBalance.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useTokenBalance = require('./shared/vue.
|
|
3
|
+
const useTokenBalance = require('./shared/vue.DAg5wC1G.cjs');
|
|
4
4
|
require('@vue-solana/core/token-accounts');
|
|
5
5
|
require('@vue-solana/core/errors');
|
|
6
6
|
require('@vue-solana/core/address');
|
|
7
7
|
require('vue');
|
|
8
|
-
require('./shared/vue.
|
|
9
|
-
require('./shared/vue.
|
|
10
|
-
require('./shared/vue.
|
|
8
|
+
require('./shared/vue.BVaMoz9y.cjs');
|
|
9
|
+
require('./shared/vue.BIxphCAq.cjs');
|
|
10
|
+
require('./shared/vue.DE3emjSF.cjs');
|
|
11
|
+
require('./shared/vue.DEHxNvUX.cjs');
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
package/dist/useTokenBalance.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { u as useTokenBalance } from './shared/vue.
|
|
1
|
+
export { u as useTokenBalance } from './shared/vue.BD6Gm1nl.mjs';
|
|
2
2
|
import '@vue-solana/core/token-accounts';
|
|
3
3
|
import '@vue-solana/core/errors';
|
|
4
4
|
import '@vue-solana/core/address';
|
|
5
5
|
import 'vue';
|
|
6
|
-
import './shared/vue.
|
|
7
|
-
import './shared/vue.
|
|
8
|
-
import './shared/vue.
|
|
6
|
+
import './shared/vue.CpkwC8Th.mjs';
|
|
7
|
+
import './shared/vue.Mxc8w6Qk.mjs';
|
|
8
|
+
import './shared/vue.CQh3AUE8.mjs';
|
|
9
|
+
import './shared/vue.D_P5SqqD.mjs';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ReactiveActionSource, SolanaRpcResponse, ReactiveStreamSource, ReactiveStreamStore } from '@vue-solana/core/kit';
|
|
2
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
3
|
+
import { ComputedRef, Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
type UseTrackedDataStatus = "loading" | "loaded" | "error" | "disabled";
|
|
6
|
+
type SendFn<TValue> = (options?: {
|
|
7
|
+
abortSignal?: AbortSignal;
|
|
8
|
+
}) => Promise<TValue>;
|
|
9
|
+
/**
|
|
10
|
+
* One-shot initial-value source (satisfied by `PendingRpcRequest`).
|
|
11
|
+
*/
|
|
12
|
+
type UseTrackedDataInitialSource<TInitialValue> = ReactiveActionSource<SolanaRpcResponse<TInitialValue>> | {
|
|
13
|
+
send: SendFn<SolanaRpcResponse<TInitialValue>>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Ongoing stream source (satisfied by `PendingRpcSubscriptionsRequest`).
|
|
17
|
+
*/
|
|
18
|
+
type UseTrackedDataStreamSource<TStreamValue> = ReactiveStreamSource<SolanaRpcResponse<TStreamValue>> | {
|
|
19
|
+
reactiveStore: () => ReactiveStreamStore<SolanaRpcResponse<TStreamValue>>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A `useTrackedData` source bundle. Every field accepts a plain source or a
|
|
23
|
+
* `ref`/`computed` of it; a `null`/`undefined` `rpcRequest` or
|
|
24
|
+
* `rpcSubscriptionRequest` disables the composable.
|
|
25
|
+
*/
|
|
26
|
+
interface UseTrackedDataSource<TInitialValue, TStreamValue, TItem> {
|
|
27
|
+
/**
|
|
28
|
+
* One-shot RPC request for the initial value, for example
|
|
29
|
+
* `rpc.getBalance(address)`.
|
|
30
|
+
*/
|
|
31
|
+
rpcRequest: UseTrackedDataInitialSource<TInitialValue> | Ref<UseTrackedDataInitialSource<TInitialValue> | null | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* RPC subscription request for live updates, for example
|
|
34
|
+
* `rpcSubscriptions.accountNotifications(address)`.
|
|
35
|
+
*/
|
|
36
|
+
rpcSubscriptionRequest: UseTrackedDataStreamSource<TStreamValue> | Ref<UseTrackedDataStreamSource<TStreamValue> | null | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Maps the initial fetch's response value to the stored item type.
|
|
39
|
+
*/
|
|
40
|
+
rpcValueMapper: (value: TInitialValue) => TItem;
|
|
41
|
+
/**
|
|
42
|
+
* Maps a stream notification's value to the stored item type.
|
|
43
|
+
*/
|
|
44
|
+
rpcSubscriptionValueMapper: (value: TStreamValue) => TItem;
|
|
45
|
+
}
|
|
46
|
+
interface UseTrackedDataOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Returns a caller-provided `AbortSignal` per connection (for example
|
|
49
|
+
* `AbortSignal.timeout(60_000)`), composed with the per-connection signal
|
|
50
|
+
* by the underlying store. Aborting it fails the connection with the abort
|
|
51
|
+
* reason without touching other state. Read fresh from the latest render,
|
|
52
|
+
* so inline closures need no callback wrapping.
|
|
53
|
+
*/
|
|
54
|
+
getAbortSignal?: (connection: number) => AbortSignal | null | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Called when the tracked data transitions into `error`.
|
|
57
|
+
*/
|
|
58
|
+
onError?: (error: unknown) => void;
|
|
59
|
+
}
|
|
60
|
+
/** Per-connection abort overrides for `refresh()`. */
|
|
61
|
+
type UseTrackedDataRefresherOptions = {
|
|
62
|
+
/**
|
|
63
|
+
* Applies only this signal to both connections, bypassing `getAbortSignal`.
|
|
64
|
+
* Passing `undefined` (or an empty options object) applies no caller signal
|
|
65
|
+
* for that refresh; call `refresh()` with no argument to keep the
|
|
66
|
+
* `getAbortSignal` factory behavior.
|
|
67
|
+
*/
|
|
68
|
+
abortSignal?: AbortSignal;
|
|
69
|
+
};
|
|
70
|
+
interface UseTrackedDataReturn<TItem> {
|
|
71
|
+
/**
|
|
72
|
+
* The latest item, surface-mapped by `rpcValueMapper` /
|
|
73
|
+
* `rpcSubscriptionValueMapper`. The {@link SolanaRpcResponse} envelope is
|
|
74
|
+
* preserved so callers can read `data.value?.context.slot`.
|
|
75
|
+
*/
|
|
76
|
+
data: ComputedRef<SolanaRpcResponse<TItem> | undefined>;
|
|
77
|
+
error: ComputedRef<SolanaError | null>;
|
|
78
|
+
/** Rebuilds both connections. `refresh({ abortSignal })` overrides `getAbortSignal`. */
|
|
79
|
+
refresh: (options?: UseTrackedDataRefresherOptions) => void;
|
|
80
|
+
status: ComputedRef<UseTrackedDataStatus>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Live RPC data seeded by a one-shot fetch, slot-deduplicated between the two
|
|
84
|
+
* sources so notifications and the initial response can arrive in any order
|
|
85
|
+
* without out-of-order regressions.
|
|
86
|
+
*
|
|
87
|
+
* - `refresh()` aborts the current connection and re-runs both the fetch and
|
|
88
|
+
* the subscription with stale-while-revalidate (last known `data` stays
|
|
89
|
+
* visible while loading).
|
|
90
|
+
* - A `null`/`undefined` source (or `ref` of one) disables the composable and
|
|
91
|
+
* clears state.
|
|
92
|
+
* - `getAbortSignal` attaches per-connection cancellation (timeouts, kill
|
|
93
|
+
* switches) on top of the internal per-connection signal.
|
|
94
|
+
*/
|
|
95
|
+
declare function useTrackedData<TInitialValue, TStreamValue, TItem>(source: UseTrackedDataSource<TInitialValue, TStreamValue, TItem>, options?: UseTrackedDataOptions): UseTrackedDataReturn<TItem>;
|
|
96
|
+
|
|
97
|
+
export { useTrackedData };
|
|
98
|
+
export type { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataRefresherOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ReactiveActionSource, SolanaRpcResponse, ReactiveStreamSource, ReactiveStreamStore } from '@vue-solana/core/kit';
|
|
2
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
3
|
+
import { ComputedRef, Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
type UseTrackedDataStatus = "loading" | "loaded" | "error" | "disabled";
|
|
6
|
+
type SendFn<TValue> = (options?: {
|
|
7
|
+
abortSignal?: AbortSignal;
|
|
8
|
+
}) => Promise<TValue>;
|
|
9
|
+
/**
|
|
10
|
+
* One-shot initial-value source (satisfied by `PendingRpcRequest`).
|
|
11
|
+
*/
|
|
12
|
+
type UseTrackedDataInitialSource<TInitialValue> = ReactiveActionSource<SolanaRpcResponse<TInitialValue>> | {
|
|
13
|
+
send: SendFn<SolanaRpcResponse<TInitialValue>>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Ongoing stream source (satisfied by `PendingRpcSubscriptionsRequest`).
|
|
17
|
+
*/
|
|
18
|
+
type UseTrackedDataStreamSource<TStreamValue> = ReactiveStreamSource<SolanaRpcResponse<TStreamValue>> | {
|
|
19
|
+
reactiveStore: () => ReactiveStreamStore<SolanaRpcResponse<TStreamValue>>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A `useTrackedData` source bundle. Every field accepts a plain source or a
|
|
23
|
+
* `ref`/`computed` of it; a `null`/`undefined` `rpcRequest` or
|
|
24
|
+
* `rpcSubscriptionRequest` disables the composable.
|
|
25
|
+
*/
|
|
26
|
+
interface UseTrackedDataSource<TInitialValue, TStreamValue, TItem> {
|
|
27
|
+
/**
|
|
28
|
+
* One-shot RPC request for the initial value, for example
|
|
29
|
+
* `rpc.getBalance(address)`.
|
|
30
|
+
*/
|
|
31
|
+
rpcRequest: UseTrackedDataInitialSource<TInitialValue> | Ref<UseTrackedDataInitialSource<TInitialValue> | null | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* RPC subscription request for live updates, for example
|
|
34
|
+
* `rpcSubscriptions.accountNotifications(address)`.
|
|
35
|
+
*/
|
|
36
|
+
rpcSubscriptionRequest: UseTrackedDataStreamSource<TStreamValue> | Ref<UseTrackedDataStreamSource<TStreamValue> | null | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Maps the initial fetch's response value to the stored item type.
|
|
39
|
+
*/
|
|
40
|
+
rpcValueMapper: (value: TInitialValue) => TItem;
|
|
41
|
+
/**
|
|
42
|
+
* Maps a stream notification's value to the stored item type.
|
|
43
|
+
*/
|
|
44
|
+
rpcSubscriptionValueMapper: (value: TStreamValue) => TItem;
|
|
45
|
+
}
|
|
46
|
+
interface UseTrackedDataOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Returns a caller-provided `AbortSignal` per connection (for example
|
|
49
|
+
* `AbortSignal.timeout(60_000)`), composed with the per-connection signal
|
|
50
|
+
* by the underlying store. Aborting it fails the connection with the abort
|
|
51
|
+
* reason without touching other state. Read fresh from the latest render,
|
|
52
|
+
* so inline closures need no callback wrapping.
|
|
53
|
+
*/
|
|
54
|
+
getAbortSignal?: (connection: number) => AbortSignal | null | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Called when the tracked data transitions into `error`.
|
|
57
|
+
*/
|
|
58
|
+
onError?: (error: unknown) => void;
|
|
59
|
+
}
|
|
60
|
+
/** Per-connection abort overrides for `refresh()`. */
|
|
61
|
+
type UseTrackedDataRefresherOptions = {
|
|
62
|
+
/**
|
|
63
|
+
* Applies only this signal to both connections, bypassing `getAbortSignal`.
|
|
64
|
+
* Passing `undefined` (or an empty options object) applies no caller signal
|
|
65
|
+
* for that refresh; call `refresh()` with no argument to keep the
|
|
66
|
+
* `getAbortSignal` factory behavior.
|
|
67
|
+
*/
|
|
68
|
+
abortSignal?: AbortSignal;
|
|
69
|
+
};
|
|
70
|
+
interface UseTrackedDataReturn<TItem> {
|
|
71
|
+
/**
|
|
72
|
+
* The latest item, surface-mapped by `rpcValueMapper` /
|
|
73
|
+
* `rpcSubscriptionValueMapper`. The {@link SolanaRpcResponse} envelope is
|
|
74
|
+
* preserved so callers can read `data.value?.context.slot`.
|
|
75
|
+
*/
|
|
76
|
+
data: ComputedRef<SolanaRpcResponse<TItem> | undefined>;
|
|
77
|
+
error: ComputedRef<SolanaError | null>;
|
|
78
|
+
/** Rebuilds both connections. `refresh({ abortSignal })` overrides `getAbortSignal`. */
|
|
79
|
+
refresh: (options?: UseTrackedDataRefresherOptions) => void;
|
|
80
|
+
status: ComputedRef<UseTrackedDataStatus>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Live RPC data seeded by a one-shot fetch, slot-deduplicated between the two
|
|
84
|
+
* sources so notifications and the initial response can arrive in any order
|
|
85
|
+
* without out-of-order regressions.
|
|
86
|
+
*
|
|
87
|
+
* - `refresh()` aborts the current connection and re-runs both the fetch and
|
|
88
|
+
* the subscription with stale-while-revalidate (last known `data` stays
|
|
89
|
+
* visible while loading).
|
|
90
|
+
* - A `null`/`undefined` source (or `ref` of one) disables the composable and
|
|
91
|
+
* clears state.
|
|
92
|
+
* - `getAbortSignal` attaches per-connection cancellation (timeouts, kill
|
|
93
|
+
* switches) on top of the internal per-connection signal.
|
|
94
|
+
*/
|
|
95
|
+
declare function useTrackedData<TInitialValue, TStreamValue, TItem>(source: UseTrackedDataSource<TInitialValue, TStreamValue, TItem>, options?: UseTrackedDataOptions): UseTrackedDataReturn<TItem>;
|
|
96
|
+
|
|
97
|
+
export { useTrackedData };
|
|
98
|
+
export type { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataRefresherOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ReactiveActionSource, SolanaRpcResponse, ReactiveStreamSource, ReactiveStreamStore } from '@vue-solana/core/kit';
|
|
2
|
+
import { SolanaError } from '@vue-solana/core/errors';
|
|
3
|
+
import { ComputedRef, Ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
type UseTrackedDataStatus = "loading" | "loaded" | "error" | "disabled";
|
|
6
|
+
type SendFn<TValue> = (options?: {
|
|
7
|
+
abortSignal?: AbortSignal;
|
|
8
|
+
}) => Promise<TValue>;
|
|
9
|
+
/**
|
|
10
|
+
* One-shot initial-value source (satisfied by `PendingRpcRequest`).
|
|
11
|
+
*/
|
|
12
|
+
type UseTrackedDataInitialSource<TInitialValue> = ReactiveActionSource<SolanaRpcResponse<TInitialValue>> | {
|
|
13
|
+
send: SendFn<SolanaRpcResponse<TInitialValue>>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Ongoing stream source (satisfied by `PendingRpcSubscriptionsRequest`).
|
|
17
|
+
*/
|
|
18
|
+
type UseTrackedDataStreamSource<TStreamValue> = ReactiveStreamSource<SolanaRpcResponse<TStreamValue>> | {
|
|
19
|
+
reactiveStore: () => ReactiveStreamStore<SolanaRpcResponse<TStreamValue>>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A `useTrackedData` source bundle. Every field accepts a plain source or a
|
|
23
|
+
* `ref`/`computed` of it; a `null`/`undefined` `rpcRequest` or
|
|
24
|
+
* `rpcSubscriptionRequest` disables the composable.
|
|
25
|
+
*/
|
|
26
|
+
interface UseTrackedDataSource<TInitialValue, TStreamValue, TItem> {
|
|
27
|
+
/**
|
|
28
|
+
* One-shot RPC request for the initial value, for example
|
|
29
|
+
* `rpc.getBalance(address)`.
|
|
30
|
+
*/
|
|
31
|
+
rpcRequest: UseTrackedDataInitialSource<TInitialValue> | Ref<UseTrackedDataInitialSource<TInitialValue> | null | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* RPC subscription request for live updates, for example
|
|
34
|
+
* `rpcSubscriptions.accountNotifications(address)`.
|
|
35
|
+
*/
|
|
36
|
+
rpcSubscriptionRequest: UseTrackedDataStreamSource<TStreamValue> | Ref<UseTrackedDataStreamSource<TStreamValue> | null | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Maps the initial fetch's response value to the stored item type.
|
|
39
|
+
*/
|
|
40
|
+
rpcValueMapper: (value: TInitialValue) => TItem;
|
|
41
|
+
/**
|
|
42
|
+
* Maps a stream notification's value to the stored item type.
|
|
43
|
+
*/
|
|
44
|
+
rpcSubscriptionValueMapper: (value: TStreamValue) => TItem;
|
|
45
|
+
}
|
|
46
|
+
interface UseTrackedDataOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Returns a caller-provided `AbortSignal` per connection (for example
|
|
49
|
+
* `AbortSignal.timeout(60_000)`), composed with the per-connection signal
|
|
50
|
+
* by the underlying store. Aborting it fails the connection with the abort
|
|
51
|
+
* reason without touching other state. Read fresh from the latest render,
|
|
52
|
+
* so inline closures need no callback wrapping.
|
|
53
|
+
*/
|
|
54
|
+
getAbortSignal?: (connection: number) => AbortSignal | null | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Called when the tracked data transitions into `error`.
|
|
57
|
+
*/
|
|
58
|
+
onError?: (error: unknown) => void;
|
|
59
|
+
}
|
|
60
|
+
/** Per-connection abort overrides for `refresh()`. */
|
|
61
|
+
type UseTrackedDataRefresherOptions = {
|
|
62
|
+
/**
|
|
63
|
+
* Applies only this signal to both connections, bypassing `getAbortSignal`.
|
|
64
|
+
* Passing `undefined` (or an empty options object) applies no caller signal
|
|
65
|
+
* for that refresh; call `refresh()` with no argument to keep the
|
|
66
|
+
* `getAbortSignal` factory behavior.
|
|
67
|
+
*/
|
|
68
|
+
abortSignal?: AbortSignal;
|
|
69
|
+
};
|
|
70
|
+
interface UseTrackedDataReturn<TItem> {
|
|
71
|
+
/**
|
|
72
|
+
* The latest item, surface-mapped by `rpcValueMapper` /
|
|
73
|
+
* `rpcSubscriptionValueMapper`. The {@link SolanaRpcResponse} envelope is
|
|
74
|
+
* preserved so callers can read `data.value?.context.slot`.
|
|
75
|
+
*/
|
|
76
|
+
data: ComputedRef<SolanaRpcResponse<TItem> | undefined>;
|
|
77
|
+
error: ComputedRef<SolanaError | null>;
|
|
78
|
+
/** Rebuilds both connections. `refresh({ abortSignal })` overrides `getAbortSignal`. */
|
|
79
|
+
refresh: (options?: UseTrackedDataRefresherOptions) => void;
|
|
80
|
+
status: ComputedRef<UseTrackedDataStatus>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Live RPC data seeded by a one-shot fetch, slot-deduplicated between the two
|
|
84
|
+
* sources so notifications and the initial response can arrive in any order
|
|
85
|
+
* without out-of-order regressions.
|
|
86
|
+
*
|
|
87
|
+
* - `refresh()` aborts the current connection and re-runs both the fetch and
|
|
88
|
+
* the subscription with stale-while-revalidate (last known `data` stays
|
|
89
|
+
* visible while loading).
|
|
90
|
+
* - A `null`/`undefined` source (or `ref` of one) disables the composable and
|
|
91
|
+
* clears state.
|
|
92
|
+
* - `getAbortSignal` attaches per-connection cancellation (timeouts, kill
|
|
93
|
+
* switches) on top of the internal per-connection signal.
|
|
94
|
+
*/
|
|
95
|
+
declare function useTrackedData<TInitialValue, TStreamValue, TItem>(source: UseTrackedDataSource<TInitialValue, TStreamValue, TItem>, options?: UseTrackedDataOptions): UseTrackedDataReturn<TItem>;
|
|
96
|
+
|
|
97
|
+
export { useTrackedData };
|
|
98
|
+
export type { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataRefresherOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource };
|
package/dist/useTransaction.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useTransaction = require('./shared/vue.
|
|
3
|
+
const useTransaction = require('./shared/vue.Bk5xjlUx.cjs');
|
|
4
|
+
require('@vue-solana/core/action');
|
|
4
5
|
require('@vue-solana/core/errors');
|
|
5
6
|
require('@vue-solana/core/timeout');
|
|
6
7
|
require('vue');
|