@voyage_ai/v402-web-ts 0.1.0 → 0.1.2
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 +639 -1
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +600 -229
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +600 -229
- package/dist/index.mjs.map +1 -1
- package/dist/react/components/WalletConnect.tsx +47 -20
- package/dist/react/hooks/usePaymentInfo.ts +38 -4
- package/dist/react/hooks/useWallet.ts +35 -8
- package/dist/react/index.d.mts +16 -55
- package/dist/react/index.d.ts +16 -55
- package/dist/react/index.js +270 -399
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +272 -400
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/index.ts +5 -9
- package/dist/react/store/walletStore.ts +29 -0
- package/dist/react/styles/inline-styles.ts +238 -0
- package/dist/react/styles.css +8 -1
- package/package.json +8 -6
- package/dist/react/components/PaymentButton.tsx +0 -112
package/dist/react/index.d.mts
CHANGED
|
@@ -143,6 +143,7 @@ interface UsePaymentInfoReturn {
|
|
|
143
143
|
*
|
|
144
144
|
* @param endpoint - API endpoint to fetch payment info from
|
|
145
145
|
* @param merchantId - @see our website to apply
|
|
146
|
+
* @param additionalParams - Optional additional parameters to send with the request (default: {})
|
|
146
147
|
*
|
|
147
148
|
* @example
|
|
148
149
|
* ```tsx
|
|
@@ -159,13 +160,25 @@ interface UsePaymentInfoReturn {
|
|
|
159
160
|
* );
|
|
160
161
|
* }
|
|
161
162
|
* ```
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```tsx
|
|
166
|
+
* // With additional parameters
|
|
167
|
+
* function PaymentInfo() {
|
|
168
|
+
* const { paymentInfo } = usePaymentInfo(
|
|
169
|
+
* 'merchant-id',
|
|
170
|
+
* '/api/protected',
|
|
171
|
+
* { userId: '123', customField: 'value' }
|
|
172
|
+
* );
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
162
175
|
*/
|
|
163
|
-
declare function usePaymentInfo(merchantId: string, endpoint?: string): UsePaymentInfoReturn;
|
|
176
|
+
declare function usePaymentInfo(merchantId: string, endpoint?: string, additionalParams?: Record<string, any>): UsePaymentInfoReturn;
|
|
164
177
|
|
|
165
178
|
/**
|
|
166
179
|
* WalletConnect Component
|
|
167
180
|
*
|
|
168
|
-
* Pre-built wallet connection UI component
|
|
181
|
+
* Pre-built wallet connection UI component with inline styles
|
|
169
182
|
*/
|
|
170
183
|
|
|
171
184
|
interface WalletConnectProps {
|
|
@@ -193,56 +206,4 @@ interface WalletConnectProps {
|
|
|
193
206
|
*/
|
|
194
207
|
declare function WalletConnect({ supportedNetworks, className, onConnect, onDisconnect, }: WalletConnectProps): React.JSX.Element;
|
|
195
208
|
|
|
196
|
-
|
|
197
|
-
* PaymentButton Component
|
|
198
|
-
*
|
|
199
|
-
* Pre-built payment button component
|
|
200
|
-
* Note: This is a simple wrapper. For complex payment flows,
|
|
201
|
-
* use the SDK directly with usePayment hook for full control.
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
interface PaymentButtonProps {
|
|
205
|
-
endpoint: string;
|
|
206
|
-
className?: string;
|
|
207
|
-
disabled?: boolean;
|
|
208
|
-
onSuccess?: (result: any) => void;
|
|
209
|
-
onError?: (error: string) => void;
|
|
210
|
-
onStart?: () => void;
|
|
211
|
-
onFinish?: () => void;
|
|
212
|
-
children?: React.ReactNode;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Simple pre-built payment button
|
|
216
|
-
*
|
|
217
|
-
* For complex payment flows, use the SDK directly:
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* ```tsx
|
|
221
|
-
* import { useWallet, usePayment } from '../react';
|
|
222
|
-
* import { handleSvmPayment } from '@/app/sdk';
|
|
223
|
-
*
|
|
224
|
-
* function CustomPayment() {
|
|
225
|
-
* const { networkType } = useWallet();
|
|
226
|
-
* const { isProcessing, setIsProcessing, setResult, setError } = usePayment();
|
|
227
|
-
*
|
|
228
|
-
* const handlePay = async () => {
|
|
229
|
-
* setIsProcessing(true);
|
|
230
|
-
* try {
|
|
231
|
-
* // Your custom logic before payment
|
|
232
|
-
* const response = await handleSvmPayment(...);
|
|
233
|
-
* const data = await response.json();
|
|
234
|
-
*
|
|
235
|
-
* // Your custom logic after payment
|
|
236
|
-
* setResult(data);
|
|
237
|
-
* } catch (err) {
|
|
238
|
-
* setError(err.message);
|
|
239
|
-
* } finally {
|
|
240
|
-
* setIsProcessing(false);
|
|
241
|
-
* }
|
|
242
|
-
* };
|
|
243
|
-
* }
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
declare function PaymentButton({ endpoint, className, disabled, onSuccess, onError, onStart, onFinish, children, }: PaymentButtonProps): React.JSX.Element;
|
|
247
|
-
|
|
248
|
-
export { PaymentButton, type PaymentButtonProps, type UsePaymentInfoReturn, type UsePaymentReturn, type UseWalletReturn, WalletConnect, type WalletConnectProps, usePayment, usePaymentInfo, useWallet };
|
|
209
|
+
export { type UsePaymentInfoReturn, type UsePaymentReturn, type UseWalletReturn, WalletConnect, type WalletConnectProps, usePayment, usePaymentInfo, useWallet };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -143,6 +143,7 @@ interface UsePaymentInfoReturn {
|
|
|
143
143
|
*
|
|
144
144
|
* @param endpoint - API endpoint to fetch payment info from
|
|
145
145
|
* @param merchantId - @see our website to apply
|
|
146
|
+
* @param additionalParams - Optional additional parameters to send with the request (default: {})
|
|
146
147
|
*
|
|
147
148
|
* @example
|
|
148
149
|
* ```tsx
|
|
@@ -159,13 +160,25 @@ interface UsePaymentInfoReturn {
|
|
|
159
160
|
* );
|
|
160
161
|
* }
|
|
161
162
|
* ```
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```tsx
|
|
166
|
+
* // With additional parameters
|
|
167
|
+
* function PaymentInfo() {
|
|
168
|
+
* const { paymentInfo } = usePaymentInfo(
|
|
169
|
+
* 'merchant-id',
|
|
170
|
+
* '/api/protected',
|
|
171
|
+
* { userId: '123', customField: 'value' }
|
|
172
|
+
* );
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
162
175
|
*/
|
|
163
|
-
declare function usePaymentInfo(merchantId: string, endpoint?: string): UsePaymentInfoReturn;
|
|
176
|
+
declare function usePaymentInfo(merchantId: string, endpoint?: string, additionalParams?: Record<string, any>): UsePaymentInfoReturn;
|
|
164
177
|
|
|
165
178
|
/**
|
|
166
179
|
* WalletConnect Component
|
|
167
180
|
*
|
|
168
|
-
* Pre-built wallet connection UI component
|
|
181
|
+
* Pre-built wallet connection UI component with inline styles
|
|
169
182
|
*/
|
|
170
183
|
|
|
171
184
|
interface WalletConnectProps {
|
|
@@ -193,56 +206,4 @@ interface WalletConnectProps {
|
|
|
193
206
|
*/
|
|
194
207
|
declare function WalletConnect({ supportedNetworks, className, onConnect, onDisconnect, }: WalletConnectProps): React.JSX.Element;
|
|
195
208
|
|
|
196
|
-
|
|
197
|
-
* PaymentButton Component
|
|
198
|
-
*
|
|
199
|
-
* Pre-built payment button component
|
|
200
|
-
* Note: This is a simple wrapper. For complex payment flows,
|
|
201
|
-
* use the SDK directly with usePayment hook for full control.
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
interface PaymentButtonProps {
|
|
205
|
-
endpoint: string;
|
|
206
|
-
className?: string;
|
|
207
|
-
disabled?: boolean;
|
|
208
|
-
onSuccess?: (result: any) => void;
|
|
209
|
-
onError?: (error: string) => void;
|
|
210
|
-
onStart?: () => void;
|
|
211
|
-
onFinish?: () => void;
|
|
212
|
-
children?: React.ReactNode;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Simple pre-built payment button
|
|
216
|
-
*
|
|
217
|
-
* For complex payment flows, use the SDK directly:
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* ```tsx
|
|
221
|
-
* import { useWallet, usePayment } from '../react';
|
|
222
|
-
* import { handleSvmPayment } from '@/app/sdk';
|
|
223
|
-
*
|
|
224
|
-
* function CustomPayment() {
|
|
225
|
-
* const { networkType } = useWallet();
|
|
226
|
-
* const { isProcessing, setIsProcessing, setResult, setError } = usePayment();
|
|
227
|
-
*
|
|
228
|
-
* const handlePay = async () => {
|
|
229
|
-
* setIsProcessing(true);
|
|
230
|
-
* try {
|
|
231
|
-
* // Your custom logic before payment
|
|
232
|
-
* const response = await handleSvmPayment(...);
|
|
233
|
-
* const data = await response.json();
|
|
234
|
-
*
|
|
235
|
-
* // Your custom logic after payment
|
|
236
|
-
* setResult(data);
|
|
237
|
-
* } catch (err) {
|
|
238
|
-
* setError(err.message);
|
|
239
|
-
* } finally {
|
|
240
|
-
* setIsProcessing(false);
|
|
241
|
-
* }
|
|
242
|
-
* };
|
|
243
|
-
* }
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
declare function PaymentButton({ endpoint, className, disabled, onSuccess, onError, onStart, onFinish, children, }: PaymentButtonProps): React.JSX.Element;
|
|
247
|
-
|
|
248
|
-
export { PaymentButton, type PaymentButtonProps, type UsePaymentInfoReturn, type UsePaymentReturn, type UseWalletReturn, WalletConnect, type WalletConnectProps, usePayment, usePaymentInfo, useWallet };
|
|
209
|
+
export { type UsePaymentInfoReturn, type UsePaymentReturn, type UseWalletReturn, WalletConnect, type WalletConnectProps, usePayment, usePaymentInfo, useWallet };
|