@appfunnel-dev/sdk 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AppFunnelConfig, P as PageDefinition, V as VariableValue, U as UserState, L as LocaleState, T as TranslationState, N as NavigationState, a as ProductsState, b as TrackingState, c as PaymentState, D as DeviceInfo, d as PageData, F as FunnelState } from './internal-BlgQ9C2d.cjs';
2
- export { C as ConditionConfig, e as ConditionGroupConfig, f as FunnelProvider, g as FunnelProviderProps, h as FunnelSettings, i as PageConfig, j as PageState, k as PageType, l as ProductConfig, m as ProductsConfig, n as Progress, R as RouteConfig, o as RuntimeProduct, p as VariableConfig, q as VariableType } from './internal-BlgQ9C2d.cjs';
1
+ import { A as AppFunnelConfig, P as PageDefinition, V as VariableValue, U as UserState, L as LocaleState, T as TranslationState, N as NavigationState, a as ProductsState, b as TrackingState, c as PaymentState, D as DeviceInfo, d as PageData, F as FunnelState } from './internal-C9MOEdND.cjs';
2
+ export { C as ConditionConfig, e as ConditionGroupConfig, f as FunnelProvider, g as FunnelProviderProps, h as FunnelSettings, i as PageConfig, j as PageState, k as PageType, l as ProductConfig, m as ProductsConfig, n as Progress, R as RouteConfig, o as RuntimeProduct, p as VariableConfig, q as VariableType } from './internal-C9MOEdND.cjs';
3
3
  import * as react from 'react';
4
4
  import { Appearance } from '@stripe/stripe-js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -40,6 +40,9 @@ declare function definePage(definition: PageDefinition): PageDefinition;
40
40
  /**
41
41
  * Read/write a single variable.
42
42
  *
43
+ * **Advanced** — this hook is not intended for normal page usage.
44
+ * Prefer accessing variables through the standard page props instead.
45
+ *
43
46
  * ```tsx
44
47
  * const [email, setEmail] = useVariable<string>('email')
45
48
  * const [count, setCount] = useVariable<number>('count')
@@ -52,9 +55,17 @@ declare function useVariable<T extends VariableValue>(id: string): [T, (value: T
52
55
  /**
53
56
  * Read all variables (including system variables). Read-only.
54
57
  * Use useVariable() to write individual variables.
58
+ *
59
+ * **Advanced** — this hook is not intended for normal page usage.
60
+ * Prefer accessing variables through the standard page props instead.
61
+ *
62
+ * Warning: this hook subscribes to ALL variable changes, so the
63
+ * component will re-render on every single variable update.
55
64
  */
56
65
  declare function useVariables(): Record<string, VariableValue>;
57
66
 
67
+ type DateFormat = 'MM/DD/YYYY' | 'DD/MM/YYYY' | 'YYYY-MM-DD';
68
+
58
69
  /**
59
70
  * Read built-in user state (email, name, customerId).
60
71
  *
@@ -72,6 +83,21 @@ declare function useUser(): UserState;
72
83
  * ```
73
84
  */
74
85
  declare function useUserProperty(field: string): [string, (value: string) => void];
86
+ /**
87
+ * Read/write the user's date of birth.
88
+ * Always stores the value as YYYY-MM-DD regardless of input format.
89
+ *
90
+ * @param format - How the input string should be interpreted (default: MM/DD/YYYY).
91
+ *
92
+ * ```tsx
93
+ * const [dob, setDob] = useDateOfBirth() // defaults to MM/DD/YYYY
94
+ * const [dob, setDob] = useDateOfBirth('DD/MM/YYYY') // explicit EU format
95
+ *
96
+ * setDob('03/15/1990') // stored as "1990-03-15"
97
+ * setDob('03151990') // stored as "1990-03-15"
98
+ * ```
99
+ */
100
+ declare function useDateOfBirth(format?: DateFormat): [string, (value: string) => void];
75
101
 
76
102
  /**
77
103
  * Read/write a single response variable (answers.*).
@@ -164,12 +190,12 @@ declare function useNavigation(): NavigationState;
164
190
  declare function useProducts(): ProductsState;
165
191
 
166
192
  /**
167
- * Tracking hook — fire events and identify users.
193
+ * Tracking hook — fire custom events.
168
194
  */
169
195
  declare function useTracking(): TrackingState;
170
196
 
