@tagadapay/plugin-sdk 2.8.8 → 2.8.9

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 (41) hide show
  1. package/dist/react/config/environment.d.ts +1 -22
  2. package/dist/react/config/environment.js +1 -132
  3. package/dist/react/utils/deviceInfo.d.ts +1 -39
  4. package/dist/react/utils/deviceInfo.js +1 -163
  5. package/dist/react/utils/jwtDecoder.d.ts +1 -14
  6. package/dist/react/utils/jwtDecoder.js +1 -86
  7. package/dist/react/utils/tokenStorage.d.ts +1 -16
  8. package/dist/react/utils/tokenStorage.js +1 -53
  9. package/dist/v2/core/client.d.ts +92 -0
  10. package/dist/v2/core/client.js +386 -0
  11. package/dist/v2/core/config/environment.d.ts +22 -0
  12. package/dist/v2/core/config/environment.js +140 -0
  13. package/dist/v2/core/pathRemapping.js +61 -3
  14. package/dist/v2/core/resources/apiClient.d.ts +8 -0
  15. package/dist/v2/core/resources/apiClient.js +30 -9
  16. package/dist/v2/core/resources/funnel.d.ts +14 -0
  17. package/dist/v2/core/resources/payments.d.ts +23 -0
  18. package/dist/v2/core/types.d.ts +271 -0
  19. package/dist/v2/core/types.js +4 -0
  20. package/dist/v2/core/utils/deviceInfo.d.ts +39 -0
  21. package/dist/v2/core/utils/deviceInfo.js +162 -0
  22. package/dist/v2/core/utils/eventDispatcher.d.ts +10 -0
  23. package/dist/v2/core/utils/eventDispatcher.js +24 -0
  24. package/dist/v2/core/utils/jwtDecoder.d.ts +14 -0
  25. package/dist/v2/core/utils/jwtDecoder.js +85 -0
  26. package/dist/v2/core/utils/pluginConfig.js +6 -0
  27. package/dist/v2/core/utils/tokenStorage.d.ts +19 -0
  28. package/dist/v2/core/utils/tokenStorage.js +52 -0
  29. package/dist/v2/react/components/DebugDrawer.js +90 -1
  30. package/dist/v2/react/hooks/__examples__/FunnelContextExample.d.ts +12 -0
  31. package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +54 -0
  32. package/dist/v2/react/hooks/useFunnel.d.ts +1 -1
  33. package/dist/v2/react/hooks/useFunnel.js +209 -32
  34. package/dist/v2/react/hooks/useGoogleAutocomplete.js +26 -18
  35. package/dist/v2/react/hooks/useISOData.js +4 -2
  36. package/dist/v2/react/hooks/useOffersQuery.d.ts +24 -29
  37. package/dist/v2/react/hooks/useOffersQuery.js +164 -204
  38. package/dist/v2/react/hooks/usePaymentQuery.js +99 -6
  39. package/dist/v2/react/providers/TagadaProvider.d.ts +8 -21
  40. package/dist/v2/react/providers/TagadaProvider.js +79 -673
  41. package/package.json +1 -1
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Decode a JWT token to extract session information
3
+ * This is a simple client-side decoder - do not use for security validation
4
+ */
5
+ export function decodeJWTClient(token) {
6
+ try {
7
+ // Split the token into parts
8
+ const parts = token.split('.');
9
+ if (parts.length !== 3) {
10
+ console.error('Invalid JWT token format');
11
+ return null;
12
+ }
13
+ // Decode the payload (second part)
14
+ const payload = parts[1];
15
+ // Add padding if needed
16
+ const paddedPayload = payload + '='.repeat((4 - (payload.length % 4)) % 4);
17
+ // Decode base64
18
+ const decoded = atob(paddedPayload);
19
+ // Parse JSON
20
+ const parsedPayload = JSON.parse(decoded);
21
+ // Check if token is expired
22
+ if (parsedPayload.exp && Date.now() >= parsedPayload.exp * 1000) {
23
+ console.warn('JWT token is expired');
24
+ return null;
25
+ }
26
+ // Return session data
27
+ return {
28
+ sessionId: parsedPayload.sessionId,
29
+ storeId: parsedPayload.storeId,
30
+ accountId: parsedPayload.accountId,
31
+ customerId: parsedPayload.customerId,
32
+ role: parsedPayload.role,
33
+ isValid: true,
34
+ isLoading: false,
35
+ };
36
+ }
37
+ catch (error) {
38
+ console.error('Failed to decode JWT token:', error);
39
+ return null;
40
+ }
41
+ }
42
+ /**
43
+ * Check if a JWT token is expired
44
+ */
45
+ export function isTokenExpired(token) {
46
+ try {
47
+ const parts = token.split('.');
48
+ if (parts.length !== 3)
49
+ return true;
50
+ const payload = parts[1];
51
+ const paddedPayload = payload + '='.repeat((4 - (payload.length % 4)) % 4);
52
+ const decoded = atob(paddedPayload);
53
+ const parsedPayload = JSON.parse(decoded);
54
+ if (parsedPayload.exp) {
55
+ return Date.now() >= parsedPayload.exp * 1000;
56
+ }
57
+ return false;
58
+ }
59
+ catch (error) {
60
+ console.error('Failed to check token expiration:', error);
61
+ return true;
62
+ }
63
+ }
64
+ /**
65
+ * Get token expiration time
66
+ */
67
+ export function getTokenExpiration(token) {
68
+ try {
69
+ const parts = token.split('.');
70
+ if (parts.length !== 3)
71
+ return null;
72
+ const payload = parts[1];
73
+ const paddedPayload = payload + '='.repeat((4 - (payload.length % 4)) % 4);
74
+ const decoded = atob(paddedPayload);
75
+ const parsedPayload = JSON.parse(decoded);
76
+ if (parsedPayload.exp) {
77
+ return new Date(parsedPayload.exp * 1000);
78
+ }
79
+ return null;
80
+ }
81
+ catch (error) {
82
+ console.error('Failed to get token expiration:', error);
83
+ return null;
84
+ }
85
+ }
@@ -8,6 +8,12 @@ import { resolveEnvValue } from './env';
8
8
  */
