@tagadapay/plugin-sdk 2.8.10 → 3.0.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.
Files changed (51) hide show
  1. package/README.md +14 -14
  2. package/dist/index.js +1 -1
  3. package/dist/react/hooks/usePluginConfig.d.ts +1 -0
  4. package/dist/react/hooks/usePluginConfig.js +69 -18
  5. package/dist/react/providers/TagadaProvider.js +1 -4
  6. package/dist/v2/core/client.d.ts +18 -0
  7. package/dist/v2/core/client.js +45 -0
  8. package/dist/v2/core/config/environment.d.ts +8 -0
  9. package/dist/v2/core/config/environment.js +18 -0
  10. package/dist/v2/core/funnelClient.d.ts +84 -0
  11. package/dist/v2/core/funnelClient.js +252 -0
  12. package/dist/v2/core/index.d.ts +2 -0
  13. package/dist/v2/core/index.js +3 -0
  14. package/dist/v2/core/resources/apiClient.js +1 -1
  15. package/dist/v2/core/resources/funnel.d.ts +1 -0
  16. package/dist/v2/core/resources/offers.d.ts +182 -8
  17. package/dist/v2/core/resources/offers.js +25 -0
  18. package/dist/v2/core/resources/products.d.ts +5 -0
  19. package/dist/v2/core/resources/products.js +15 -1
  20. package/dist/v2/core/types.d.ts +1 -0
  21. package/dist/v2/core/utils/funnelQueryKeys.d.ts +23 -0
  22. package/dist/v2/core/utils/funnelQueryKeys.js +23 -0
  23. package/dist/v2/core/utils/index.d.ts +2 -0
  24. package/dist/v2/core/utils/index.js +2 -0
  25. package/dist/v2/core/utils/pluginConfig.js +44 -32
  26. package/dist/v2/core/utils/sessionStorage.d.ts +20 -0
  27. package/dist/v2/core/utils/sessionStorage.js +39 -0
  28. package/dist/v2/index.d.ts +4 -2
  29. package/dist/v2/index.js +1 -1
  30. package/dist/v2/react/components/DebugDrawer.js +99 -2
  31. package/dist/v2/react/hooks/__examples__/FunnelContextExample.d.ts +3 -0
  32. package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +4 -3
  33. package/dist/v2/react/hooks/useClubOffers.d.ts +2 -2
  34. package/dist/v2/react/hooks/useFunnel.d.ts +27 -39
  35. package/dist/v2/react/hooks/useFunnel.js +22 -659
  36. package/dist/v2/react/hooks/useFunnelLegacy.d.ts +52 -0
  37. package/dist/v2/react/hooks/useFunnelLegacy.js +733 -0
  38. package/dist/v2/react/hooks/useOfferQuery.d.ts +109 -0
  39. package/dist/v2/react/hooks/useOfferQuery.js +483 -0
  40. package/dist/v2/react/hooks/useOffersQuery.d.ts +9 -75
  41. package/dist/v2/react/hooks/useProductsQuery.d.ts +1 -0
  42. package/dist/v2/react/hooks/useProductsQuery.js +10 -6
  43. package/dist/v2/react/index.d.ts +8 -4
  44. package/dist/v2/react/index.js +4 -2
  45. package/dist/v2/react/providers/TagadaProvider.d.ts +66 -5
  46. package/dist/v2/react/providers/TagadaProvider.js +120 -6
  47. package/dist/v2/standalone/index.d.ts +20 -0
  48. package/dist/v2/standalone/index.js +22 -0
  49. package/dist/v2/vue/index.d.ts +6 -0
  50. package/dist/v2/vue/index.js +10 -0
  51. package/package.json +6 -1
@@ -5,6 +5,7 @@
5
5
  import { Product, ProductVariant } from '../../core/resources/products';