171
197
  /**
172
- * Payment hook — reads payment-related variables.
198
+ * Payment hook — reads payment-related variables and provides a purchase action.
173
199
  *
174
200
  * Only re-renders when payment/card variables change.
175
201
  */
@@ -188,6 +214,47 @@ declare function usePayment(): PaymentState;
188
214
  */
189
215
  declare function useDeviceInfo(): DeviceInfo;
190
216
 
217
+ interface SafeAreaInsets {
218
+ top: number;
219
+ right: number;
220
+ bottom: number;
221
+ left: number;
222
+ }
223
+ /**
224
+ * Returns the current safe-area insets (in px) from `env(safe-area-inset-*)`.
225
+ *
226
+ * Useful for positioning fixed elements above the Safari home-indicator bar.
227
+ *
228
+ * ```tsx
229
+ * const { bottom } = useSafeArea()
230
+ * <div style={{ position: 'fixed', bottom: 0, paddingBottom: bottom }} />
231
+ * ```
232
+ */
233
+ declare function useSafeArea(): SafeAreaInsets;
234
+
235
+ interface KeyboardState {
236
+ /** Whether the virtual keyboard is currently visible */
237
+ isOpen: boolean;
238
+ /** Height of the keyboard in pixels (0 when closed) */
239
+ height: number;
240
+ }
241
+ /**
242
+ * Detects the virtual keyboard on mobile devices.
243
+ *
244
+ * Uses the VirtualKeyboard API where available, with a
245
+ * visualViewport fallback for Safari/older browsers.
246
+ *
247
+ * The visualViewport path follows the approach described at
248
+ * https://martijnhols.nl/blog/how-to-get-document-height-ios-safari-osk
249
+ * to handle iOS Safari's delayed viewport updates on keyboard close.
250
+ *
251
+ * ```tsx
252
+ * const { isOpen, height } = useKeyboard()
253
+ * <div style={{ position: 'fixed', bottom: isOpen ? height : 0 }} />
254
+ * ```
255
+ */
256
+ declare function useKeyboard(): KeyboardState;
257
+
191
258
  /**
192
259
  * Read page-level system variables.
193
260
  *
@@ -232,6 +299,9 @@ interface StripePaymentFormProps {
232
299
  /**
233
300
  * Stripe payment component supporting PaymentElement and Embedded Checkout.
234
301
  *
302
+ * In dev mode (`globalThis.__APPFUNNEL_DEV__`), renders a demo form that
303
+ * simulates Stripe UI and emulates purchases without real Stripe calls.
304
+ *
235
305
  * Use a ref to submit the form from an external button:
236
306
  * ```tsx
237
307
  * const paymentRef = useRef<StripePaymentHandle>(null)
@@ -288,4 +358,4 @@ type IntegrationLoader = (config: Record<string, unknown>) => void;
288
358
  */
289
359
  declare function registerIntegration(id: string, loader: IntegrationLoader): void;
290
360
 
