@vue-solana/vue 2.6.1 → 3.0.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.
Files changed (188) hide show
  1. package/README.md +6 -4
  2. package/dist/index.d.mts +3 -1
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.mjs +36 -47
  5. package/dist/shared/vue.1Qwco2kv.mjs +33 -0
  6. package/dist/shared/vue.BFSboXMB.mjs +17 -0
  7. package/dist/shared/vue.BGGixph-.d.mts +5 -0
  8. package/dist/shared/vue.BGGixph-.d.ts +5 -0
  9. package/dist/shared/{vue.CbJFnho-.mjs → vue.BNJTXSnQ.mjs} +17 -70
  10. package/dist/shared/{vue.BINkrA8h.mjs → vue.BwBqla_n.mjs} +16 -26
  11. package/dist/shared/vue.BxtOHzY_.mjs +27 -0
  12. package/dist/shared/vue.C1JbUTpJ.mjs +66 -0
  13. package/dist/shared/vue.C9OOmvkD.mjs +36 -0
  14. package/dist/shared/vue.CGv0ip3w.mjs +52 -0
  15. package/dist/shared/vue.CaAgH2Xt.mjs +51 -0
  16. package/dist/shared/{vue.Dyi1OCI1.mjs → vue.CjSw0Hh1.mjs} +3 -9
  17. package/dist/shared/vue.CsFY1mfz.mjs +29 -0
  18. package/dist/shared/vue.CvenSbZZ.mjs +27 -0
  19. package/dist/shared/{vue.BDNOyiGZ.mjs → vue.D5pqR5Fa.mjs} +9 -12
  20. package/dist/shared/vue.DNKD6jqM.mjs +22 -0
  21. package/dist/shared/vue.DlihC5GG.mjs +38 -0
  22. package/dist/shared/vue.XlfH_nkc.mjs +32 -0
  23. package/dist/shared/vue.hG_FieA3.mjs +37 -0
  24. package/dist/shared/vue.o98pAmDg.mjs +40 -0
  25. package/dist/swr.mjs +22 -76
  26. package/dist/useAccountInfo.d.mts +4 -4
  27. package/dist/useAccountInfo.d.ts +4 -4
  28. package/dist/useAccountInfo.mjs +5 -4
  29. package/dist/useBalance.d.mts +4 -4
  30. package/dist/useBalance.d.ts +4 -4
  31. package/dist/useBalance.mjs +5 -4
  32. package/dist/usePlanTransaction.d.mts +12 -13
  33. package/dist/usePlanTransaction.d.ts +12 -13
  34. package/dist/usePlanTransaction.mjs +2 -1
  35. package/dist/usePlanTransactions.d.mts +2 -1
  36. package/dist/usePlanTransactions.d.ts +2 -1
  37. package/dist/usePlanTransactions.mjs +2 -1
  38. package/dist/useProgramAccounts.d.mts +5 -15
  39. package/dist/useProgramAccounts.d.ts +5 -15
  40. package/dist/useProgramAccounts.mjs +5 -4
  41. package/dist/useSendTransaction.d.mts +11 -12
  42. package/dist/useSendTransaction.d.ts +11 -12
  43. package/dist/useSendTransaction.mjs +2 -1
  44. package/dist/useSendTransactions.d.mts +2 -1
  45. package/dist/useSendTransactions.d.ts +2 -1
  46. package/dist/useSendTransactions.mjs +2 -1
  47. package/dist/useSignAndSendTransaction.d.mts +1 -1
  48. package/dist/useSignAndSendTransaction.d.ts +1 -1
  49. package/dist/useSignAndSendTransaction.mjs +3 -2
  50. package/dist/useSignAndSendTransactions.d.mts +2 -2
  51. package/dist/useSignAndSendTransactions.d.ts +2 -2
  52. package/dist/useSignAndSendTransactions.mjs +2 -1
  53. package/dist/useSignIn.d.mts +4 -4
  54. package/dist/useSignIn.d.ts +4 -4
  55. package/dist/useSignIn.mjs +3 -2
  56. package/dist/useSignMessage.d.mts +4 -4
  57. package/dist/useSignMessage.d.ts +4 -4
  58. package/dist/useSignMessage.mjs +3 -2
  59. package/dist/useSignTransactions.d.mts +4 -4
  60. package/dist/useSignTransactions.d.ts +4 -4
  61. package/dist/useSignTransactions.mjs +3 -2
  62. package/dist/useSubscription.mjs +1 -1
  63. package/dist/useTokenAccounts.d.mts +4 -4
  64. package/dist/useTokenAccounts.d.ts +4 -4
  65. package/dist/useTokenAccounts.mjs +5 -4
  66. package/dist/useTokenBalance.d.mts +9 -7
  67. package/dist/useTokenBalance.d.ts +9 -7
  68. package/dist/useTokenBalance.mjs +4 -3
  69. package/dist/useTrackedData.mjs +1 -1
  70. package/dist/useTransactionConfirmation.d.mts +4 -4
  71. package/dist/useTransactionConfirmation.d.ts +4 -4
  72. package/dist/useTransactionConfirmation.mjs +3 -2
  73. package/package.json +38 -75
  74. package/dist/buffer-polyfill.cjs +0 -8
  75. package/dist/buffer-polyfill.d.cts +0 -2
  76. package/dist/index.cjs +0 -452
  77. package/dist/index.d.cts +0 -62
  78. package/dist/kit.cjs +0 -16
  79. package/dist/kit.d.cts +0 -1
  80. package/dist/shared/vue.4C5kX4fE.cjs +0 -36
  81. package/dist/shared/vue.9TPxZPMf.cjs +0 -59
  82. package/dist/shared/vue.B4eMoJT2.cjs +0 -36
  83. package/dist/shared/vue.B6ainw2G.cjs +0 -63
  84. package/dist/shared/vue.BD6Gm1nl.mjs +0 -74
  85. package/dist/shared/vue.BGxz4dru.cjs +0 -98
  86. package/dist/shared/vue.BIxphCAq.cjs +0 -10
  87. package/dist/shared/vue.BOpgWr43.mjs +0 -70
  88. package/dist/shared/vue.BQRpjwKl.mjs +0 -80
  89. package/dist/shared/vue.BVaMoz9y.cjs +0 -9
  90. package/dist/shared/vue.Bk5xjlUx.cjs +0 -61
  91. package/dist/shared/vue.Bwd1sGAM.cjs +0 -72
  92. package/dist/shared/vue.ByxbBC3y.mjs +0 -57
  93. package/dist/shared/vue.C13umiQi.mjs +0 -85
  94. package/dist/shared/vue.CIs8QhCw.cjs +0 -132
  95. package/dist/shared/vue.CMohL_Cz.mjs +0 -58
  96. package/dist/shared/vue.CWZSMVnB.cjs +0 -84
  97. package/dist/shared/vue.Co5rj-I6.mjs +0 -118
  98. package/dist/shared/vue.CoaIWGPT.cjs +0 -38
  99. package/dist/shared/vue.CrkK_T15.cjs +0 -86
  100. package/dist/shared/vue.D-qi8PSL.cjs +0 -82
  101. package/dist/shared/vue.D3Y0PWbF.mjs +0 -71
  102. package/dist/shared/vue.D5U1yLG3.mjs +0 -83
  103. package/dist/shared/vue.DAg5wC1G.cjs +0 -76
  104. package/dist/shared/vue.DAthhH4D.mjs +0 -118
  105. package/dist/shared/vue.DDbVk0Zh.cjs +0 -180
  106. package/dist/shared/vue.DE3emjSF.cjs +0 -48
  107. package/dist/shared/vue.DEHxNvUX.cjs +0 -7
  108. package/dist/shared/vue.DFaMJLAQ.cjs +0 -60
  109. package/dist/shared/vue.DKoM8jIV.cjs +0 -121
  110. package/dist/shared/vue.DKyQ7J67.cjs +0 -15
  111. package/dist/shared/vue.DL3z5PxP.d.cts +0 -21
  112. package/dist/shared/vue.DNxOpDXz.cjs +0 -12
  113. package/dist/shared/vue.Di7yjJ-R.cjs +0 -87
  114. package/dist/shared/vue.Dn3KLJZH.cjs +0 -121
  115. package/dist/shared/vue.DxM45azl.cjs +0 -173
  116. package/dist/shared/vue.E_npPFoV.cjs +0 -67
  117. package/dist/shared/vue.FiMmnMHr.cjs +0 -20
  118. package/dist/shared/vue.JUWqu6kD.mjs +0 -61
  119. package/dist/shared/vue.Sbbm9JSu.cjs +0 -74
  120. package/dist/shared/vue.ZuUCEEab.cjs +0 -103
  121. package/dist/shared/vue.l3UCdN7z.cjs +0 -111
  122. package/dist/shared/vue.ldvmk9NM.cjs +0 -45
  123. package/dist/swr.cjs +0 -136
  124. package/dist/swr.d.cts +0 -41
  125. package/dist/useAccountInfo.cjs +0 -15
  126. package/dist/useAccountInfo.d.cts +0 -24
  127. package/dist/useAction.cjs +0 -9
  128. package/dist/useAction.d.cts +0 -45
  129. package/dist/useAirdrop.cjs +0 -14
  130. package/dist/useAirdrop.d.cts +0 -27
  131. package/dist/useBalance.cjs +0 -14
  132. package/dist/useBalance.d.cts +0 -15
  133. package/dist/useClientCapability.cjs +0 -12
  134. package/dist/useClientCapability.d.cts +0 -39
  135. package/dist/useConnection.cjs +0 -11
  136. package/dist/useConnection.d.cts +0 -46
  137. package/dist/useIdentity.cjs +0 -12
  138. package/dist/useIdentity.d.cts +0 -3
  139. package/dist/usePayer.cjs +0 -13
  140. package/dist/usePayer.d.cts +0 -18
  141. package/dist/usePlanTransaction.cjs +0 -14
  142. package/dist/usePlanTransaction.d.cts +0 -45
  143. package/dist/usePlanTransactions.cjs +0 -13
  144. package/dist/usePlanTransactions.d.cts +0 -4
  145. package/dist/useProgramAccounts.cjs +0 -15
  146. package/dist/useProgramAccounts.d.cts +0 -55
  147. package/dist/useRequest.cjs +0 -11
  148. package/dist/useRequest.d.cts +0 -73
  149. package/dist/useRpc.cjs +0 -10
  150. package/dist/useRpc.d.cts +0 -55
  151. package/dist/useSelectedWalletAccount.cjs +0 -13
  152. package/dist/useSelectedWalletAccount.d.cts +0 -117
  153. package/dist/useSendTransaction.cjs +0 -14
  154. package/dist/useSendTransaction.d.cts +0 -51
  155. package/dist/useSendTransactions.cjs +0 -13
  156. package/dist/useSendTransactions.d.cts +0 -4
  157. package/dist/useSignAndSendTransaction.cjs +0 -18
  158. package/dist/useSignAndSendTransaction.d.cts +0 -40
  159. package/dist/useSignAndSendTransactions.cjs +0 -15
  160. package/dist/useSignAndSendTransactions.d.cts +0 -35
  161. package/dist/useSignIn.cjs +0 -13
  162. package/dist/useSignIn.d.cts +0 -23
  163. package/dist/useSignMessage.cjs +0 -13
  164. package/dist/useSignMessage.d.cts +0 -236
  165. package/dist/useSignTransactions.cjs +0 -13
  166. package/dist/useSignTransactions.d.cts +0 -24
  167. package/dist/useSignatureStatus.cjs +0 -14
  168. package/dist/useSignatureStatus.d.cts +0 -26
  169. package/dist/useSolana.cjs +0 -10
  170. package/dist/useSolana.d.cts +0 -9
  171. package/dist/useSolanaClient.cjs +0 -10
  172. package/dist/useSolanaClient.d.cts +0 -45
  173. package/dist/useSubscription.cjs +0 -9
  174. package/dist/useSubscription.d.cts +0 -70
  175. package/dist/useTokenAccounts.cjs +0 -15
  176. package/dist/useTokenAccounts.d.cts +0 -19
  177. package/dist/useTokenBalance.cjs +0 -15
  178. package/dist/useTokenBalance.d.cts +0 -15
  179. package/dist/useTrackedData.cjs +0 -10
  180. package/dist/useTrackedData.d.cts +0 -98
  181. package/dist/useTransaction.cjs +0 -11
  182. package/dist/useTransaction.d.cts +0 -27
  183. package/dist/useTransactionConfirmation.cjs +0 -15
  184. package/dist/useTransactionConfirmation.d.cts +0 -38
  185. package/dist/useWallet.cjs +0 -12
  186. package/dist/useWallet.d.cts +0 -31
  187. package/dist/useWallets.cjs +0 -10
  188. package/dist/useWallets.d.cts +0 -11