9
9
  const loadLocalDevConfig = async (configVariant = 'default') => {
10
10
  try {
11
+ // Check for explicit environment override
12
+ const env = resolveEnvValue('TAGADA_ENV') || resolveEnvValue('TAGADA_ENVIRONMENT');
13
+ if (env === 'production') {
14
+ // Skip local config loading if explicitly in production mode
15
+ return null;
16
+ }
11
17
  // Only try to load local config in development
12
18
  // Use hostname-based detection for better Vite compatibility
13
19
  const isLocalDev = typeof window !== 'undefined' &&
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Client-side token storage utilities
3
+ */
4
+ /**
5
+ * Set the CMS token in localStorage
6
+ */
7
+ export declare function setClientToken(token: string): void;
8
+ /**
9
+ * Get the CMS token from localStorage
10
+ */
11
+ export declare function getClientToken(): string | null;
12
+ /**
13
+ * Clear the CMS token from localStorage
14
+ */
15
+ export declare function clearClientToken(): void;
16
+ /**
17
+ * Check if a token exists in localStorage
18
+ */
19
+ export declare function hasClientToken(): boolean;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Client-side token storage utilities
3
+ */
4
+ const TOKEN_KEY = 'cms_token';
5
+ /**
6
+ * Set the CMS token in localStorage
7
+ */
8
+ export function setClientToken(token) {
9
+ if (typeof window !== 'undefined') {
10
+ try {
11
+ localStorage.setItem(TOKEN_KEY, token);
12
+ window.dispatchEvent(new Event('storage'));
13
+ }
14
+ catch (error) {
15
+ console.error('Failed to save token to localStorage:', error);
16
+ }
17
+ }
18
+ }
19
+ /**
20
+ * Get the CMS token from localStorage
21
+ */
22
+ export function getClientToken() {
23
+ if (typeof window !== 'undefined') {
24
+ try {
25
+ return localStorage.getItem(TOKEN_KEY);
26
+ }
27
+ catch (error) {
28
+ console.error('Failed to get token from localStorage:', error);
29
+ return null;
30
+ }
31
+ }
32
+ return null;
33
+ }
34
+ /**
35
+ * Clear the CMS token from localStorage
36
+ */
37
+ export function clearClientToken() {
38
+ if (typeof window !== 'undefined') {
39
+ try {
40
+ localStorage.removeItem(TOKEN_KEY);
41
+ }
42
+ catch (error) {
43
+ console.error('Failed to clear token from localStorage:', error);
44
+ }
45
+ }
46
+ }
47
+ /**
48
+ * Check if a token exists in localStorage
49
+ */
50
+ export function hasClientToken() {
51
+ return !!getClientToken();
52
+ }
@@ -582,7 +582,96 @@ export const DebugDrawer = ({ isOpen, onClose }) => {
582
582
  color: isCurrent ? '#d1fae5' : '#9ca3af',
583
583
  marginLeft: '8px',
584
584
  }, children: ["\u2022 ", cond.type, " \u2192 ", cond.nextStepId] }, condIdx)))] }))] }, step.id));