291
- export { AppFunnelConfig, DeviceInfo, FunnelState, type IntegrationConfigs, LocaleState, NavigationState, PaddleCheckout, type PaddleCheckoutProps, PageData, PageDefinition, PaymentState, ProductsState, StripePaymentForm, type StripePaymentFormProps, type StripePaymentHandle, TrackingState, TranslationState, UserState, VariableValue, defineConfig, definePage, registerIntegration, useData, useDeviceInfo, useFunnel, useLocale, useNavigation, usePageData, usePayment, useProducts, useQueryParam, useQueryParams, useResponse, useResponses, useTracking, useTranslation, useUser, useUserProperty, useVariable, useVariables };
361
+ export { AppFunnelConfig, type DateFormat, DeviceInfo, FunnelState, type IntegrationConfigs, type KeyboardState, LocaleState, NavigationState, PaddleCheckout, type PaddleCheckoutProps, PageData, PageDefinition, PaymentState, ProductsState, type SafeAreaInsets, StripePaymentForm, type StripePaymentFormProps, type StripePaymentHandle, TrackingState, TranslationState, UserState, VariableValue, defineConfig, definePage, registerIntegration, useData, useDateOfBirth, useDeviceInfo, useFunnel, useKeyboard, useLocale, useNavigation, usePageData, usePayment, useProducts, useQueryParam, useQueryParams, useResponse, useResponses, useSafeArea, useTracking, useTranslation, useUser, useUserProperty, useVariable, useVariables };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AppFunnelConfig, P as PageDefinition, V as VariableValue, U as UserState, L as LocaleState, T as TranslationState, N as NavigationState, a as ProductsState, b as TrackingState, c as PaymentState, D as DeviceInfo, d as PageData, F as FunnelState } from './internal-BlgQ9C2d.js';
2
- export { C as ConditionConfig, e as ConditionGroupConfig, f as FunnelProvider, g as FunnelProviderProps, h as FunnelSettings, i as PageConfig, j as PageState, k as PageType, l as ProductConfig, m as ProductsConfig, n as Progress, R as RouteConfig, o as RuntimeProduct, p as VariableConfig, q as VariableType } from './internal-BlgQ9C2d.js';
1
+ import { A as AppFunnelConfig, P as PageDefinition, V as VariableValue, U as UserState, L as LocaleState, T as TranslationState, N as NavigationState, a as ProductsState, b as TrackingState, c as PaymentState, D as DeviceInfo, d as PageData, F as FunnelState } from './internal-C9MOEdND.js';
2
+ export { C as ConditionConfig, e as ConditionGroupConfig, f as FunnelProvider, g as FunnelProviderProps, h as FunnelSettings, i as PageConfig, j as PageState, k as PageType, l as ProductConfig, m as ProductsConfig, n as Progress, R as RouteConfig, o as RuntimeProduct, p as VariableConfig, q as VariableType } from './internal-C9MOEdND.js';
3
3
  import * as react from 'react';
4
4
  import { Appearance } from '@stripe/stripe-js';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -40,6 +40,9 @@ declare function definePage(definition: PageDefinition): PageDefinition;
40
40
  /**
41
41
  * Read/write a single variable.
42
42
  *
43
+ * **Advanced** — this hook is not intended for normal page usage.
44
+ * Prefer accessing variables through the standard page props instead.
45
+ *
43
46
  * ```tsx
44
47
  * const [email, setEmail] = useVariable<string>('email')
45
48
  * const [count, setCount] = useVariable<number>('count')
@@ -52,9 +55,17 @@ declare function useVariable<T extends VariableValue>(id: string): [T, (value: T
52
55
  /**
53
56
  * Read all variables (including system variables). Read-only.
54
57
  * Use useVariable() to write individual variables.
58
+ *
59
+ * **Advanced** — this hook is not intended for normal page usage.
60
+ * Prefer accessing variables through the standard page props instead.
61
+ *
62
+ * Warning: this hook subscribes to ALL variable changes, so the
63
+ * component will re-render on every single variable update.
55
64
  */
56
65
  declare function useVariables(): Record<string, VariableValue>;
57
66
 
67
+ type DateFormat = 'MM/DD/YYYY' | 'DD/MM/YYYY' | 'YYYY-MM-DD';
68
+
58
69
  /**
59
70
  * Read built-in user state (email, name, customerId).
60
71
  *
@@ -72,6 +83,21 @@ declare function useUser(): UserState;
72
83
  * ```
73
84
  */
74
85
  declare function useUserProperty(field: string): [string, (value: string) => void];
86
+ /**
87
+ * Read/write the user's date of birth.
88
+ * Always stores the value as YYYY-MM-DD regardless of input format.
89
+ *
90
+ * @param format - How the input string should be interpreted (default: MM/DD/YYYY).
91
+ *
92
+ * ```tsx
93
+ * const [dob, setDob] = useDateOfBirth() // defaults to MM/DD/YYYY
94
+ * const [dob, setDob] = useDateOfBirth('DD/MM/YYYY') // explicit EU format
95
+ *
96
+ * setDob('03/15/1990') // stored as "1990-03-15"
97
+ * setDob('03151990') // stored as "1990-03-15"
98
+ * ```
99
+ */
100
+ declare function useDateOfBirth(format?: DateFormat): [string, (value: string) => void];
75
101
 
76
102
  /**
77
103
  * Read/write a single response variable (answers.*).
@@ -164,12 +190,12 @@ declare function useNavigation(): NavigationState;
164
190
  declare function useProducts(): ProductsState;
165
191
 
166
192
  /**
167
- * Tracking hook — fire events and identify users.
193
+ * Tracking hook — fire custom events.
168
194
  */
169
195
  declare function useTracking(): TrackingState;
170
196
 
