@appfunnel-dev/sdk 0.10.0 → 0.12.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/{chunk-EVUYCLVY.cjs → chunk-5E6WNNU4.cjs} +7 -3
- package/dist/chunk-5E6WNNU4.cjs.map +1 -0
- package/dist/{chunk-H3KHXZSI.js → chunk-DAHMOQ63.js} +8 -4
- package/dist/chunk-DAHMOQ63.js.map +1 -0
- package/dist/{chunk-XP44I2MU.cjs → chunk-ECWTUTEJ.cjs} +6 -6
- package/dist/{chunk-XP44I2MU.cjs.map → chunk-ECWTUTEJ.cjs.map} +1 -1
- package/dist/{chunk-P4SLDMWY.js → chunk-GZKA33W2.js} +3 -3
- package/dist/{chunk-P4SLDMWY.js.map → chunk-GZKA33W2.js.map} +1 -1
- package/dist/elements/index.cjs +28 -8
- package/dist/elements/index.cjs.map +1 -1
- package/dist/elements/index.d.cts +6 -2
- package/dist/elements/index.d.ts +6 -2
- package/dist/elements/index.js +24 -4
- package/dist/elements/index.js.map +1 -1
- package/dist/index.cjs +50 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/{internal-C9MOEdND.d.cts → internal-BuotLNwa.d.cts} +2 -0
- package/dist/{internal-C9MOEdND.d.ts → internal-BuotLNwa.d.ts} +2 -0
- package/dist/internal.cjs +2 -2
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/package.json +3 -2
- package/dist/chunk-EVUYCLVY.cjs.map +0 -1
- package/dist/chunk-H3KHXZSI.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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-
|
|
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-
|
|
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-BuotLNwa.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-BuotLNwa.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';
|
|
6
|
+
export { toast } from 'sonner';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Type helper for appfunnel.config.ts.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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-
|
|
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-
|
|
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-BuotLNwa.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-BuotLNwa.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';
|
|
6
|
+
export { toast } from 'sonner';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Type helper for appfunnel.config.ts.
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { useNavigation, useResponses } from './chunk-
|
|
2
|
-
export { useNavigation, useResponse, useResponses } from './chunk-
|
|
3
|
-
import { useFunnelContext } from './chunk-
|
|
4
|
-
export { FunnelProvider, registerIntegration } from './chunk-
|
|
1
|
+
import { useNavigation, useResponses } from './chunk-GZKA33W2.js';
|
|
2
|
+
export { useNavigation, useResponse, useResponses } from './chunk-GZKA33W2.js';
|
|
3
|
+
import { useFunnelContext } from './chunk-DAHMOQ63.js';
|
|
4
|
+
export { FunnelProvider, registerIntegration } from './chunk-DAHMOQ63.js';
|
|
5
5
|
import { forwardRef, useMemo, useRef, useEffect, useCallback, useImperativeHandle, useState, useSyncExternalStore } from 'react';
|
|
6
|
+
import { toast } from 'sonner';
|
|
7
|
+
export { toast } from 'sonner';
|
|
6
8
|
import { loadStripe } from '@stripe/stripe-js';
|
|
7
9
|
import { useStripe, useElements, PaymentElement, EmbeddedCheckoutProvider, EmbeddedCheckout, Elements } from '@stripe/react-stripe-js';
|
|
8
10
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
@@ -353,7 +355,8 @@ function useTracking() {
|
|
|
353
355
|
var API_BASE_URL = "https://api.appfunnel.net";
|
|
354
356
|
var PAYMENT_KEYS = ["payment.loading", "payment.error"];
|
|
355
357
|
function usePayment() {
|
|
356
|
-
const { variableStore, products, campaignId, tracker } = useFunnelContext();
|
|
358
|
+
const { variableStore, products, campaignId, tracker, config } = useFunnelContext();
|
|
359
|
+
const showToasts = !config.settings?.disableToasts;
|
|
357
360
|
const subscribe = useCallback(
|
|
358
361
|
(cb) => variableStore.subscribe(cb, { keys: PAYMENT_KEYS }),
|
|
359
362
|
[variableStore]
|
|
@@ -385,6 +388,7 @@ function usePayment() {
|
|
|
385
388
|
const msg = "Please complete payment authorization first";
|
|
386
389
|
console.error("[Purchase] Failed:", msg);
|
|
387
390
|
variableStore.set("payment.error", msg);
|
|
391
|
+
if (showToasts) toast.error(msg);
|
|
388
392
|
options?.onError?.(msg);
|
|
389
393
|
return false;
|
|
390
394
|
}
|
|
@@ -401,6 +405,7 @@ function usePayment() {
|
|
|
401
405
|
const msg = "Product not found or missing Stripe price";
|
|
402
406
|
console.error("[Purchase] Failed:", msg);
|
|
403
407
|
variableStore.set("payment.error", msg);
|
|
408
|
+
if (showToasts) toast.error(msg);
|
|
404
409
|
options?.onError?.(msg);
|
|
405
410
|
return false;
|
|
406
411
|
}
|
|
@@ -450,6 +455,7 @@ function usePayment() {
|
|
|
450
455
|
const msg = "Failed to load payment processor";
|
|
451
456
|
console.error("[Purchase] Failed:", msg);
|
|
452
457
|
variableStore.set("payment.error", msg);
|
|
458
|
+
if (showToasts) toast.error(msg);
|
|
453
459
|
options?.onError?.(msg);
|
|
454
460
|
return false;
|
|
455
461
|
}
|
|
@@ -466,6 +472,7 @@ function usePayment() {
|
|
|
466
472
|
const msg = confirmError?.message || "Payment authentication failed";
|
|
467
473
|
console.error("[Purchase] 3DS failed:", msg);
|
|
468
474
|
variableStore.set("payment.error", msg);
|
|
475
|
+
if (showToasts) toast.error(msg);
|
|
469
476
|
options?.onError?.(msg);
|
|
470
477
|
return false;
|
|
471
478
|
}
|
|
@@ -591,6 +598,7 @@ function usePayment() {
|
|
|
591
598
|
const msg = result.error || "Purchase failed";
|
|
592
599
|
console.error("[Purchase] Failed:", msg);
|
|
593
600
|
variableStore.set("payment.error", msg);
|
|
601
|
+
if (showToasts) toast.error(msg);
|
|
594
602
|
options?.onError?.(msg);
|
|
595
603
|
return false;
|
|
596
604
|
}
|
|
@@ -598,6 +606,7 @@ function usePayment() {
|
|
|
598
606
|
const msg = err instanceof Error ? err.message : "Purchase failed";
|
|
599
607
|
console.error("[Purchase] Exception:", err);
|
|
600
608
|
variableStore.set("payment.error", msg);
|
|
609
|
+
if (showToasts) toast.error(msg);
|
|
601
610
|
options?.onError?.(msg);
|
|
602
611
|
return false;
|
|
603
612
|
} finally {
|
|
@@ -605,7 +614,7 @@ function usePayment() {
|
|
|
605
614
|
variableStore.set("payment.loading", false);
|
|
606
615
|
}
|
|
607
616
|
},
|
|
608
|
-
[variableStore, products, campaignId, tracker]
|
|
617
|
+
[variableStore, products, campaignId, tracker, showToasts]
|
|
609
618
|
);
|
|
610
619
|
return useMemo(
|
|
611
620
|
() => ({
|
|
@@ -1262,7 +1271,8 @@ var InnerPaymentForm = forwardRef(
|
|
|
1262
1271
|
const stripe = useStripe();
|
|
1263
1272
|
const elements = useElements();
|
|
1264
1273
|
const [error, setError] = useState(null);
|
|
1265
|
-
const { variableStore, campaignId, tracker, products } = useFunnelContext();
|
|
1274
|
+
const { variableStore, campaignId, tracker, products, config } = useFunnelContext();
|
|
1275
|
+
const showToasts = !config.settings?.disableToasts;
|
|
1266
1276
|
const readyFired = useRef(false);
|
|
1267
1277
|
useEffect(() => {
|
|
1268
1278
|
if (stripe && elements && !readyFired.current) {
|
|
@@ -1290,6 +1300,7 @@ var InnerPaymentForm = forwardRef(
|
|
|
1290
1300
|
const msg = confirmResult.error.message || "Payment failed";
|
|
1291
1301
|
setError(msg);
|
|
1292
1302
|
variableStore.set("payment.error", msg);
|
|
1303
|
+
if (showToasts) toast.error(msg);
|
|
1293
1304
|
onError?.(msg);
|
|
1294
1305
|
return;
|
|
1295
1306
|
}
|
|
@@ -1300,6 +1311,7 @@ var InnerPaymentForm = forwardRef(
|
|
|
1300
1311
|
const msg = "PaymentIntent not found after confirmation";
|
|
1301
1312
|
setError(msg);
|
|
1302
1313
|
variableStore.set("payment.error", msg);
|
|
1314
|
+
if (showToasts) toast.error(msg);
|
|
1303
1315
|
onError?.(msg);
|
|
1304
1316
|
return;
|
|
1305
1317
|
}
|
|
@@ -1320,6 +1332,7 @@ var InnerPaymentForm = forwardRef(
|
|
|
1320
1332
|
const msg = result2.error || "Card validation failed";
|
|
1321
1333
|
setError(msg);
|
|
1322
1334
|
variableStore.set("payment.error", msg);
|
|
1335
|
+
if (showToasts) toast.error(msg);
|
|
1323
1336
|
onError?.(msg);
|
|
1324
1337
|
return;
|
|
1325
1338
|
}
|
|
@@ -1341,6 +1354,7 @@ var InnerPaymentForm = forwardRef(
|
|
|
1341
1354
|
const msg = "No product selected or missing Stripe price";
|
|
1342
1355
|
setError(msg);
|
|
1343
1356
|
variableStore.set("payment.error", msg);
|
|
1357
|
+
if (showToasts) toast.error(msg);
|
|
1344
1358
|
onError?.(msg);
|
|
1345
1359
|
return;
|
|
1346
1360
|
}
|
|
@@ -1372,12 +1386,14 @@ var InnerPaymentForm = forwardRef(
|
|
|
1372
1386
|
const msg = result.error || "Failed to process payment";
|
|
1373
1387
|
setError(msg);
|
|
1374
1388
|
variableStore.set("payment.error", msg);
|
|
1389
|
+
if (showToasts) toast.error(msg);
|
|
1375
1390
|
onError?.(msg);
|
|
1376
1391
|
}
|
|
1377
1392
|
} catch (err) {
|
|
1378
1393
|
const msg = err instanceof Error ? err.message : "An error occurred";
|
|
1379
1394
|
setError(msg);
|
|
1380
1395
|
variableStore.set("payment.error", msg);
|
|
1396
|
+
if (showToasts) toast.error(msg);
|
|
1381
1397
|
onError?.(msg);
|
|
1382
1398
|
} finally {
|
|
1383
1399
|
variableStore.set("payment.loading", false);
|
|
@@ -1406,7 +1422,8 @@ var RealStripePaymentForm = forwardRef(
|
|
|
1406
1422
|
appearance,
|
|
1407
1423
|
layout
|
|
1408
1424
|
}, ref) {
|
|
1409
|
-
const { campaignId, tracker, variableStore, products, router } = useFunnelContext();
|
|
1425
|
+
const { campaignId, tracker, variableStore, products, router, config } = useFunnelContext();
|
|
1426
|
+
const showToasts = !config.settings?.disableToasts;
|
|
1410
1427
|
const [email] = useVariable("user.email");
|
|
1411
1428
|
const validateOnly = mode === "validate-only";
|
|
1412
1429
|
const product = useMemo(() => {
|
|
@@ -1498,6 +1515,7 @@ var RealStripePaymentForm = forwardRef(
|
|
|
1498
1515
|
const msg = err instanceof Error ? err.message : "Failed to initialize payment";
|
|
1499
1516
|
setError(msg);
|
|
1500
1517
|
variableStore.set("payment.error", msg);
|
|
1518
|
+
if (showToasts) toast.error(msg);
|
|
1501
1519
|
} finally {
|
|
1502
1520
|
setIsLoading(false);
|
|
1503
1521
|
variableStore.set("payment.loading", false);
|