585
- }) })] })), _jsxs("div", { style: { marginTop: '12px' }, children: [_jsx("h4", { style: { margin: '0 0 8px 0', color: '#60a5fa', fontSize: '13px' }, children: "\uD83D\uDD0D Raw Data" }), _jsx("div", { style: { fontSize: '11px' }, children: _jsx(TreeView, { data: context.debugFunnel.data, name: "funnelData" }) })] })] })) : (_jsx("p", { style: { color: '#6b7280' }, children: "No funnel hook active" }))] })), activeTab === 'checkout' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Checkout Debug" }), context.debugCheckout.isActive ? (_jsxs("div", { children: [_jsxs("div", { style: { marginBottom: '20px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#60a5fa' }, children: "Status" }), _jsxs("div", { style: { display: 'grid', gap: '8px' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Hook Active:" }), _jsx("span", { style: { color: '#10b981' }, children: "\u2705 Yes" })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Loading:" }), _jsx("span", { style: { color: context.debugCheckout.isLoading ? '#f59e0b' : '#10b981' }, children: context.debugCheckout.isLoading ? '⏳ Yes' : '✅ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Has Error:" }), _jsx("span", { style: { color: context.debugCheckout.error ? '#ef4444' : '#10b981' }, children: context.debugCheckout.error ? '❌ Yes' : '✅ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Last Updated:" }), _jsx("span", { style: { color: '#9ca3af', fontSize: '12px' }, children: context.debugCheckout.lastUpdated?.toLocaleTimeString() || 'Never' })] })] })] }), context.debugCheckout.error && (_jsxs("div", { style: { marginBottom: '20px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#ef4444' }, children: "Error Details" }), _jsxs("div", { style: {
585
+ }) })] })), context.debugFunnel.data?.session && (_jsxs("div", { style: { marginBottom: '16px' }, children: [_jsx("h4", { style: { margin: '0 0 8px 0', color: '#60a5fa', fontSize: '13px' }, children: "\uD83D\uDCE6 Resources & Context" }), context.debugFunnel.data.session.resources &&
586
+ Object.keys(context.debugFunnel.data.session.resources).length > 0 && (_jsxs("div", { style: { marginBottom: '12px' }, children: [_jsxs("div", { style: {
587
+ fontSize: '11px',
588
+ color: '#10b981',
589
+ fontWeight: 'bold',
590
+ marginBottom: '6px',
591
+ }, children: ["\uD83C\uDFAF Available Resources (", Object.keys(context.debugFunnel.data.session.resources).length, ")"] }), _jsx("div", { style: { display: 'grid', gap: '8px' }, children: Object.entries(context.debugFunnel.data.session.resources).map(([key, value]) => {
592
+ // Skip undefined/null resources
593
+ if (value === undefined || value === null)
594
+ return null;
595
+ // Check if it's an array or single resource
596
+ const isArray = Array.isArray(value);
597
+ const resourceCount = isArray ? value.length : 1;
598
+ return (_jsxs("div", { style: {
599
+ border: '1px solid #374151',
600
+ borderRadius: '6px',
601
+ padding: '10px',
602
+ backgroundColor: '#111827',
603
+ }, children: [_jsxs("div", { style: {
604
+ display: 'flex',
605
+ justifyContent: 'space-between',
606
+ alignItems: 'center',
607
+ marginBottom: '8px',
608
+ }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '6px' }, children: [_jsx("span", { style: { color: '#10b981', fontSize: '14px' }, children: key === 'order' || key === 'mainOrder'
609
+ ? '🛒'
610
+ : key === 'customer'
611
+ ? '👤'
612
+ : key === 'checkout'
613
+ ? '💳'
614
+ : key === 'offer'
615
+ ? '🎁'
616
+ : key === 'subscription'
617
+ ? '🔄'
618
+ : '📄' }), _jsx("span", { style: {
619
+ color: '#f9fafb',
620
+ fontWeight: 'bold',
621
+ fontSize: '12px',
622
+ }, children: key }), isArray && (_jsxs("span", { style: {
623
+ fontSize: '10px',
624
+ backgroundColor: '#3b82f6',
625
+ color: '#fff',
626
+ padding: '2px 6px',
627
+ borderRadius: '3px',
628
+ }, children: [resourceCount, " items"] }))] }), !isArray && value && typeof value === 'object' && (_jsx("div", { style: { fontSize: '10px', color: '#9ca3af' }, children: value.id && (_jsx("span", { style: { fontFamily: 'monospace' }, children: value.id })) }))] }), !isArray && value && typeof value === 'object' && (_jsxs("div", { style: {
629
+ display: 'grid',
630
+ gridTemplateColumns: '1fr 1fr',
631
+ gap: '6px',
632
+ fontSize: '11px',
633
+ marginBottom: '8px',
634
+ }, children: [value.amount !== undefined && (_jsxs("div", { children: [_jsx("span", { style: { color: '#6b7280' }, children: "Amount: " }), _jsx("span", { style: { color: '#10b981', fontWeight: 'bold' }, children: (() => {
635
+ try {
636
+ return context.money.formatMoney(Number(value.amount) || 0, String(value.currency) || 'USD', context.locale.locale);
637
+ }
638
+ catch {
639
+ return `${value.amount} ${value.currency || ''}`;
640
+ }
641
+ })() })] })), value.email !== undefined && (_jsxs("div", { children: [_jsx("span", { style: { color: '#6b7280' }, children: "Email: " }), _jsx("span", { style: { color: '#60a5fa' }, children: value.email })] })), value.status !== undefined && (_jsxs("div", { children: [_jsx("span", { style: { color: '#6b7280' }, children: "Status: " }), _jsx("span", { style: { color: '#f59e0b' }, children: value.status })] })), value.currency !== undefined && (_jsxs("div", { children: [_jsx("span", { style: { color: '#6b7280' }, children: "Currency: " }), _jsx("span", { style: { color: '#8b5cf6' }, children: value.currency })] }))] })), _jsxs("details", { style: { marginTop: '6px' }, children: [_jsx("summary", { style: {
642
+ cursor: 'pointer',
643
+ fontSize: '10px',
644
+ color: '#60a5fa',
645
+ fontWeight: 'bold',
646
+ }, children: "Show Full Data" }), _jsx("div", { style: { marginTop: '6px', fontSize: '10px' }, children: _jsx(TreeView, { data: value, name: key, maxLevel: 3 }) })] })] }, key));
647
+ }) })] })), context.debugFunnel.data.session.metadata &&
648
+ Object.keys(context.debugFunnel.data.session.metadata).length > 0 && (_jsxs("div", { style: { marginBottom: '12px' }, children: [_jsxs("div", { style: {
649
+ fontSize: '11px',
650
+ color: '#8b5cf6',
651
+ fontWeight: 'bold',
652
+ marginBottom: '6px',
653
+ }, children: ["\uD83D\uDCDD Session Metadata (", Object.keys(context.debugFunnel.data.session.metadata).length, ")"] }), _jsx("div", { style: {
654
+ border: '1px solid #374151',
655
+ borderRadius: '6px',
656
+ padding: '10px',
657
+ backgroundColor: '#111827',
658
+ }, children: _jsx(TreeView, { data: context.debugFunnel.data.session.metadata, name: "metadata", maxLevel: 2 }) })] })), _jsxs("div", { style: { marginBottom: '12px' }, children: [_jsx("div", { style: {
659
+ fontSize: '11px',
660
+ color: '#f59e0b',
661
+ fontWeight: 'bold',
662
+ marginBottom: '6px',
663
+ }, children: "\u2139\uFE0F Session Context" }), _jsx("div", { style: {
664
+ border: '1px solid #374151',
665
+ borderRadius: '6px',
666
+ padding: '10px',
667
+ backgroundColor: '#111827',
668
+ }, children: _jsxs("div", { style: { display: 'grid', gap: '6px', fontSize: '11px' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { style: { color: '#6b7280' }, children: "Customer ID:" }), _jsx("span", { style: { color: '#60a5fa', fontFamily: 'monospace', fontSize: '10px' }, children: context.debugFunnel.data.session.customerId })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { style: { color: '#6b7280' }, children: "Store ID:" }), _jsx("span", { style: { color: '#60a5fa', fontFamily: 'monospace', fontSize: '10px' }, children: context.debugFunnel.data.session.storeId })] }), context.debugFunnel.data.session.environment && (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { style: { color: '#6b7280' }, children: "Environment:" }), _jsx("span", { style: { color: '#10b981' }, children: context.debugFunnel.data.session.environment })] })), context.debugFunnel.data.session.startedAt && (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { style: { color: '#6b7280' }, children: "Started At:" }), _jsx("span", { style: { color: '#9ca3af', fontSize: '10px' }, children: new Date(context.debugFunnel.data.session.startedAt).toLocaleString() })] })), context.debugFunnel.data.session.lastActivityAt && (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { style: { color: '#6b7280' }, children: "Last Activity:" }), _jsx("span", { style: { color: '#9ca3af', fontSize: '10px' }, children: new Date(context.debugFunnel.data.session.lastActivityAt).toLocaleString() })] }))] }) })] })] })), _jsxs("details", { style: { marginTop: '12px' }, children: [_jsx("summary", { style: {
669
+ cursor: 'pointer',
670
+ fontWeight: 'bold',
671
+ fontSize: '13px',
672
+ color: '#60a5fa',
673
+ marginBottom: '8px',
674
+ }, children: "\uD83D\uDD0D Raw Funnel Data (Debug)" }), _jsx("div", { style: { fontSize: '11px', marginTop: '8px' }, children: _jsx(TreeView, { data: context.debugFunnel.data, name: "funnelData", maxLevel: 4 }) })] })] })) : (_jsx("p", { style: { color: '#6b7280' }, children: "No funnel hook active" }))] })), activeTab === 'checkout' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Checkout Debug" }), context.debugCheckout.isActive ? (_jsxs("div", { children: [_jsxs("div", { style: { marginBottom: '20px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#60a5fa' }, children: "Status" }), _jsxs("div", { style: { display: 'grid', gap: '8px' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Hook Active:" }), _jsx("span", { style: { color: '#10b981' }, children: "\u2705 Yes" })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Loading:" }), _jsx("span", { style: { color: context.debugCheckout.isLoading ? '#f59e0b' : '#10b981' }, children: context.debugCheckout.isLoading ? '⏳ Yes' : '✅ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Has Error:" }), _jsx("span", { style: { color: context.debugCheckout.error ? '#ef4444' : '#10b981' }, children: context.debugCheckout.error ? '❌ Yes' : '✅ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Last Updated:" }), _jsx("span", { style: { color: '#9ca3af', fontSize: '12px' }, children: context.debugCheckout.lastUpdated?.toLocaleTimeString() || 'Never' })] })] })] }), context.debugCheckout.error && (_jsxs("div", { style: { marginBottom: '20px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#ef4444' }, children: "Error Details" }), _jsxs("div", { style: {
586
675
  backgroundColor: '#372c2c',
587
676
  padding: '12px',
588
677
  borderRadius: '4px',
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Example: Accessing Funnel Context & Resources
3
+ *
4
+ * This example demonstrates how to access data from previous steps
5
+ * using the funnel context, including order, customer, and other resources.
6
+ */
7
+ export declare function FunnelContextExample(): import("react/jsx-runtime").JSX.Element;
8
+ /**
9
+ * Simple example for documentation
10
+ * This can now be called with or without options
11
+ */
12
+ export declare function SimpleContextExample(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Example: Accessing Funnel Context & Resources
4
+ *
5
+ * This example demonstrates how to access data from previous steps
6
+ * using the funnel context, including order, customer, and other resources.
7
+ */
8
+ import { useFunnel } from '../useFunnel';
9
+ export function FunnelContextExample() {
10
+ const { context, isLoading, isInitialized } = useFunnel({
11
+ autoInitialize: true,
12
+ });
13
+ if (isLoading) {
14
+ return _jsx("div", { children: "Loading funnel session..." });
15
+ }
16
+ if (!isInitialized || !context) {
17
+ return _jsx("div", { children: "Funnel not initialized" });
18
+ }
19
+ // Access resources from context
20
+ const order = context.resources?.order;
21
+ const customer = context.resources?.customer;
22
+ const checkout = context.resources?.checkout;
23
+ const orders = context.resources?.orders || [];
24
+ return (_jsxs("div", { style: { padding: '20px', fontFamily: 'sans-serif' }, children: [_jsx("h1", { children: "Funnel Context Example" }), _jsxs("section", { style: { marginBottom: '30px' }, children: [_jsx("h2", { children: "Session Info" }), _jsxs("ul", { children: [_jsxs("li", { children: [_jsx("strong", { children: "Session ID:" }), " ", context.sessionId] }), _jsxs("li", { children: [_jsx("strong", { children: "Funnel ID:" }), " ", context.funnelId] }), _jsxs("li", { children: [_jsx("strong", { children: "Current Step:" }), " ", context.currentStepId] }), _jsxs("li", { children: [_jsx("strong", { children: "Previous Step:" }), " ", context.previousStepId || 'None'] }), _jsxs("li", { children: [_jsx("strong", { children: "Furthest Step:" }), " ", context.furthestStepId || 'None'] }), _jsxs("li", { children: [_jsx("strong", { children: "Environment:" }), " ", context.environment || 'Not set'] })] })] }), _jsxs("section", { style: { marginBottom: '30px' }, children: [_jsx("h2", { children: "Resources" }), order && (_jsxs("div", { style: { marginBottom: '20px', padding: '15px', border: '1px solid #ddd', borderRadius: '5px' }, children: [_jsx("h3", { children: "Order (Hot Context)" }), _jsx("pre", { style: { background: '#f5f5f5', padding: '10px', borderRadius: '3px', overflow: 'auto' }, children: JSON.stringify(order, null, 2) })] })), customer && (_jsxs("div", { style: { marginBottom: '20px', padding: '15px', border: '1px solid #ddd', borderRadius: '5px' }, children: [_jsx("h3", { children: "Customer" }), _jsx("pre", { style: { background: '#f5f5f5', padding: '10px', borderRadius: '3px', overflow: 'auto' }, children: JSON.stringify(customer, null, 2) })] })), checkout && (_jsxs("div", { style: { marginBottom: '20px', padding: '15px', border: '1px solid #ddd', borderRadius: '5px' }, children: [_jsx("h3", { children: "Checkout" }), _jsx("pre", { style: { background: '#f5f5f5', padding: '10px', borderRadius: '3px', overflow: 'auto' }, children: JSON.stringify(checkout, null, 2) })] })), orders.length > 0 && (_jsxs("div", { style: { marginBottom: '20px', padding: '15px', border: '1px solid #ddd', borderRadius: '5px' }, children: [_jsxs("h3", { children: ["Orders Collection (", orders.length, " orders)"] }), orders.map((o, index) => (_jsxs("div", { style: { marginBottom: '10px' }, children: [_jsxs("strong", { children: ["Order ", index + 1, ":"] }), _jsx("pre", { style: {
25
+ background: '#f5f5f5',
26
+ padding: '10px',
27
+ borderRadius: '3px',
28
+ marginTop: '5px',
29
+ overflow: 'auto',
30
+ }, children: JSON.stringify(o, null, 2) })] }, o.id || index)))] })), _jsxs("details", { style: { marginTop: '20px' }, children: [_jsx("summary", { style: { cursor: 'pointer', fontWeight: 'bold' }, children: "Show All Resources (Raw)" }), _jsx("pre", { style: {
31
+ background: '#f5f5f5',
32
+ padding: '10px',
33
+ borderRadius: '3px',
34
+ marginTop: '10px',
35
+ overflow: 'auto',
36
+ }, children: JSON.stringify(context.resources, null, 2) })] })] }), context.metadata && Object.keys(context.metadata).length > 0 && (_jsxs("section", { style: { marginBottom: '30px' }, children: [_jsx("h2", { children: "Metadata" }), _jsx("pre", { style: { background: '#f5f5f5', padding: '10px', borderRadius: '3px', overflow: 'auto' }, children: JSON.stringify(context.metadata, null, 2) })] })), _jsxs("details", { children: [_jsx("summary", { style: { cursor: 'pointer', fontWeight: 'bold' }, children: "Show Full Context (Debug)" }), _jsx("pre", { style: {
37
+ background: '#f5f5f5',
38
+ padding: '10px',
39
+ borderRadius: '3px',
40
+ marginTop: '10px',
41
+ overflow: 'auto',
42
+ }, children: JSON.stringify(context, null, 2) })] })] }));
43
+ }
44
+ /**
45
+ * Simple example for documentation
46
+ * This can now be called with or without options
47
+ */
48
+ export function SimpleContextExample() {
49
+ const funnel = useFunnel(); // Works without params!
50
+ // Access data from previous steps
51
+ const order = funnel.context?.resources?.order;
52
+ const customer = funnel.context?.resources?.customer;
53
+ return (_jsxs("div", { children: [_jsxs("h1", { children: ["Order ", order?.id] }), _jsxs("p", { children: ["Customer: ", customer?.email] }), _jsxs("p", { children: ["Amount: $", ((order?.amount || 0) / 100).toFixed(2)] })] }));
54
+ }
@@ -37,7 +37,7 @@ export interface UseFunnelResult {
37
37
  * Modern funnel navigation using TanStack Query for state management
38
38
  * and the v2 ApiClient architecture.
39
39
  */
40
- export declare function useFunnel(options: UseFunnelOptions): UseFunnelResult;
40
+ export declare function useFunnel(options?: UseFunnelOptions): UseFunnelResult;
41
41
  /**
42
42
  * Simplified funnel hook for basic step tracking (v2)
43
43
  */