171
197
  /**
172
- * Payment hook — reads payment-related variables.
198
+ * Payment hook — reads payment-related variables and provides a purchase action.
173
199
  *
174
200
  * Only re-renders when payment/card variables change.
175
201
  */
@@ -188,6 +214,47 @@ declare function usePayment(): PaymentState;
188
214
  */
189
215
  declare function useDeviceInfo(): DeviceInfo;
190
216
 
217
+ interface SafeAreaInsets {
218
+ top: number;
219
+ right: number;
220
+ bottom: number;
221
+ left: number;
222
+ }
223
+ /**
224
+ * Returns the current safe-area insets (in px) from `env(safe-area-inset-*)`.
225
+ *
226
+ * Useful for positioning fixed elements above the Safari home-indicator bar.
227
+ *
228
+ * ```tsx
229
+ * const { bottom } = useSafeArea()
230
+ * <div style={{ position: 'fixed', bottom: 0, paddingBottom: bottom }} />
231
+ * ```
232
+ */
233
+ declare function useSafeArea(): SafeAreaInsets;
234
+
235
+ interface KeyboardState {
236
+ /** Whether the virtual keyboard is currently visible */
237
+ isOpen: boolean;
238
+ /** Height of the keyboard in pixels (0 when closed) */
239
+ height: number;
240
+ }
241
+ /**
242
+ * Detects the virtual keyboard on mobile devices.
243
+ *
244
+ * Uses the VirtualKeyboard API where available, with a
245
+ * visualViewport fallback for Safari/older browsers.
246
+ *
247
+ * The visualViewport path follows the approach described at
248
+ * https://martijnhols.nl/blog/how-to-get-document-height-ios-safari-osk
249
+ * to handle iOS Safari's delayed viewport updates on keyboard close.
250
+ *
251
+ * ```tsx
252
+ * const { isOpen, height } = useKeyboard()
253
+ * <div style={{ position: 'fixed', bottom: isOpen ? height : 0 }} />
254
+ * ```
255
+ */
256
+ declare function useKeyboard(): KeyboardState;
257
+
191
258
  /**
192
259
  * Read page-level system variables.
193
260
  *
@@ -232,6 +299,9 @@ interface StripePaymentFormProps {
232
299
  /**
233
300
  * Stripe payment component supporting PaymentElement and Embedded Checkout.
234
301
  *
302
+ * In dev mode (`globalThis.__APPFUNNEL_DEV__`), renders a demo form that
303
+ * simulates Stripe UI and emulates purchases without real Stripe calls.
304
+ *
235
305
  * Use a ref to submit the form from an external button:
236
306
  * ```tsx
237
307
  * const paymentRef = useRef<StripePaymentHandle>(null)
@@ -288,4 +358,4 @@ type IntegrationLoader = (config: Record<string, unknown>) => void;
288
358
  */
289
359
  declare function registerIntegration(id: string, loader: IntegrationLoader): void;
290
360
 
291
- export { AppFunnelConfig, DeviceInfo, FunnelState, type IntegrationConfigs, LocaleState, NavigationState, PaddleCheckout, type PaddleCheckoutProps, PageData, PageDefinition, PaymentState, ProductsState, StripePaymentForm, type StripePaymentFormProps, type StripePaymentHandle, TrackingState, TranslationState, UserState, VariableValue, defineConfig, definePage, registerIntegration, useData, useDeviceInfo, useFunnel, useLocale, useNavigation, usePageData, usePayment, useProducts, useQueryParam, useQueryParams, useResponse, useResponses, useTracking, useTranslation, useUser, useUserProperty, useVariable, useVariables };
361
+ export { AppFunnelConfig, type DateFormat, DeviceInfo, FunnelState, type IntegrationConfigs, type KeyboardState, LocaleState, NavigationState, PaddleCheckout, type PaddleCheckoutProps, PageData, PageDefinition, PaymentState, ProductsState, type SafeAreaInsets, StripePaymentForm, type StripePaymentFormProps, type StripePaymentHandle, TrackingState, TranslationState, UserState, VariableValue, defineConfig, definePage, registerIntegration, useData, useDateOfBirth, useDeviceInfo, useFunnel, useKeyboard, useLocale, useNavigation, usePageData, usePayment, useProducts, useQueryParam, useQueryParams, useResponse, useResponses, useSafeArea, useTracking, useTranslation, useUser, useUserProperty, useVariable, useVariables };