@@ -1,103 +0,0 @@
1
- 'use strict';
2
-
3
- const action = require('@vue-solana/core/action');
4
- const kit = require('@vue-solana/core/kit');
5
- const errors = require('@vue-solana/core/errors');
6
- const vue = require('vue');
7
-
8
- function useRequest(source, options = {}) {
9
- const data = vue.shallowRef(void 0);
10
- const error = vue.shallowRef(null);
11
- const status = vue.shallowRef("fetching");
12
- let disposed = false;
13
- let attempt = 0;
14
- const store = action.createSolanaActionStore(async (signal, resolved, override) => {
15
- attempt += 1;
16
- const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(attempt);
17
- const composedSignal = callerSignal ? AbortSignal.any([signal, callerSignal]) : signal;
18
- let pending;
19
- if (isSendSource(resolved)) {
20
- pending = Promise.resolve(resolved.send({ abortSignal: composedSignal }));
21
- } else if (typeof resolved === "function") {
22
- pending = Promise.resolve(resolved(composedSignal)).then(
23
- (result) => isSendSource(result) ? result.send({ abortSignal: composedSignal }) : result
24
- );
25
- } else {
26
- throw new Error("useRequest source did not resolve to a request function");
27
- }
28
- return kit.getAbortablePromise(pending, composedSignal);
29
- });
30
- const unsubscribe = store.subscribe(() => {
31
- const next = store.getState();
32
- if (next.status === "success") {
33
- data.value = next.data;
34
- error.value = null;
35
- status.value = "success";
36
- } else if (next.status === "error") {
37
- error.value = errors.normalizeSolanaError(next.error, "RPC_FAILURE");
38
- status.value = "error";
39
- } else if (next.status === "running") {
40
- status.value = "fetching";
41
- }
42
- });
43
- vue.onScopeDispose(() => {
44
- disposed = true;
45
- unsubscribe();
46
- store.reset();
47
- });
48
- function unwrapSource() {
49
- if (vue.isRef(source)) {
50
- return source.value;
51
- }
52
- return source;
53
- }
54
- async function run(override) {
55
- if (disposed) {
56
- return void 0;
57
- }
58
- const resolved = unwrapSource();
59
- if (isDisabled(resolved)) {
60
- data.value = void 0;
61
- error.value = null;
62
- status.value = "disabled";
63
- store.reset();
64
- return void 0;
65
- }
66
- status.value = "fetching";
67
- try {
68
- return await store.dispatchAsync(resolved, override);
69
- } catch (cause) {
70
- if (store.getState().status !== "error") {
71
- return void 0;
72
- }
73
- throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
74
- }
75
- }
76
- const refresh = (options2) => run(options2);
77
- vue.watch(
78
- () => vue.isRef(source) ? source.value : source,
79
- () => {
80
- void refresh().catch(() => void 0);
81
- }
82
- );
83
- vue.onMounted(() => {
84
- void refresh().catch(() => void 0);
85
- });
86
- if (!vue.getCurrentInstance()) {
87
- void refresh().catch(() => void 0);
88
- }
89
- return {
90
- data: vue.computed(() => data.value),
91
- error: vue.computed(() => error.value),
92
- refresh,
93
- status: vue.computed(() => status.value)
94
- };
95
- }
96
- function isDisabled(resolved) {
97
- return resolved === null || resolved === void 0;
98
- }
99
- function isSendSource(resolved) {
100
- return typeof resolved === "object" && resolved !== null && "send" in resolved && typeof resolved.send === "function";
101
- }
102
-
103
- exports.useRequest = useRequest;
@@ -1,111 +0,0 @@
1
- 'use strict';
2
-
3
- const errors = require('@vue-solana/core/errors');
4
- const vue = require('vue');
5
-
6
- function useSubscription(source, options = {}) {
7
- const data = vue.shallowRef(void 0);
8
- const error = vue.shallowRef(null);
9
- const status = vue.shallowRef("loading");
10
- const disposables = [];
11
- let connectionCount = 0;
12
- let disposed = false;
13
- let activeSource;
14
- let activeStore;
15
- function applyState(state) {
16
- if (state.status === "loaded") {
17
- data.value = state.data;
18
- error.value = null;
19
- status.value = "loaded";
20
- } else if (state.status === "error") {
21
- error.value = errors.normalizeSolanaError(state.error, "RPC_FAILURE");
22
- status.value = "error";
23
- options.onError?.(state.error);
24
- } else if (state.status === "loading") {
25
- status.value = data.value === void 0 ? "loading" : status.value;
26
- } else if (state.status === "idle") {
27
- data.value = void 0;
28
- error.value = null;
29
- status.value = "loading";
30
- }
31
- }
32
- function openConnection(store, override) {
33
- activeStore = store;
34
- connectionCount += 1;
35
- const connection = connectionCount;
36
- const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
37
- applyState(store.getState());
38
- disposables.push(
39
- store.subscribe(() => {
40
- applyState(store.getState());
41
- })
42
- );
43
- if (callerSignal?.aborted) {
44
- applyState({ data: store.getState().data, error: callerSignal.reason, status: "error" });
45
- return;
46
- }
47
- if (callerSignal) {
48
- store.withSignal(callerSignal).connect();
49
- } else {
50
- store.connect();
51
- }
52
- }
53
- function disconnect() {
54
- disposables.forEach((dispose) => {
55
- dispose();
56
- });
57
- disposables.length = 0;
58
- if (activeStore) {
59
- activeStore.reset();
60
- activeStore = void 0;
61
- }
62
- activeSource = void 0;
63
- }
64
- function connectCurrent(override) {
65
- if (disposed) {
66
- return;
67
- }
68
- const resolved = vue.isRef(source) ? source.value : source;
69
- if (resolved === null || resolved === void 0) {
70
- disconnect();
71
- data.value = void 0;
72
- error.value = null;
73
- status.value = "disabled";
74
- return;
75
- }
76
- if (activeSource === resolved && activeStore) {
77
- openConnection(activeStore, override);
78
- return;
79
- }
80
- disconnect();
81
- activeSource = resolved;
82
- openConnection(resolved.reactiveStore(), override);
83
- }
84
- vue.watch(
85
- () => vue.isRef(source) ? source.value : source,
86
- () => {
87
- connectCurrent();
88
- },
89
- { flush: "sync" }
90
- );
91
- vue.onMounted(() => {
92
- connectCurrent();
93
- });
94
- if (!vue.getCurrentInstance()) {
95
- connectCurrent();
96
- }
97
- vue.onScopeDispose(() => {
98
- disposed = true;
99
- disconnect();
100
- });
101
- return {
102
- data: vue.computed(() => data.value),
103
- error: vue.computed(() => error.value),
104
- reconnect: (options2) => {
105
- connectCurrent(options2);
106
- },
107
- status: vue.computed(() => status.value)
108
- };
109
- }
110
-
111
- exports.useSubscription = useSubscription;
@@ -1,45 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
- const useClientCapability = require('./vue.4C5kX4fE.cjs');
5
- const useSolanaClient = require('./vue.BIxphCAq.cjs');
6
-
7
- function useIdentity() {
8
- useClientCapability.useClientCapability(["identity"], {
9
- hookName: "useIdentity",
10
- providerHint: "Install a signer plugin, e.g. `createClient().use(generatedIdentity())` from `@solana/kit-plugin-signer`."
11
- });
12
- const { client } = useSolanaClient.useSolanaClient();
13
- const identity = vue.shallowRef(
14
- client.identity
15
- );
16
- const subscribable = client;
17
- if (typeof subscribable.subscribeToIdentity === "function") {
18
- const unsubscribe = subscribable.subscribeToIdentity(() => {
19
- identity.value = client.identity;
20
- });
21
- vue.onScopeDispose(unsubscribe);
22
- }
23
- return identity;
24
- }
25
- function usePayer() {
26
- useClientCapability.useClientCapability(["payer"], {
27
- hookName: "usePayer",
28
- providerHint: "Install a signer plugin, e.g. `createClient().use(generatedPayer())` from `@solana/kit-plugin-signer`."
29
- });
30
- const { client } = useSolanaClient.useSolanaClient();
31
- const payer = vue.shallowRef(
32
- client.payer
33
- );
34
- const subscribable = client;
35
- if (typeof subscribable.subscribeToPayer === "function") {
36
- const unsubscribe = subscribable.subscribeToPayer(() => {
37
- payer.value = client.payer;
38
- });
39
- vue.onScopeDispose(unsubscribe);
40
- }
41
- return payer;
42
- }
43
-
44
- exports.useIdentity = useIdentity;
45
- exports.usePayer = usePayer;
package/dist/swr.cjs DELETED
@@ -1,136 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
- const useRequest = require('./shared/vue.ZuUCEEab.cjs');
5
- const useSubscription = require('./shared/vue.l3UCdN7z.cjs');
6
- const useTrackedData = require('./shared/vue.DxM45azl.cjs');
7
- require('@vue-solana/core/action');
8
- require('@vue-solana/core/kit');
9
- require('@vue-solana/core/errors');
10
-
11
- const PREFIX_REQUEST = "request:";
12
- const PREFIX_SUBSCRIPTION = "subscription:";
13
- const PREFIX_TRACKED = "tracked:";
14
- const swrCache = /* @__PURE__ */ new Map();
15
- function clearSwrCache() {
16
- swrCache.clear();
17
- }
18
- function readSwrCache(key) {
19
- return swrCache.get(key);
20
- }
21
- function writeSwrCache(key, entry) {
22
- swrCache.set(key, entry);
23
- }
24
- function deleteSwrCache(key) {
25
- swrCache.delete(key);
26
- }
27
- function isPendingStatus(status) {
28
- return status === "fetching" || status === "loading";
29
- }
30
- function writeSwrResult(key, data, error, status) {
31
- if (status === "disabled") {
32
- deleteSwrCache(key);
33
- return;
34
- }
35
- const previous = readSwrCache(key);
36
- writeSwrCache(key, {
37
- data: data !== void 0 ? data : previous?.data,
38
- error,
39
- status
40
- });
41
- }
42
- function swrError(error, status, seed) {
43
- if (status === "disabled") {
44
- return null;
45
- }
46
- return error ?? (isPendingStatus(status) ? seed?.error ?? null : null);
47
- }
48
- function useRequestSwr(key, source, options = {}) {
49
- const cacheKey = `${PREFIX_REQUEST}${key}`;
50
- const seed = readSwrCache(cacheKey);
51
- const result = useRequest.useRequest(source, options);
52
- if (result.status.value === "disabled") {
53
- deleteSwrCache(cacheKey);
54
- }
55
- vue.watch(
56
- [result.data, result.error, result.status],
57
- ([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
58
- { flush: "sync" }
59
- );
60
- const data = vue.computed(() => {
61
- if (result.status.value === "disabled") {
62
- return void 0;
63
- }
64
- return result.data.value !== void 0 ? result.data.value : seed?.data;
65
- });
66
- const error = vue.computed(
67
- () => swrError(result.error.value, result.status.value, seed)
68
- );
69
- return {
70
- data,
71
- error,
72
- refresh: result.refresh,
73
- status: result.status
74
- };
75
- }
76
- function useSubscriptionSwr(key, source, options = {}) {
77
- const cacheKey = `${PREFIX_SUBSCRIPTION}${key}`;
78
- const seed = readSwrCache(cacheKey);
79
- const result = useSubscription.useSubscription(source, options);
80
- if (result.status.value === "disabled") {
81
- deleteSwrCache(cacheKey);
82
- }
83
- vue.watch(
84
- [result.data, result.error, result.status],
85
- ([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
86
- { flush: "sync" }
87
- );
88
- const data = vue.computed(() => {
89
- if (result.status.value === "disabled") {
90
- return void 0;
91
- }
92
- return result.data.value !== void 0 ? result.data.value : seed?.data;
93
- });
94
- const error = vue.computed(
95
- () => swrError(result.error.value, result.status.value, seed)
96
- );
97
- return {
98
- data,
99
- error,
100
- reconnect: result.reconnect,
101
- status: result.status
102
- };
103
- }
104
- function useTrackedDataSwr(key, source, options = {}) {
105
- const cacheKey = `${PREFIX_TRACKED}${key}`;
106
- const seed = readSwrCache(cacheKey);
107
- const result = useTrackedData.useTrackedData(source, options);
108
- if (result.status.value === "disabled") {
109
- deleteSwrCache(cacheKey);
110
- }
111
- vue.watch(
112
- [result.data, result.error, result.status],
113
- ([data2, error2, status]) => writeSwrResult(cacheKey, data2, error2, status),
114
- { flush: "sync" }
115
- );
116
- const data = vue.computed(() => {
117
- if (result.status.value === "disabled") {
118
- return void 0;
119
- }
120
- return result.data.value ?? seed?.data;
121
- });
122
- const error = vue.computed(
123
- () => swrError(result.error.value, result.status.value, seed)
124
- );
125
- return {
126
- data,
127
- error,
128
- refresh: result.refresh,
129
- status: result.status
130
- };
131
- }
132
-
133
- exports.clearSwrCache = clearSwrCache;
134
- exports.useRequestSwr = useRequestSwr;
135
- exports.useSubscriptionSwr = useSubscriptionSwr;
136
- exports.useTrackedDataSwr = useTrackedDataSwr;
package/dist/swr.d.cts DELETED
@@ -1,41 +0,0 @@
1
- import { useRequest, UseRequestOptions, UseRequestReturn } from './useRequest.cjs';
2
- import { UseSubscriptionSource, UseSubscriptionOptions, UseSubscriptionReturn } from './useSubscription.cjs';
3
- import { UseTrackedDataSource, UseTrackedDataOptions, UseTrackedDataReturn } from './useTrackedData.cjs';
4
- import '@vue-solana/core/errors';
5
- import 'vue';
6
- import '@vue-solana/core/kit';
7
-
8
- /**
9
- * Remove every cached SWR entry (all adapters). Useful between test cases
10
- * and to reset server-side caches per request.
11
- */
12
- declare function clearSwrCache(): void;
13
- /**
14
- * `useRequest` with cache keying. A component mounting with a key that
15
- * already holds data shows it immediately (stale) while its own request
16
- * revalidates; results are written back for the next mount.
17
- *
18
- * A `null`/`undefined` source disables the request and **clears** the
19
- * cached entry for the key — including when the component mounts with the
20
- * source already disabled.
21
- */
22
- declare function useRequestSwr<TResult>(key: string, source: Parameters<typeof useRequest<TResult>>[0], options?: UseRequestOptions): UseRequestReturn<TResult>;
23
- /**
24
- * `useSubscription` with cache keying — a freshly mounted component seeds
25
- * from the last-known stream value while its own subscription connects.
26
- *
27
- * A `null`/`undefined` source disables the subscription and **clears** the
28
- * cached entry for the key.
29
- */
30
- declare function useSubscriptionSwr<TResult>(key: string, source: UseSubscriptionSource<TResult>, options?: UseSubscriptionOptions): UseSubscriptionReturn<TResult>;
31
- /**
32
- * `useTrackedData` with cache keying — seeds from the last-known
33
- * {@link SolanaRpcResponse} envelope (data **and** slot context) while the
34
- * fetch + subscription pair revalidates.
35
- *
36
- * A `null`/`undefined` source disables the composable and **clears** the
37
- * cached entry for the key.
38
- */
39
- declare function useTrackedDataSwr<TInitialValue, TStreamValue, TItem>(key: string, source: UseTrackedDataSource<TInitialValue, TStreamValue, TItem>, options?: UseTrackedDataOptions): UseTrackedDataReturn<TItem>;
40
-
41
- export { clearSwrCache, useRequestSwr, useSubscriptionSwr, useTrackedDataSwr };
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- const useAccountInfo = require('./shared/vue.D-qi8PSL.cjs');
4
- require('@vue-solana/core/errors');
5
- require('vue');
6
- require('@vue-solana/core/address');
7
- require('./shared/vue.BVaMoz9y.cjs');
8
- require('./shared/vue.BIxphCAq.cjs');
9
- require('./shared/vue.DE3emjSF.cjs');
10
- require('./shared/vue.DEHxNvUX.cjs');
11
- require('./shared/vue.DNxOpDXz.cjs');
12
-
13
-
14
-
15
- exports.useAccountInfo = useAccountInfo.useAccountInfo;
@@ -1,24 +0,0 @@
1
- import * as vue from 'vue';
2
- import { MaybeRefOrGetter } from 'vue';
3
- import { Commitment } from '@vue-solana/core/kit';
4
- import { SolanaError } from '@vue-solana/core/errors';
5
-
6
- interface UseAccountInfoOptions {
7
- commitment?: Commitment;
8
- }
9
- interface AccountInfo {
10
- executable: boolean;
11
- lamports: number;
12
- owner: string;
13
- space: number;
14
- data: Uint8Array;
15
- }
16
- declare function useAccountInfo(address: MaybeRefOrGetter<string | null | undefined>, options?: UseAccountInfoOptions): {
17
- accountInfo: vue.ShallowRef<AccountInfo | null, AccountInfo | null>;
18
- loading: vue.ShallowRef<boolean, boolean>;
19
- error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
20
- refresh: () => Promise<AccountInfo | null>;
21
- };
22
-
23
- export { useAccountInfo };
24
- export type { AccountInfo, UseAccountInfoOptions };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- const useAction = require('./shared/vue.CoaIWGPT.cjs');
4
- require('@vue-solana/core/action');
5
- require('vue');
6
-
7
-
8
-
9
- exports.useAction = useAction.useAction;
@@ -1,45 +0,0 @@
1
- import { ComputedRef, Ref } from 'vue';
2
-
3
- type UseActionStatus = "idle" | "running" | "success" | "error";
4
- interface UseActionOptions {
5
- /**
6
- * Called after a dispatch settles successfully.
7
- */
8
- onSuccess?: (data: unknown) => void;
9
- /**
10
- * Called after a dispatch fails for a reason other than supersession.
11
- */
12
- onError?: (error: unknown) => void;
13
- }
14
- interface UseActionReturn<TArgs extends readonly unknown[], TResult> {
15
- data: ComputedRef<TResult | undefined>;
16
- dispatch: (...args: TArgs) => Promise<TResult>;
17
- error: ComputedRef<unknown>;
18
- isRunning: ComputedRef<boolean>;
19
- reset: () => void;
20
- status: ComputedRef<UseActionStatus>;
21
- }
22
- /**
23
- * Generic async action state machine.
24
- *
25
- * Accepts any async function that receives a fresh `AbortSignal` per call and
26
- * tracks `{ data, dispatch, error, isRunning, reset, status }` through Vue
27
- * reactive state.
28
- *
29
- * - There is no dependencies array: pass the handler directly or as a ref;
30
- * `dispatch` always invokes the latest closure, so handlers reading
31
- * reactive state never see stale values. `dispatch` keeps a stable identity
32
- * across the component lifetime.
33
- * - Calling `dispatch` again while a call is in flight aborts the previous
34
- * call. Superseded calls reject with an abort reason so callers can detect
35
- * them; they never corrupt state.
36
- * - Failures surface on `error` while the previous `data` is preserved for
37
- * stale-while-revalidate rendering.
38
- *
39
- * The underlying state machine is `createSolanaActionStore` from
40
- * `@vue-solana/core/action`, shared with non-Vue consumers.
41
- */
42
- declare function useAction<TArgs extends readonly unknown[], TResult>(action: ((signal: AbortSignal, ...args: TArgs) => Promise<TResult>) | Ref<(signal: AbortSignal, ...args: TArgs) => Promise<TResult>>, options?: UseActionOptions): UseActionReturn<TArgs, TResult>;
43
-
44
- export { useAction };
45
- export type { UseActionOptions, UseActionReturn, UseActionStatus };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- const useAirdrop = require('./shared/vue.B4eMoJT2.cjs');
4
- require('./shared/vue.CoaIWGPT.cjs');
5
- require('@vue-solana/core/action');
6
- require('vue');
7
- require('./shared/vue.4C5kX4fE.cjs');
8
- require('./shared/vue.BIxphCAq.cjs');
9
- require('./shared/vue.DE3emjSF.cjs');
10
- require('./shared/vue.DEHxNvUX.cjs');
11
-
12
-
13
-
14
- exports.useAirdrop = useAirdrop.useAirdrop;
@@ -1,27 +0,0 @@
1
- import { Address, Lamports, Signature } from '@vue-solana/core/kit';
2
- import { UseActionReturn } from './useAction.cjs';
3
- import 'vue';
4
-
5
- /**
6
- * Airdrops SOL into an account. Each `dispatch(address, amount)` runs the
7
- * airdrop with a fresh `AbortSignal`; calling `dispatch` again while a call is
8
- * in flight aborts the previous one.
9
- *
10
- * Requires the client to expose an `airdrop` capability, typically installed
11
- * with the RPC airdrop plugin, e.g.
12
- * `createClient().use(solanaRpc({ ... })).use(rpcAirdrop())` from
13
- * `@solana/kit-plugin-rpc`. `solanaRpc()` is required rather than the
14
- * read-only `solanaRpcConnection()`: an airdrop signs a request, so the
15
- * client needs a `payer`. The capability is commonly available on test
16
- * networks (devnet, testnet) and local validators.
17
- *
18
- * Some implementations (e.g. LiteSVM) update balances directly without sending
19
- * a transaction, in which case the resolved `data` is `undefined` rather than
20
- * a {@link Signature}.
21
- */
22
- declare function useAirdrop(): UseActionReturn<[
23
- address: Address,
24
- amount: Lamports
25
- ], Signature | undefined>;
26
-
27
- export { useAirdrop };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- const useBalance = require('./shared/vue.E_npPFoV.cjs');
4
- require('@vue-solana/core/address');
5
- require('@vue-solana/core/errors');
6
- require('vue');
7
- require('./shared/vue.BVaMoz9y.cjs');
8
- require('./shared/vue.BIxphCAq.cjs');
9
- require('./shared/vue.DE3emjSF.cjs');
10
- require('./shared/vue.DEHxNvUX.cjs');
11
-
12
-
13
-
14
- exports.useBalance = useBalance.useBalance;
@@ -1,15 +0,0 @@
1
- import * as vue from 'vue';
2
- import { MaybeRefOrGetter } from 'vue';
3
- import { Commitment } from '@vue-solana/core/kit';
4
- import { SolanaError } from '@vue-solana/core/errors';
5
-
6
- type BalanceInput = string | null | undefined;
7
- declare function useBalance(address: MaybeRefOrGetter<BalanceInput>, commitment?: Commitment): {
8
- balance: vue.ShallowRef<number | null, number | null>;
9
- loading: vue.ShallowRef<boolean, boolean>;
10
- error: vue.ShallowRef<SolanaError | null, SolanaError | null>;
11
- refresh: () => Promise<number | null>;
12
- };
13
-
14
- export { useBalance };
15
- export type { BalanceInput };
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- const useClientCapability = require('./shared/vue.4C5kX4fE.cjs');
4
- require('./shared/vue.BIxphCAq.cjs');
5
- require('./shared/vue.DE3emjSF.cjs');
6
- require('vue');
7
- require('./shared/vue.DEHxNvUX.cjs');
8
-
9
-
10
-
11
- exports.MissingClientCapabilityError = useClientCapability.MissingClientCapabilityError;
12
- exports.useClientCapability = useClientCapability.useClientCapability;
@@ -1,39 +0,0 @@
1
- /**
2
- * Thrown by {@link useClientCapability} when the installed Solana client does
3
- * not expose a requested capability.
4
- */
5
- declare class MissingClientCapabilityError extends Error {
6
- /** Name of the hook that requested the capability, e.g. `usePayer`. */
7
- readonly hookName: string;
8
- /** Human guidance for installing the capability on the client. */
9
- readonly providerHint: string;
10
- /** The missing capability name(s). */
11
- readonly capabilities: readonly string[];
12
- constructor(hookName: string, capabilities: readonly string[], providerHint: string);
13
- }
14
- interface UseClientCapabilityOptions {
15
- /**
16
- * Name of the calling hook for error messages (defaults to
17
- * `useClientCapability`).
18
- */
19
- hookName?: string;
20
- /**
21
- * Guidance appended to the error when a capability is missing, e.g. which
22
- * `@solana/kit` plugin to `.use()`.
23
- */
24
- providerHint?: string;
25
- }
26
- /**
27
- * Runtime assertion that a capability is installed on the (loosely-typed)
28
- * Solana client. Throws a {@link MissingClientCapabilityError} — naming the
29
- * calling hook and how to install the capability — if any requested
30
- * capability is missing. Accepts one capability name or an array.
31
- *
32
- * The assertion runs synchronously during setup (the first step of mount),
33
- * so a misconfigured client fails fast with a clear error instead of a
34
- * cryptic `undefined is not a function` later on.
35
- */
36
- declare function useClientCapability(capability: string | readonly string[], options?: UseClientCapabilityOptions): void;
37
-
38
- export { MissingClientCapabilityError, useClientCapability };
39
- export type { UseClientCapabilityOptions };
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- const useConnection = require('./shared/vue.BVaMoz9y.cjs');
4
- require('./shared/vue.BIxphCAq.cjs');
5
- require('./shared/vue.DE3emjSF.cjs');
6
- require('vue');
7
- require('./shared/vue.DEHxNvUX.cjs');
8
-
9
-
10
-
11
- exports.useConnection = useConnection.useConnection;