6
6
  export interface UseProductsQueryOptions {
7
7
  productIds?: string[];
8
+ variantIds?: string[];
8
9
  enabled?: boolean;
9
10
  includeVariants?: boolean;
10
11
  includePrices?: boolean;
@@ -8,7 +8,7 @@ import { ProductsResource } from '../../core/resources/products';
8
8
  import { getGlobalApiClient } from './useApiQuery';
9
9
  import { usePluginConfig } from './usePluginConfig';
10
10
  export function useProductsQuery(options = {}) {
11
- const { productIds = [], enabled = true, includeVariants = true, includePrices = true } = options;
11
+ const { productIds = [], variantIds = [], enabled = true, includeVariants = true, includePrices = true } = options;
12
12
  const { storeId } = usePluginConfig();
13
13
  // Create products resource client
14
14
  const productsResource = useMemo(() => {
@@ -20,7 +20,7 @@ export function useProductsQuery(options = {}) {
20
20
  }
21
21
  }, []);
22
22
  // Create query key based on options
23
- const queryKey = useMemo(() => ['products', { storeId, productIds, includeVariants, includePrices }], [storeId, productIds, includeVariants, includePrices]);
23
+ const queryKey = useMemo(() => ['products', { storeId, productIds, variantIds, includeVariants, includePrices }], [storeId, productIds, variantIds, includeVariants, includePrices]);
24
24
  // Use TanStack Query for fetching products
25
25
  const { data: products = [], isLoading, error, refetch } = useQuery({
26
26
  queryKey,
@@ -29,18 +29,22 @@ export function useProductsQuery(options = {}) {
29
29
  if (!storeId) {
30
30
  throw new Error('Store ID not found. Make sure the TagadaProvider is properly configured.');
31
31
  }
32
- const options = {
32
+ const baseOptions = {
33
33
  storeId,
34
34
  includeVariants,
35
35
  includePrices,
36
36
  };
37
- if (productIds.length > 0) {
37
+ if (variantIds.length > 0) {
38
+ // Fetch products by variant IDs (most efficient)
39
+ return await productsResource.getProductsByVariantIds(variantIds, baseOptions);
40
+ }
41
+ else if (productIds.length > 0) {
38
42
  // Fetch specific products
39
- return await productsResource.getProductsByIds(productIds, options);
43
+ return await productsResource.getProductsByIds(productIds, baseOptions);
40
44
  }
41
45
  else {
42
46
  // Fetch all products for the store
43
- return await productsResource.getProducts(options);
47
+ return await productsResource.getProducts(baseOptions);
44
48
  }
45
49
  },
46
50
  staleTime: 5 * 60 * 1000, // 5 minutes
@@ -4,6 +4,7 @@
4
4
  */
5
5
  export { ExpressPaymentMethodsProvider } from './providers/ExpressPaymentMethodsProvider';
6
6
  export { TagadaProvider, useTagadaContext } from './providers/TagadaProvider';
7
+ export type { DebugScript } from './providers/TagadaProvider';
7
8
  export { ApplePayButton } from './components/ApplePayButton';
8
9
  export { GooglePayButton } from './components/GooglePayButton';
9
10
  export { useAuth } from './hooks/useAuth';
@@ -25,7 +26,7 @@ export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQ
25
26
  export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
26
27
  export { useCurrency } from './hooks/useCurrency';
27
28
  export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
28
- export { useOffersQuery as useOffers } from './hooks/useOffersQuery';
29
+ export { useOfferQuery as useOffer } from './hooks/useOfferQuery';
29
30
  export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
30
31
  export { useOrderQuery as useOrder } from './hooks/useOrderQuery';
31
32
  export { usePaymentQuery as usePayment } from './hooks/usePaymentQuery';
@@ -38,7 +39,8 @@ export { useThreeds } from './hooks/useThreeds';
38
39
  export { useThreedsModal } from './hooks/useThreedsModal';
39
40
  export { useTranslation } from './hooks/useTranslation';
40
41
  export { useVipOffersQuery as useVipOffers } from './hooks/useVipOffersQuery';
41
- export { useFunnel, useSimpleFunnel } from './hooks/useFunnel';
42
+ export { useFunnel } from './hooks/useFunnel';
43
+ export { useFunnel as useFunnelLegacy, useSimpleFunnel } from './hooks/useFunnelLegacy';
42
44
  export type { UseCheckoutTokenOptions, UseCheckoutTokenResult } from './hooks/useCheckoutToken';
43
45
  export type { ClubOffer, ClubOfferItem, ClubOfferLineItem, ClubOfferSummary, UseClubOffersOptions, UseClubOffersResult } from './hooks/useClubOffers';
44
46
  export type { UseCreditsOptions, UseCreditsResult } from './hooks/useCredits';
@@ -58,8 +60,10 @@ export type { TranslateFunction, UseTranslationOptions, UseTranslationResult } f
58
60
  export { FunnelActionType } from '../core/resources/funnel';
59
61
  export type { UseCheckoutQueryOptions as UseCheckoutOptions, UseCheckoutQueryResult as UseCheckoutResult } from './hooks/useCheckoutQuery';
60
62
  export type { UseDiscountsQueryOptions as UseDiscountsOptions, UseDiscountsQueryResult as UseDiscountsResult } from './hooks/useDiscountsQuery';
61
- export type { FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext, UseFunnelOptions, UseFunnelResult } from './hooks/useFunnel';
62
- export type { UseOffersQueryOptions as UseOffersOptions, UseOffersQueryResult as UseOffersResult } from './hooks/useOffersQuery';
63
+ export type { FunnelAction, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext } from '../core/resources/funnel';
64
+ export type { FunnelContextValue } from './hooks/useFunnel';
65
+ export type { UseFunnelOptions as UseFunnelLegacyOptions, UseFunnelResult as UseFunnelLegacyResult } from './hooks/useFunnelLegacy';
66
+ export type { AvailableVariant, LineItemSelection, OfferLineItem, OfferPreviewSummary, UseOfferQueryOptions as UseOfferOptions, UseOfferQueryResult as UseOfferResult } from './hooks/useOfferQuery';
63
67
  export type { UseOrderBumpQueryOptions as UseOrderBumpOptions, UseOrderBumpQueryResult as UseOrderBumpResult } from './hooks/useOrderBumpQuery';
64
68
  export type { UseOrderQueryOptions as UseOrderOptions, UseOrderQueryResult as UseOrderResult } from './hooks/useOrderQuery';
65
69
  export type { PaymentHook as UsePaymentResult } from './hooks/usePaymentQuery';
@@ -29,7 +29,7 @@ export { queryKeys, useApiMutation, useApiQuery, useInvalidateQuery, usePreloadQ
29
29
  export { useCheckoutQuery as useCheckout } from './hooks/useCheckoutQuery';
30
30
  export { useCurrency } from './hooks/useCurrency';
31
31
  export { useDiscountsQuery as useDiscounts } from './hooks/useDiscountsQuery';
32
- export { useOffersQuery as useOffers } from './hooks/useOffersQuery';
32
+ export { useOfferQuery as useOffer } from './hooks/useOfferQuery';
33
33
  export { useOrderBumpQuery as useOrderBump } from './hooks/useOrderBumpQuery';
34
34
  export { useOrderQuery as useOrder } from './hooks/useOrderQuery';
35
35
  export { usePaymentQuery as usePayment } from './hooks/usePaymentQuery';
@@ -43,7 +43,9 @@ export { useThreedsModal } from './hooks/useThreedsModal';
43
43
  export { useTranslation } from './hooks/useTranslation';
44
44
  export { useVipOffersQuery as useVipOffers } from './hooks/useVipOffersQuery';
45
45
  // Funnel hooks
46
- export { useFunnel, useSimpleFunnel } from './hooks/useFunnel';
46
+ export { useFunnel } from './hooks/useFunnel';
47
+ // Legacy funnel hooks (deprecated - use TagadaProvider + useFunnel instead)
48
+ export { useFunnel as useFunnelLegacy, useSimpleFunnel } from './hooks/useFunnelLegacy';
47
49
  // TanStack Query types
48
50
  export { FunnelActionType } from '../core/resources/funnel';
49
51
  // Re-export utilities from main react
@@ -1,11 +1,43 @@
1
1
  import { ReactNode } from 'react';
2
- import { TagadaState } from '../../core/client';
3
- import { RawPluginConfig } from '../../core/utils/pluginConfig';
4
- import { Environment, EnvironmentConfig } from '../../core/types';
5
2
  import { ApiService } from '../../../react/services/apiService';
6
- import { formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, convertCurrency } from '../../../react/utils/money';
3
+ import { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits } from '../../../react/utils/money';
4
+ import { TagadaClient, TagadaClientConfig, TagadaState } from '../../core/client';
5
+ import { FunnelState } from '../../core/funnelClient';
6
+ import { FunnelAction, FunnelNavigationResult, SimpleFunnelContext } from '../../core/resources/funnel';
7
+ import { Environment, EnvironmentConfig } from '../../core/types';
8
+ import { RawPluginConfig } from '../../core/utils/pluginConfig';
9
+ /**
10
+ * Debug Script Definition
11
+ * Templates can provide debug scripts that will appear in the Debug Drawer "Scripts" tab
12
+ */
13
+ export interface DebugScript {
14
+ /** Unique identifier for the script */
15
+ id: string;
16
+ /** Display name shown in the Scripts tab */
17
+ name: string;
18
+ /** Optional description of what the script does */
19
+ description?: string;
20
+ /** The function to execute when the script is run */
21
+ run: (context: TagadaContextValue) => void | Promise<void>;
22
+ /** Optional category to group scripts */
23
+ category?: string;
24
+ }
7
25
  interface TagadaContextValue extends TagadaState {
26
+ client: TagadaClient;
8
27
  apiService: ApiService;
28
+ pendingRedirect: boolean;
29
+ funnel: FunnelState & {
30
+ currentStep: {
31
+ id: string;
32
+ } | null;
33
+ next: (event: FunnelAction) => Promise<FunnelNavigationResult>;
34
+ goToStep: (stepId: string) => Promise<FunnelNavigationResult>;
35
+ updateContext: (updates: Partial<SimpleFunnelContext>) => Promise<void>;
36
+ initializeSession: (entryStepId?: string) => Promise<void>;
37
+ endSession: () => Promise<void>;
38
+ retryInitialization: () => Promise<void>;
39
+ refetch: () => Promise<void>;
40
+ };
9
41
  debugCheckout: {
10
42
  isActive: boolean;
11
43
  data: any;
@@ -22,6 +54,7 @@ interface TagadaContextValue extends TagadaState {
22
54
  lastUpdated: Date | null;
23
55
  };
24
56
  updateFunnelDebugData: (data: any, error?: Error | null, isLoading?: boolean) => void;
57
+ debugScripts: DebugScript[];
25
58
  refreshCoordinator: {
26
59
  registerCheckoutRefresh: (refreshFn: () => Promise<void>, name?: string) => void;
27
60
  registerOrderBumpRefresh: (refreshFn: () => Promise<void>) => void;
@@ -53,8 +86,36 @@ interface TagadaProviderProps {
53
86
  localConfig?: string;
54
87
  blockUntilSessionReady?: boolean;
55
88
  rawPluginConfig?: RawPluginConfig;
89
+ /**
90
+ * Optional feature flags to enable/disable subsystems (e.g. funnel).
91
+ * By default all features are enabled.
92
+ */
93
+ features?: TagadaClientConfig['features'];
94
+ /**
95
+ * Funnel ID to initialize. If not provided, will be detected from URL query param.
96
+ */
97
+ funnelId?: string;
98
+ /**
99
+ * Auto-initialize funnel session when auth and store are ready.
100
+ * Default: true
101
+ */
102
+ autoInitializeFunnel?: boolean;
103
+ /**
104
+ * Callback fired after funnel navigation
105
+ */
106
+ onNavigate?: (result: FunnelNavigationResult) => void | boolean;
107
+ /**
108
+ * Callback fired on funnel errors
109
+ */
110
+ onFunnelError?: (error: Error) => void;
111
+ /**
112
+ * Debug scripts provided by the template.
113
+ * These will appear in the Debug Drawer "Scripts" tab when debugMode is enabled.
114
+ * Only shown if the array is not empty.
115
+ */
116
+ debugScripts?: DebugScript[];
56
117
  }
57
118
  export declare function TagadaProvider({ children, environment, customApiConfig, // Ignored for now in TagadaClient, or need to add support
58
- debugMode, localConfig, blockUntilSessionReady, rawPluginConfig, }: TagadaProviderProps): import("react/jsx-runtime").JSX.Element;
119
+ debugMode, localConfig, blockUntilSessionReady, rawPluginConfig, features, funnelId, autoInitializeFunnel, onNavigate, onFunnelError, debugScripts, }: TagadaProviderProps): import("react/jsx-runtime").JSX.Element;
59
120
  export declare function useTagadaContext(): TagadaContextValue;
60
121
  export {};
@@ -4,10 +4,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
4
4
  * TagadaProvider - Main provider component for the Tagada Pay React SDK
5
5
  */
6
6
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
7
- import { createContext, useCallback, useContext, useEffect, useMemo, useState, useRef, } from 'react';
8
- import { TagadaClient } from '../../core/client';
7
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
9
8
  import { ApiService } from '../../../react/services/apiService';
10
- import { formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, convertCurrency, } from '../../../react/utils/money';
9
+ import { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, } from '../../../react/utils/money';
10
+ import { TagadaClient } from '../../core/client';
11
11
  import { default as DebugDrawer } from '../components/DebugDrawer';
12
12
  import { setGlobalApiClient } from '../hooks/useApiQuery';
13
13
  // Professional, subtle loading component for initialization
@@ -44,18 +44,27 @@ const InitializationLoader = () => (_jsxs("div", { style: {
44
44
  ` })] }));
45
45
  const TagadaContext = createContext(null);
46
46
  export function TagadaProvider({ children, environment, customApiConfig, // Ignored for now in TagadaClient, or need to add support
47
- debugMode, localConfig, blockUntilSessionReady = false, rawPluginConfig, }) {
47
+ debugMode, localConfig, blockUntilSessionReady = false, rawPluginConfig, features, funnelId, autoInitializeFunnel = true, onNavigate, onFunnelError, debugScripts = [], }) {
48
+ // Auto-detect debug mode from environment if not explicitly set
49
+ const effectiveDebugMode = debugMode !== undefined
50
+ ? debugMode
51
+ : (typeof import.meta !== 'undefined' && import.meta.env?.DEV) ||
52
+ (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development');
48
53
  // Initialize client
49
54
  const client = useMemo(() => {
50
55
  const config = {
51
56
  environment,
52
- debugMode,
57
+ debugMode: effectiveDebugMode,
53
58
  localConfig,
54
59
  rawPluginConfig,
55
60
  blockUntilSessionReady,
61
+ // For now we always enable funnel by default; callers can disable via features if needed
62
+ features: features ?? {
63
+ funnel: true,
64
+ },
56
65
  };
57
66
  return new TagadaClient(config);
58
- }, []); // Singleton behavior
67
+ }, []); // Singleton behavior on first render
59
68
  // State Sync
60
69
  const [state, setState] = useState(client.getState());
61
70
  useEffect(() => {
@@ -82,6 +91,32 @@ debugMode, localConfig, blockUntilSessionReady = false, rawPluginConfig, }) {
82
91
  apiService.updateToken(state.token);
83
92
  apiService.updateConfig(state.environment);
84
93
  }, [state.token, state.environment, apiService]);
94
+ // Funnel State Management
95
+ const [funnelState, setFunnelState] = useState(() => client.funnel
96
+ ? client.funnel.getState()
97
+ : {
98
+ context: null,
99
+ isLoading: false,
100
+ isInitialized: false,
101
+ isNavigating: false,
102
+ error: null,
103
+ sessionError: null,
104
+ });
105
+ // Track pending redirect to prevent renders during navigation
106
+ const [pendingRedirect, setPendingRedirect] = useState(false);
107
+ // Subscribe to funnel state changes
108
+ useEffect(() => {
109
+ if (!client.funnel)
110
+ return;
111
+ // Keep funnel client in sync with latest config/environment
112
+ client.funnel.setConfig({
113
+ pluginConfig: state.pluginConfig,
114
+ environment: state.environment,
115
+ });
116
+ return client.funnel.subscribe(setFunnelState);
117
+ }, [client, state.pluginConfig, state.environment]);
118
+ // Note: Funnel auto-initialization is now handled by TagadaClient itself
119
+ // when the session is initialized. This happens automatically in the core layer.
85
120
  // Debug State (React specific)
86
121
  const [debugCheckout, setDebugCheckout] = useState({
87
122
  isActive: false,
@@ -160,13 +195,92 @@ debugMode, localConfig, blockUntilSessionReady = false, rawPluginConfig, }) {
160
195
  formatSimpleMoney,
161
196
  }), []);
162
197
  const [isDebugDrawerOpen, setIsDebugDrawerOpen] = useState(false);
198
+ // Funnel Methods
199
+ const funnelMethods = useMemo(() => {
200
+ if (!client.funnel) {
201
+ // Return no-op methods if funnel is disabled
202
+ const noopAsync = async () => {
203
+ throw new Error('Funnel feature is disabled');
204
+ };
205
+ return {
206
+ next: noopAsync,
207
+ goToStep: noopAsync,
208
+ updateContext: noopAsync,
209
+ initializeSession: noopAsync,
210
+ endSession: noopAsync,
211
+ retryInitialization: noopAsync,
212
+ refetch: noopAsync,
213
+ };
214
+ }
215
+ const next = async (event) => {
216
+ const result = await client.funnel.navigate(event);
217
+ // Call custom onNavigate handler if provided
218
+ let shouldAutoRedirect = true;
219
+ if (onNavigate) {
220
+ const handlerResult = onNavigate(result);
221
+ // If handler explicitly returns false, skip auto-redirect
222
+ if (handlerResult === false) {
223
+ shouldAutoRedirect = false;
224
+ }
225
+ }
226
+ // Default behavior: auto-redirect if result has a URL
227
+ if (shouldAutoRedirect && result?.url && typeof window !== 'undefined') {
228
+ console.log('🚀 [TagadaProvider] Auto-redirecting to:', result.url);
229
+ // Set pending redirect flag BEFORE navigation to prevent renders
230
+ setPendingRedirect(true);
231
+ window.location.href = result.url;
232
+ }
233
+ return result;
234
+ };
235
+ const goToStep = async (stepId) => {
236
+ return await next({
237
+ type: 'DIRECT_NAVIGATION',
238
+ data: { targetStepId: stepId },
239
+ });
240
+ };
241
+ // Helper to resolve accountId with fallbacks
242
+ const getAccountId = () => state.store?.accountId || state.pluginConfig?.accountId || state.session?.accountId || '';
243
+ return {
244
+ next,
245
+ goToStep,
246
+ updateContext: (updates) => client.funnel.updateContext(updates),
247
+ initializeSession: async (entryStepId) => {
248
+ const accountId = getAccountId();
249
+ if (!accountId || !state.auth.session || !state.store) {
250
+ throw new Error('Cannot initialize funnel: missing required data (accountId, session, or store)');
251
+ }
252
+ await client.funnel.initialize({ customerId: state.auth.session.customerId, sessionId: state.auth.session.sessionId }, { id: state.store.id, accountId }, funnelId, entryStepId);
253
+ },
254
+ endSession: () => client.funnel.endSession(),
255
+ retryInitialization: () => {
256
+ const accountId = getAccountId();
257
+ if (!accountId || !state.auth.session || !state.store) {
258
+ return Promise.reject(new Error('Cannot retry initialization: missing required data'));
259
+ }
260
+ return client
261
+ .funnel.autoInitialize({ customerId: state.auth.session.customerId, sessionId: state.auth.session.sessionId }, { id: state.store.id, accountId }, funnelId)
262
+ .then(() => { });
263
+ },
264
+ refetch: async () => {
265
+ await client.funnel.refreshSession();
266
+ },
267
+ };
268
+ }, [client, state.auth.session, state.store, funnelId, onNavigate]);
163
269
  const contextValue = {
270
+ client,
164
271
  ...state,
165
272
  apiService,
273
+ pendingRedirect,
274
+ funnel: {
275
+ ...funnelState,
276
+ currentStep: funnelState.context?.currentStepId ? { id: funnelState.context.currentStepId } : null,
277
+ ...funnelMethods,
278
+ },
166
279
  debugCheckout,
167
280
  updateCheckoutDebugData,
168
281
  debugFunnel,
169
282
  updateFunnelDebugData,
283
+ debugScripts,
170
284
  refreshCoordinator,
171
285
  money: moneyUtils,
172
286
  };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Standalone Adapter for TagadaPay SDK v2
3
+ *
4
+ * Provides a vanilla JS interface for using the SDK without a framework.
5
+ * Suitable for standard HTML/JS sites or other frameworks (Svelte, Angular, etc).
6
+ *
7
+ * This layer is a very thin wrapper over the Core SDK.
8
+ */
9
+ import { TagadaClient, TagadaClientConfig, TagadaState } from '../core/client';
10
+ import { ApiClient } from '../core/resources/apiClient';
11
+ /**
12
+ * Factory function to create a Tagada Client instance.
13
+ * Features (like funnel) can be toggled via the config.
14
+ */
15
+ export declare function createTagadaClient(config?: TagadaClientConfig): TagadaClient;
16
+ export { TagadaClient, ApiClient };
17
+ export type { TagadaClientConfig, TagadaState };
18
+ export { FunnelActionType } from '../core/resources/funnel';
19
+ export type { FunnelAction, FunnelNavigationResult, SimpleFunnelContext } from '../core/resources/funnel';
20
+ export * from '../core/utils';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Standalone Adapter for TagadaPay SDK v2
3
+ *
4
+ * Provides a vanilla JS interface for using the SDK without a framework.
5
+ * Suitable for standard HTML/JS sites or other frameworks (Svelte, Angular, etc).
6
+ *
7
+ * This layer is a very thin wrapper over the Core SDK.
8
+ */
9
+ import { TagadaClient } from '../core/client';
10
+ import { ApiClient } from '../core/resources/apiClient';
11
+ /**
12
+ * Factory function to create a Tagada Client instance.
13
+ * Features (like funnel) can be toggled via the config.
14
+ */
15
+ export function createTagadaClient(config = {}) {
16
+ return new TagadaClient(config);
17
+ }
18
+ // Re-export Core Classes
19
+ export { TagadaClient, ApiClient };
20
+ export { FunnelActionType } from '../core/resources/funnel';
21
+ // Re-export Utilities
22
+ export * from '../core/utils';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Vue.js Adapter for TagadaPay SDK
3
+ *
4
+ * Provides Vue composables that wrap the Core SDK logic.
5
+ * Uses Vue's reactivity system to expose state from TagadaClient and FunnelClient.
6
+ */
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Vue.js Adapter for TagadaPay SDK
4
+ *
5
+ * Provides Vue composables that wrap the Core SDK logic.
6
+ * Uses Vue's reactivity system to expose state from TagadaClient and FunnelClient.
7
+ */
8
+ // TODO: Implement Vue adapter
9
+ // export function useTagada() { ... }
10
+ // export function useFunnel() { ... }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.8.10",
3
+ "version": "3.0.2",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,6 +19,11 @@
19
19
  "types": "./dist/v2/index.d.ts",
20
20
  "import": "./dist/v2/index.js",
21
21
  "require": "./dist/v2/index.js"
22
+ },
23
+ "./v2/standalone": {
24
+ "types": "./dist/v2/standalone/index.d.ts",
25
+ "import": "./dist/v2/standalone/index.js",
26
+ "require": "./dist/v2/standalone/index.js"
22
27
  }
23
28
  },
24
29
  "scripts": {